mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-05-20 10:27:46 +08:00
Merge pull request #1675 from jedevc/source-date-epoch-fixes
SOURCE_DATE_EPOCH build arg injection fixes
This commit is contained in:
commit
fd8eaab2df
13
bake/bake.go
13
bake/bake.go
@ -140,19 +140,6 @@ 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 f.Args == nil {
|
|
||||||
f.Args = make(map[string]*string)
|
|
||||||
}
|
|
||||||
if _, ok := f.Args["SOURCE_DATE_EPOCH"]; !ok {
|
|
||||||
f.Args["SOURCE_DATE_EPOCH"] = &v
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return m, n, nil
|
return m, n, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -604,13 +604,6 @@ 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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// set platforms
|
// set platforms
|
||||||
if len(opt.Platforms) != 0 {
|
if len(opt.Platforms) != 0 {
|
||||||
pp := make([]string, len(opt.Platforms))
|
pp := make([]string, len(opt.Platforms))
|
||||||
|
@ -149,6 +149,19 @@ func runBake(dockerCli command.Cli, targets []string, in bakeOptions, cFlags com
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if v := os.Getenv("SOURCE_DATE_EPOCH"); v != "" {
|
||||||
|
// TODO: extract env var parsing to a method easily usable by library consumers
|
||||||
|
for _, t := range tgts {
|
||||||
|
if _, ok := t.Args["SOURCE_DATE_EPOCH"]; ok {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if t.Args == nil {
|
||||||
|
t.Args = map[string]*string{}
|
||||||
|
}
|
||||||
|
t.Args["SOURCE_DATE_EPOCH"] = &v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// this function can update target context string from the input so call before printOnly check
|
// this function can update target context string from the input so call before printOnly check
|
||||||
bo, err := bake.TargetsToBuildOpt(tgts, inp)
|
bo, err := bake.TargetsToBuildOpt(tgts, inp)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -100,6 +100,13 @@ func (o *buildOptions) toControllerOptions() (controllerapi.BuildOptions, error)
|
|||||||
Opts: &o.CommonOptions,
|
Opts: &o.CommonOptions,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: extract env var parsing to a method easily usable by library consumers
|
||||||
|
if v := os.Getenv("SOURCE_DATE_EPOCH"); v != "" {
|
||||||
|
if _, ok := opts.BuildArgs["SOURCE_DATE_EPOCH"]; !ok {
|
||||||
|
opts.BuildArgs["SOURCE_DATE_EPOCH"] = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
inAttests := append([]string{}, o.attests...)
|
inAttests := append([]string{}, o.attests...)
|
||||||
if o.provenance != "" {
|
if o.provenance != "" {
|
||||||
inAttests = append(inAttests, buildflags.CanonicalizeAttest("provenance", o.provenance))
|
inAttests = append(inAttests, buildflags.CanonicalizeAttest("provenance", o.provenance))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user