mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-20 18:57:44 +08:00
build: don't generate metadata file when print flag is used
Signed-off-by: CrazyMax <1951866+crazy-max@users.noreply.github.com> (cherry picked from commit ba264138d62e79f3f740b272e4b6152fa0fc5199)
This commit is contained in:
parent
b77648d5f8
commit
f6e57cf5b5
@ -142,7 +142,6 @@ func (o *buildOptions) toControllerOptions() (*controllerapi.BuildOptions, error
|
||||
Pull: o.pull,
|
||||
ExportPush: o.exportPush,
|
||||
ExportLoad: o.exportLoad,
|
||||
WithProvenanceResponse: len(o.metadataFile) > 0,
|
||||
}
|
||||
|
||||
// TODO: extract env var parsing to a method easily usable by library consumers
|
||||
@ -207,6 +206,8 @@ func (o *buildOptions) toControllerOptions() (*controllerapi.BuildOptions, error
|
||||
return nil, err
|
||||
}
|
||||
|
||||
opts.WithProvenanceResponse = opts.PrintFunc == nil && len(o.metadataFile) > 0
|
||||
|
||||
return &opts, nil
|
||||
}
|
||||
|
||||
@ -365,15 +366,14 @@ func runBuild(ctx context.Context, dockerCli command.Cli, options buildOptions)
|
||||
return errors.Wrap(err, "writing image ID file")
|
||||
}
|
||||
}
|
||||
if options.metadataFile != "" {
|
||||
if err := writeMetadataFile(options.metadataFile, decodeExporterResponse(resp.ExporterResponse)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if opts.PrintFunc != nil {
|
||||
if err := printResult(opts.PrintFunc, resp.ExporterResponse); err != nil {
|
||||
return err
|
||||
}
|
||||
} else if options.metadataFile != "" {
|
||||
if err := writeMetadataFile(options.metadataFile, decodeExporterResponse(resp.ExporterResponse)); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user