Skip to content

Commit e6a82a0

Browse files
committed
only use attestation when building image outside the development inner loop
when building a image, by default attestation are generated and modify the image ID which trigger a container recreation on up, run command even if there isn't any changes on the image content itself Signed-off-by: Guillaume Lours <[email protected]>
1 parent 2352a4a commit e6a82a0

File tree

3 files changed

+39
-24
lines changed

3 files changed

+39
-24
lines changed

cmd/compose/build.go

Lines changed: 33 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,18 @@ import (
3535

3636
type buildOptions struct {
3737
*ProjectOptions
38-
quiet bool
39-
pull bool
40-
push bool
41-
args []string
42-
noCache bool
43-
memory cliopts.MemBytes
44-
ssh string
45-
builder string
46-
deps bool
47-
print bool
48-
check bool
38+
quiet bool
39+
pull bool
40+
push bool
41+
args []string
42+
noCache bool
43+
memory cliopts.MemBytes
44+
ssh string
45+
builder string
46+
deps bool
47+
print bool
48+
check bool
49+
provenance string
4950
}
5051

5152
func (opts buildOptions) toAPIBuildOptions(services []string) (api.BuildOptions, error) {
@@ -69,20 +70,27 @@ func (opts buildOptions) toAPIBuildOptions(services []string) (api.BuildOptions,
6970
if uiMode == ui.ModeJSON {
7071
uiMode = "rawjson"
7172
}
73+
var provenance *string
74+
// empty when set by up, run or create functions and "none" when set by the user from the build command
75+
if opts.provenance != "" && opts.provenance != "none" {
76+
provenance = &opts.provenance
77+
}
78+
7279
return api.BuildOptions{
73-
Pull: opts.pull,
74-
Push: opts.push,
75-
Progress: uiMode,
76-
Args: types.NewMappingWithEquals(opts.args),
77-
NoCache: opts.noCache,
78-
Quiet: opts.quiet,
79-
Services: services,
80-
Deps: opts.deps,
81-
Memory: int64(opts.memory),
82-
Print: opts.print,
83-
Check: opts.check,
84-
SSHs: SSHKeys,
85-
Builder: builderName,
80+
Pull: opts.pull,
81+
Push: opts.push,
82+
Progress: uiMode,
83+
Args: types.NewMappingWithEquals(opts.args),
84+
NoCache: opts.noCache,
85+
Quiet: opts.quiet,
86+
Services: services,
87+
Deps: opts.deps,
88+
Memory: int64(opts.memory),
89+
Print: opts.print,
90+
Check: opts.check,
91+
SSHs: SSHKeys,
92+
Builder: builderName,
93+
Provenance: provenance,
8694
}, nil
8795
}
8896

@@ -123,6 +131,7 @@ func buildCommand(p *ProjectOptions, dockerCli command.Cli, backend api.Service)
123131
flags.StringVar(&opts.ssh, "ssh", "", "Set SSH authentications used when building service images. (use 'default' for using your default SSH Agent)")
124132
flags.StringVar(&opts.builder, "builder", "", "Set builder to use")
125133
flags.BoolVar(&opts.deps, "with-dependencies", false, "Also build dependencies (transitively)")
134+
flags.StringVar(&opts.provenance, "provenance", "max", "Set provenance mode (none|min|max)")
126135

127136
flags.Bool("parallel", true, "Build images in parallel. DEPRECATED")
128137
flags.MarkHidden("parallel") //nolint:errcheck

pkg/api/api.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,8 @@ type BuildOptions struct {
159159
Print bool
160160
// Check let builder validate build configuration
161161
Check bool
162+
// Provenance
163+
Provenance *string
162164
}
163165

164166
// Apply mutates project according to build options

pkg/compose/build.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,9 @@ func (s *composeService) toBuildOptions(project *types.Project, service types.Se
481481
return build.Options{}, err
482482
}
483483

484+
attests := map[string]*string{}
485+
attests["provenance"] = options.Provenance
486+
484487
return build.Options{
485488
Inputs: build.Inputs{
486489
ContextPath: service.Build.Context,
@@ -504,6 +507,7 @@ func (s *composeService) toBuildOptions(project *types.Project, service types.Se
504507
Session: sessionConfig,
505508
Allow: allow,
506509
SourcePolicy: sp,
510+
Attests: attests,
507511
}, nil
508512
}
509513

0 commit comments

Comments
 (0)