platforms: provide simpler function for common use
Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
@@ -6,8 +6,13 @@ import (
|
||||
specs "github.com/opencontainers/image-spec/specs-go/v1"
|
||||
)
|
||||
|
||||
// Default returns the current platform's default platform specification.
|
||||
func Default() specs.Platform {
|
||||
// Default returns the default specifier for the platform.
|
||||
func Default() string {
|
||||
return Format(DefaultSpec())
|
||||
}
|
||||
|
||||
// DefaultSpec returns the current platform's default platform specification.
|
||||
func DefaultSpec() specs.Platform {
|
||||
return specs.Platform{
|
||||
OS: runtime.GOOS,
|
||||
Architecture: runtime.GOARCH,
|
||||
|
||||
@@ -13,8 +13,13 @@ func TestDefault(t *testing.T) {
|
||||
OS: runtime.GOOS,
|
||||
Architecture: runtime.GOARCH,
|
||||
}
|
||||
p := Default()
|
||||
p := DefaultSpec()
|
||||
if !reflect.DeepEqual(p, expected) {
|
||||
t.Fatalf("default platform not as expected: %#v != %#v", p, expected)
|
||||
}
|
||||
|
||||
s := Default()
|
||||
if s != Format(p) {
|
||||
t.Fatalf("default specifier should match formatted default spec: %v != %v", s, p)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user