Ver código fonte

fix for sending build logs to segment for pack builds (#3825)

Feroze Mohideen 2 anos atrás
pai
commit
49686cb929
1 arquivos alterados com 10 adições e 0 exclusões
  1. 10 0
      cli/cmd/v2/build.go

+ 10 - 0
cli/cmd/v2/build.go

@@ -151,6 +151,16 @@ func build(ctx context.Context, client api.Client, inp buildInput) buildOutput {
 		err := packAgent.Build(ctx, opts, buildConfig, "")
 		if err != nil {
 			output.Error = fmt.Errorf("error building image with pack: %w", err)
+			logString := "Error reading contents of build log file"
+
+			if logFile != nil {
+				content, err := os.ReadFile(logFile.Name())
+				// only continue if we can read the file. if we cannot, logString will be the default
+				if err == nil {
+					logString = string(content)
+				}
+			}
+			output.Logs = logString
 			return output
 		}
 	default: