From c2914ccba78af10b1943e749e5f1e91fbce474bf Mon Sep 17 00:00:00 2001 From: justinsb Date: Mon, 23 Aug 2021 08:38:29 -0400 Subject: [PATCH] Warn if KOPS_ARCH is not a recognized value Otherwise we were silently rejecting it. --- util/pkg/architectures/BUILD.bazel | 1 + util/pkg/architectures/architectures.go | 16 +++++++++++----- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/util/pkg/architectures/BUILD.bazel b/util/pkg/architectures/BUILD.bazel index e9fc7d9848c9f..7654a292751ec 100644 --- a/util/pkg/architectures/BUILD.bazel +++ b/util/pkg/architectures/BUILD.bazel @@ -5,4 +5,5 @@ go_library( srcs = ["architectures.go"], importpath = "k8s.io/kops/util/pkg/architectures", visibility = ["//visibility:public"], + deps = ["//vendor/k8s.io/klog/v2:go_default_library"], ) diff --git a/util/pkg/architectures/architectures.go b/util/pkg/architectures/architectures.go index 7ab4de11248b2..b4016ce45046e 100644 --- a/util/pkg/architectures/architectures.go +++ b/util/pkg/architectures/architectures.go @@ -20,6 +20,8 @@ import ( "fmt" "os" "runtime" + + "k8s.io/klog/v2" ) type Architecture string @@ -44,11 +46,15 @@ func GetSupported() []Architecture { // Kubernetes PR builds only generate AMD64 binaries at the moment // Force support only for AMD64 or ARM64 arch := os.Getenv("KOPS_ARCH") - switch arch { - case "amd64": - return []Architecture{ArchitectureAmd64} - case "arm64": - return []Architecture{ArchitectureArm64} + if arch != "" { + switch arch { + case "amd64": + return []Architecture{ArchitectureAmd64} + case "arm64": + return []Architecture{ArchitectureArm64} + default: + klog.Warningf("unknown architecture KOPS_ARCH=%q", arch) + } } return []Architecture{