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 1, 2023
1 parent ac67704 commit a481e15
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 @@ -23,11 +23,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 @@ -202,12 +203,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 @@ -232,7 +233,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 @@ -62,6 +62,7 @@ type buildOptions struct {
dockerfileName string
extraHosts []string
imageIDFile string
metadataFile string
labels []string
networkMode string
noCacheFilter []string
Expand All @@ -74,17 +75,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 @@ -276,8 +275,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 @@ -403,7 +402,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 a481e15

Please sign in to comment.