-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support setting `platform` for dependencies and also allow overriding `platform` for a specific package. Signed-off-by: Noel Georgi <[email protected]>
- Loading branch information
Showing
13 changed files
with
130 additions
and
41 deletions.
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# syntax = SHEBANG | ||
|
||
format: v1alpha2 |
9 changes: 9 additions & 0 deletions
9
internal/pkg/integration/testdata/platform-override/final/pkg.yaml
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,9 @@ | ||
--- | ||
name: final | ||
platform: linux/arm64 | ||
steps: | ||
- test: | ||
- test `uname -m` = "aarch64" | ||
finalize: | ||
- from: / | ||
to: / |
17 changes: 17 additions & 0 deletions
17
internal/pkg/integration/testdata/platform-override/test.yaml
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 @@ | ||
--- | ||
run: | ||
- name: docker-amd64 | ||
runner: docker | ||
platform: linux/amd64 | ||
target: final | ||
expect: success | ||
- name: llb-amd64 | ||
runner: llb | ||
platform: linux/amd64 | ||
target: final | ||
expect: success | ||
- name: buildkit-amd64 | ||
runner: buildkit | ||
platform: linux/amd64 | ||
target: final | ||
expect: success |
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,34 @@ | ||
// This Source Code Form is subject to the terms of the Mozilla Public | ||
// License, v. 2.0. If a copy of the MPL was not distributed with this | ||
// file, You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
// Package platform provides a function to convert a platform string to a v1.Platform. | ||
package platform | ||
|
||
import ( | ||
"fmt" | ||
|
||
v1 "github.com/opencontainers/image-spec/specs-go/v1" | ||
) | ||
|
||
// ToV1Platform converts a platform string to a v1.Platform. | ||
func ToV1Platform(platform, targetPlatform string) (v1.Platform, error) { | ||
if platform == "" { | ||
platform = targetPlatform | ||
} | ||
|
||
switch platform { | ||
case "linux/amd64": | ||
return v1.Platform{ | ||
OS: "linux", | ||
Architecture: "amd64", | ||
}, nil | ||
case "linux/arm64": | ||
return v1.Platform{ | ||
OS: "linux", | ||
Architecture: "arm64", | ||
}, nil | ||
default: | ||
return v1.Platform{}, fmt.Errorf("unknown platform %q", platform) | ||
} | ||
} |
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