Skip to content

Commit

Permalink
Use absolute path for tarball destination file
Browse files Browse the repository at this point in the history
  • Loading branch information
TinaMor committed Oct 28, 2024
1 parent 09ad9c7 commit a0502ce
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions pkg/cmd/builder/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ func Build(ctx context.Context, client *containerd.Client, options types.Builder
// Open the tar file
reader, err := os.Open(buildCtlArgs.DestFile)
if err != nil {
return fmt.Errorf("Failed to open file destination file: %v", err)
return fmt.Errorf("failed to open file destination file: %v", err)
}
defer reader.Close()

Expand Down Expand Up @@ -187,7 +187,6 @@ func loadImage(ctx context.Context, in io.Reader, namespace, address, snapshotte
if err != nil {
if r.N == 0 {
// Avoid confusing "unrecognized image format"
log.L.Debugf("no image was built. error: %v", err)
return errors.New("no image was built")
}
if errors.Is(err, images.ErrEmptyWalk) {
Expand Down Expand Up @@ -234,11 +233,10 @@ func generateBuildctlArgs(ctx context.Context, client *containerd.Client, option
result.BuildctlBinary = buildctlBinary

// Set the default destination file
var defaultDestFile = "output.tar"
// defaultDestFile, err := filepath.Abs("output.tar")
// if err != nil {
// return result, fmt.Errorf("failed to set the default destination file path: %v", err)
// }
defaultDestFile, err := filepath.Abs("output.tar")
if err != nil {
return result, fmt.Errorf("failed to set the default destination file path: %v", err)
}

output := options.Output
if output == "" {
Expand Down Expand Up @@ -308,7 +306,6 @@ func generateBuildctlArgs(ctx context.Context, client *containerd.Client, option
_, destFilePath, _ := strings.Cut(output, "dest=")
result.DestFile = destFilePath
}
log.L.Debugf("\n------------output: %s\n--------------", output)

buildctlArgs := buildkitutil.BuildctlBaseArgs(options.BuildKitHost)
buildctlArgs = append(buildctlArgs, []string{
Expand Down

0 comments on commit a0502ce

Please sign in to comment.