Skip to content

Commit

Permalink
controller: remove MetadataFile from CommonOptions
Browse files Browse the repository at this point in the history
Signed-off-by: CrazyMax <[email protected]>
  • Loading branch information
crazy-max committed Jun 6, 2023
1 parent 9df1970 commit 73b4e04
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 167 deletions.
17 changes: 9 additions & 8 deletions commands/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,12 @@ import (
)

type bakeOptions struct {
files []string
overrides []string
printOnly bool
sbom string
provenance string
files []string
overrides []string
printOnly bool
sbom string
provenance string
metadataFile string

controllerapi.CommonOptions
//control.ControlOptions
Expand Down Expand Up @@ -212,12 +213,12 @@ func runBake(dockerCli command.Cli, targets []string, in bakeOptions, cFlags com
return wrapBuildError(err, true)
}

if len(in.MetadataFile) > 0 {
if len(in.metadataFile) > 0 {
dt := make(map[string]interface{})
for t, r := range resp {
dt[t] = decodeExporterResponse(r.ExporterResponse)
}
if err := writeMetadataFile(in.MetadataFile, dt); err != nil {
if err := writeMetadataFile(in.metadataFile, dt); err != nil {
return err
}
}
Expand All @@ -242,7 +243,7 @@ func bakeCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
cFlags.pull = nil
}
options.Builder = rootOpts.builder
options.MetadataFile = cFlags.metadataFile
options.metadataFile = cFlags.metadataFile
// Other common flags (noCache, pull and progress) are processed in runBake function.
return runBake(dockerCli, args, options, cFlags)
},
Expand Down
19 changes: 9 additions & 10 deletions commands/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ type buildOptions struct {
dockerfileName string
extraHosts []string
imageIDFile string
metadataFile string
labels []string
networkMode string
noCacheFilter []string
Expand All @@ -75,17 +76,15 @@ type buildOptions struct {
tags []string
target string
ulimits *dockeropts.UlimitOpt
attests []string
sbom string
provenance string
progress string
quiet bool

invoke *invokeConfig
noBuild bool

attests []string
sbom string
provenance string

progress string
quiet bool

controllerapi.CommonOptions
control.ControlOptions
}
Expand Down Expand Up @@ -284,8 +283,8 @@ func runBuild(dockerCli command.Cli, options buildOptions) (err error) {
return errors.Wrap(err, "writing image ID file")
}
}
if options.MetadataFile != "" {
if err := writeMetadataFile(options.MetadataFile, decodeExporterResponse(resp.ExporterResponse)); err != nil {
if options.metadataFile != "" {
if err := writeMetadataFile(options.metadataFile, decodeExporterResponse(resp.ExporterResponse)); err != nil {
return err
}
}
Expand Down Expand Up @@ -414,7 +413,7 @@ func buildCmd(dockerCli command.Cli, rootOpts *rootOptions) *cobra.Command {
RunE: func(cmd *cobra.Command, args []string) error {
options.contextPath = args[0]
options.Builder = rootOpts.builder
options.MetadataFile = cFlags.metadataFile
options.metadataFile = cFlags.metadataFile
options.NoCache = false
if cFlags.noCache != nil {
options.NoCache = *cFlags.noCache
Expand Down
Loading

0 comments on commit 73b4e04

Please sign in to comment.