-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2086 from jjbustamante/jjbustamante/poc-multiarch…
…-rfc Implementation of the multi-platform support for builders and buildpack packages RFC 0128
- Loading branch information
Showing
76 changed files
with
2,350 additions
and
188 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
acceptance/testdata/mock_buildpacks/multi-platform-buildpack/buildpack.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
api = "0.10" | ||
|
||
[buildpack] | ||
id = "simple/layers" | ||
version = "simple-layers-version" | ||
name = "Simple Layers Buildpack" | ||
|
||
[[targets]] | ||
os = "linux" | ||
arch = "amd64" | ||
|
||
[[targets]] | ||
os = "windows" | ||
arch = "amd64" | ||
|
||
[[stacks]] | ||
id = "*" |
3 changes: 3 additions & 0 deletions
3
acceptance/testdata/mock_buildpacks/multi-platform-buildpack/linux/amd64/bin/build
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
echo "---> Build: NOOP Buildpack" |
3 changes: 3 additions & 0 deletions
3
acceptance/testdata/mock_buildpacks/multi-platform-buildpack/linux/amd64/bin/detect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/usr/bin/env bash | ||
|
||
## always detect |
3 changes: 3 additions & 0 deletions
3
acceptance/testdata/mock_buildpacks/multi-platform-buildpack/windows/amd64/bin/build.bat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
@echo off | ||
|
||
echo ---- Build: NOOP Buildpack |
2 changes: 2 additions & 0 deletions
2
acceptance/testdata/mock_buildpacks/multi-platform-buildpack/windows/amd64/bin/detect.bat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
@echo off | ||
:: always detect |
19 changes: 19 additions & 0 deletions
19
acceptance/testdata/pack_fixtures/builder_multi_platform-no-targets.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[[buildpacks]] | ||
id = "simple/layers" | ||
version = "simple-layers-version" | ||
uri = "{{ .BuildpackURI }}" | ||
|
||
[[order]] | ||
[[order.group]] | ||
id = "simple/layers" | ||
version = "simple-layers-version" | ||
|
||
[build] | ||
image = "{{ .BuildImage }}" | ||
|
||
[run] | ||
[[run.images]] | ||
image = "{{ .RunImage }}" | ||
|
||
|
||
|
28 changes: 28 additions & 0 deletions
28
acceptance/testdata/pack_fixtures/builder_multi_platform.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
[[buildpacks]] | ||
id = "simple/layers" | ||
version = "simple-layers-version" | ||
uri = "{{ .BuildpackURI }}" | ||
|
||
[[order]] | ||
[[order.group]] | ||
id = "simple/layers" | ||
version = "simple-layers-version" | ||
|
||
# Targets the buildpack will work with | ||
[[targets]] | ||
os = "linux" | ||
arch = "amd64" | ||
|
||
[[targets]] | ||
os = "windows" | ||
arch = "amd64" | ||
|
||
[build] | ||
image = "{{ .BuildImage }}" | ||
|
||
[run] | ||
[[run.images]] | ||
image = "{{ .RunImage }}" | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ uri = "{{ .BuildpackURI }}" | |
image = "{{ .PackageName }}" | ||
|
||
[platform] | ||
os = "{{ .OS }}" | ||
os = "{{ .OS }}" |
5 changes: 5 additions & 0 deletions
5
acceptance/testdata/pack_fixtures/package_multi_platform.toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[buildpack] | ||
uri = "{{ .BuildpackURI }}" | ||
|
||
[[dependencies]] | ||
uri = "{{ .PackageName }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ type BuilderCreateFlags struct { | |
Registry string | ||
Policy string | ||
Flatten []string | ||
Targets []string | ||
Label map[string]string | ||
} | ||
|
||
|
@@ -87,6 +88,15 @@ Creating a custom builder allows you to control what buildpacks are used and wha | |
return err | ||
} | ||
|
||
multiArchCfg, err := processMultiArchitectureConfig(logger, flags.Targets, builderConfig.Targets, !flags.Publish) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
if len(multiArchCfg.Targets()) == 0 { | ||
logger.Infof("Pro tip: use --targets flag OR [[targets]] in builder.toml to specify the desired platform") | ||
} | ||
|
||
imageName := args[0] | ||
if err := pack.CreateBuilder(cmd.Context(), client.CreateBuilderOptions{ | ||
RelativeBaseDir: relativeBaseDir, | ||
|
@@ -98,6 +108,7 @@ Creating a custom builder allows you to control what buildpacks are used and wha | |
PullPolicy: pullPolicy, | ||
Flatten: toFlatten, | ||
Labels: flags.Label, | ||
Targets: multiArchCfg.Targets(), | ||
}); err != nil { | ||
return err | ||
} | ||
|
@@ -116,6 +127,12 @@ Creating a custom builder allows you to control what buildpacks are used and wha | |
cmd.Flags().StringVar(&flags.Policy, "pull-policy", "", "Pull policy to use. Accepted values are always, never, and if-not-present. The default is always") | ||
cmd.Flags().StringArrayVar(&flags.Flatten, "flatten", nil, "List of buildpacks to flatten together into a single layer (format: '<buildpack-id>@<buildpack-version>,<buildpack-id>@<buildpack-version>'") | ||
cmd.Flags().StringToStringVarP(&flags.Label, "label", "l", nil, "Labels to add to the builder image, in the form of '<name>=<value>'") | ||
cmd.Flags().StringSliceVarP(&flags.Targets, "target", "t", nil, | ||
`Target platforms to build for.\nTargets should be in the format '[os][/arch][/variant]:[distroname@osversion@anotherversion];[distroname@osversion]'. | ||
- To specify two different architectures: '--target "linux/amd64" --target "linux/arm64"' | ||
- To specify the distribution version: '--target "linux/arm/v6:[email protected]"' | ||
- To specify multiple distribution versions: '--target "linux/arm/v6:[email protected]" --target "linux/arm/v6:[email protected]"' | ||
`) | ||
|
||
AddHelpFlag(cmd, "create") | ||
return cmd | ||
|
Oops, something went wrong.