Skip to content

Commit

Permalink
Merge pull request #1482 from AkihiroSuda/auto-propagate-source-date-…
Browse files Browse the repository at this point in the history
…epoch

Propagate SOURCE_DATE_EPOCH from the client env
  • Loading branch information
tonistiigi committed Dec 28, 2022
2 parents 88852e2 + 0e6f5a1 commit 287aaf1
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions bake/bake.go
Expand Up @@ -140,6 +140,16 @@ func ReadTargets(ctx context.Context, files []File, targets, overrides []string,
}
}

// 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 := os.Getenv("SOURCE_DATE_EPOCH"); v != "" {
for _, f := range m {
if _, ok := f.Args["SOURCE_DATE_EPOCH"]; !ok {
f.Args["SOURCE_DATE_EPOCH"] = &v
}
}
}

return m, n, nil
}

Expand Down
7 changes: 7 additions & 0 deletions build/build.go
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 := os.Getenv("SOURCE_DATE_EPOCH"); v != "" {
if _, ok := so.FrontendAttrs["build-arg:SOURCE_DATE_EPOCH"]; !ok {
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 287aaf1

Please sign in to comment.