Merge pull request #12194 from justinsb/warn_if_unknown_arch

Warn if KOPS_ARCH is not a recognized value
This commit is contained in:
Kubernetes Prow Robot 2021-08-23 08:34:00 -07:00 committed by GitHub
commit 11af87bf4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 5 deletions

View File

@ -5,4 +5,5 @@ go_library(
srcs = ["architectures.go"], srcs = ["architectures.go"],
importpath = "k8s.io/kops/util/pkg/architectures", importpath = "k8s.io/kops/util/pkg/architectures",
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
deps = ["//vendor/k8s.io/klog/v2:go_default_library"],
) )

View File

@ -20,6 +20,8 @@ import (
"fmt" "fmt"
"os" "os"
"runtime" "runtime"
"k8s.io/klog/v2"
) )
type Architecture string type Architecture string
@ -44,11 +46,15 @@ func GetSupported() []Architecture {
// Kubernetes PR builds only generate AMD64 binaries at the moment // Kubernetes PR builds only generate AMD64 binaries at the moment
// Force support only for AMD64 or ARM64 // Force support only for AMD64 or ARM64
arch := os.Getenv("KOPS_ARCH") arch := os.Getenv("KOPS_ARCH")
if arch != "" {
switch arch { switch arch {
case "amd64": case "amd64":
return []Architecture{ArchitectureAmd64} return []Architecture{ArchitectureAmd64}
case "arm64": case "arm64":
return []Architecture{ArchitectureArm64} return []Architecture{ArchitectureArm64}
default:
klog.Warningf("unknown architecture KOPS_ARCH=%q", arch)
}
} }
return []Architecture{ return []Architecture{