diff --git a/cmd/compose/build.go b/cmd/compose/build.go index f31fbd28ab3..9393745e061 100644 --- a/cmd/compose/build.go +++ b/cmd/compose/build.go @@ -35,17 +35,18 @@ import ( type buildOptions struct { *ProjectOptions - quiet bool - pull bool - push bool - args []string - noCache bool - memory cliopts.MemBytes - ssh string - builder string - deps bool - print bool - check bool + quiet bool + pull bool + push bool + args []string + noCache bool + memory cliopts.MemBytes + ssh string + builder string + deps bool + print bool + check bool + provenance bool } func (opts buildOptions) toAPIBuildOptions(services []string) (api.BuildOptions, error) { @@ -69,20 +70,22 @@ func (opts buildOptions) toAPIBuildOptions(services []string) (api.BuildOptions, if uiMode == ui.ModeJSON { uiMode = "rawjson" } + return api.BuildOptions{ - Pull: opts.pull, - Push: opts.push, - Progress: uiMode, - Args: types.NewMappingWithEquals(opts.args), - NoCache: opts.noCache, - Quiet: opts.quiet, - Services: services, - Deps: opts.deps, - Memory: int64(opts.memory), - Print: opts.print, - Check: opts.check, - SSHs: SSHKeys, - Builder: builderName, + Pull: opts.pull, + Push: opts.push, + Progress: uiMode, + Args: types.NewMappingWithEquals(opts.args), + NoCache: opts.noCache, + Quiet: opts.quiet, + Services: services, + Deps: opts.deps, + Memory: int64(opts.memory), + Print: opts.print, + Check: opts.check, + SSHs: SSHKeys, + Builder: builderName, + Provenance: opts.provenance, }, nil } @@ -153,6 +156,7 @@ func runBuild(ctx context.Context, dockerCli command.Cli, backend api.Service, o } apiBuildOptions, err := opts.toAPIBuildOptions(services) + apiBuildOptions.Provenance = true if err != nil { return err } diff --git a/pkg/api/api.go b/pkg/api/api.go index 95ff19931a8..d4d540be2e2 100644 --- a/pkg/api/api.go +++ b/pkg/api/api.go @@ -159,6 +159,8 @@ type BuildOptions struct { Print bool // Check let builder validate build configuration Check bool + // Provenance + Provenance bool } // Apply mutates project according to build options diff --git a/pkg/compose/build.go b/pkg/compose/build.go index e562a5edb1e..4666bacb00b 100644 --- a/pkg/compose/build.go +++ b/pkg/compose/build.go @@ -481,6 +481,11 @@ func (s *composeService) toBuildOptions(project *types.Project, service types.Se return build.Options{}, err } + attests := map[string]*string{} + if !options.Provenance { + attests["provenance"] = nil + } + return build.Options{ Inputs: build.Inputs{ ContextPath: service.Build.Context, @@ -504,6 +509,7 @@ func (s *composeService) toBuildOptions(project *types.Project, service types.Se Session: sessionConfig, Allow: allow, SourcePolicy: sp, + Attests: attests, }, nil }