Skip to content

Commit

Permalink
pkg/imagebuilder: expose BuiltInBuildArgs for downstream
Browse files Browse the repository at this point in the history
Expose map BuiltInBuildArgs so downstream users like buildah can use it.

Signed-off-by: Aditya R <[email protected]>
  • Loading branch information
flouthoc committed Jun 16, 2023
1 parent bf1ff5c commit ac04851
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions dispatchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ var (
var localspec = platforms.DefaultSpec()

// https://docs.docker.com/engine/reference/builder/#automatic-platform-args-in-the-global-scope
var builtinBuildArgs = map[string]string{
var BuiltInBuildArgs = map[string]string{
"TARGETPLATFORM": localspec.OS + "/" + localspec.Architecture,
"TARGETOS": localspec.OS,
"TARGETARCH": localspec.Architecture,
Expand All @@ -44,8 +44,8 @@ var builtinBuildArgs = map[string]string{

func init() {
if localspec.Variant != "" {
builtinBuildArgs["TARGETPLATFORM"] = builtinBuildArgs["TARGETPLATFORM"] + "/" + localspec.Variant
builtinBuildArgs["BUILDPLATFORM"] = builtinBuildArgs["BUILDPLATFORM"] + "/" + localspec.Variant
BuiltInBuildArgs["TARGETPLATFORM"] = BuiltInBuildArgs["TARGETPLATFORM"] + "/" + localspec.Variant
BuiltInBuildArgs["BUILDPLATFORM"] = BuiltInBuildArgs["BUILDPLATFORM"] + "/" + localspec.Variant
}
}

Expand Down Expand Up @@ -224,7 +224,7 @@ func from(b *Builder, args []string, attributes map[string]bool, flagArgs []stri
for n, v := range b.HeadingArgs {
argStrs = append(argStrs, n+"="+v)
}
defaultArgs := envMapAsSlice(builtinBuildArgs)
defaultArgs := envMapAsSlice(BuiltInBuildArgs)
filteredUserArgs := make(map[string]string)
for k, v := range b.UserArgs {
for _, a := range b.GlobalAllowedArgs {
Expand Down Expand Up @@ -634,7 +634,7 @@ func arg(b *Builder, args []string, attributes map[string]bool, flagArgs []strin
b.Args["TARGETPLATFORM"] = b.Args["TARGETPLATFORM"] + "/" + p.Variant
}
}
} else if val, ok := builtinBuildArgs[arg]; ok {
} else if val, ok := BuiltInBuildArgs[arg]; ok {
name = arg
value = val
hasDefault = true
Expand Down

0 comments on commit ac04851

Please sign in to comment.