Skip to content

Commit

Permalink
Propagate SOURCE_DATE_EPOCH from the client env
Browse files Browse the repository at this point in the history
Signed-off-by: Akihiro Suda <[email protected]>
  • Loading branch information
AkihiroSuda committed Dec 21, 2022
1 parent 88852e2 commit e1ae109
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions bake/bake.go
Original file line number Diff line number Diff line change
Expand Up @@ -896,6 +896,14 @@ func toBuildOpt(t *Target, inp *Input) (*build.Options, error) {
args[k] = *v
}

// Propagate SOURCE_DATE_EPOCH from the client env.
// The logic is purposely duplicated from `build/build`.go for keeping this visible in `bake --print`.
if v, ok := os.LookupEnv("SOURCE_DATE_EPOCH"); ok {
if _, ok2 := args["SOURCE_DATE_EPOCH"]; !ok2 {
args["SOURCE_DATE_EPOCH"] = v
}
}

labels := map[string]string{}
for k, v := range t.Labels {
if v == nil {
Expand Down
7 changes: 7 additions & 0 deletions build/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,13 @@ func toSolveOpt(ctx context.Context, node builder.Node, multiDriver bool, opt Op
}
}

// Propagate SOURCE_DATE_EPOCH from the client env
if v, ok := os.LookupEnv("SOURCE_DATE_EPOCH"); ok {
if _, ok2 := so.FrontendAttrs["build-arg:SOURCE_DATE_EPOCH"]; !ok2 {
so.FrontendAttrs["build-arg:SOURCE_DATE_EPOCH"] = v
}
}

if len(opt.Attests) > 0 {
if !bopts.LLBCaps.Contains(apicaps.CapID("exporter.image.attestations")) {
return nil, nil, errors.Errorf("attestations are not supported by the current buildkitd")
Expand Down

0 comments on commit e1ae109

Please sign in to comment.