Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 28 additions & 24 deletions cmd/compose/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}

Expand Down Expand Up @@ -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
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/api/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions pkg/compose/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -504,6 +509,7 @@ func (s *composeService) toBuildOptions(project *types.Project, service types.Se
Session: sessionConfig,
Allow: allow,
SourcePolicy: sp,
Attests: attests,
}, nil
}

Expand Down