From 052ceee47e10a45f99876dae8dc1539ff76588fc Mon Sep 17 00:00:00 2001 From: Andrew Rynhard Date: Fri, 10 Feb 2017 12:29:35 -0800 Subject: [PATCH] Fix cluster-cidr flag --- cmd/kubeadm/app/phases/addons/BUILD | 8 +++++ cmd/kubeadm/app/phases/addons/addons.go | 2 +- cmd/kubeadm/app/phases/addons/addons_test.go | 31 ++++++++++++++++++++ 3 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 cmd/kubeadm/app/phases/addons/addons_test.go diff --git a/cmd/kubeadm/app/phases/addons/BUILD b/cmd/kubeadm/app/phases/addons/BUILD index 0600c3e52ac..fc0374787ef 100644 --- a/cmd/kubeadm/app/phases/addons/BUILD +++ b/cmd/kubeadm/app/phases/addons/BUILD @@ -5,6 +5,7 @@ licenses(["notice"]) load( "@io_bazel_rules_go//go:def.bzl", "go_library", + "go_test", ) go_library( @@ -39,3 +40,10 @@ filegroup( srcs = [":package-srcs"], tags = ["automanaged"], ) + +go_test( + name = "go_default_test", + srcs = ["addons_test.go"], + library = ":go_default_library", + tags = ["automanaged"], +) diff --git a/cmd/kubeadm/app/phases/addons/addons.go b/cmd/kubeadm/app/phases/addons/addons.go index 9c4ec4ddd16..6cb342c214c 100644 --- a/cmd/kubeadm/app/phases/addons/addons.go +++ b/cmd/kubeadm/app/phases/addons/addons.go @@ -158,5 +158,5 @@ func getClusterCIDR(podsubnet string) string { if len(podsubnet) == 0 { return "" } - return "--cluster-cidr" + podsubnet + return "- --cluster-cidr=" + podsubnet } diff --git a/cmd/kubeadm/app/phases/addons/addons_test.go b/cmd/kubeadm/app/phases/addons/addons_test.go new file mode 100644 index 00000000000..087bf00d9e7 --- /dev/null +++ b/cmd/kubeadm/app/phases/addons/addons_test.go @@ -0,0 +1,31 @@ +/* +Copyright 2017 The Kubernetes Authors. + +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. +*/ + +package addons + +import "testing" + +func TestGetClusterCIDR(t *testing.T) { + emptyClusterCIDR := getClusterCIDR("") + if emptyClusterCIDR != "" { + t.Errorf("Invalid format: %s", emptyClusterCIDR) + } + + clusterCIDR := getClusterCIDR("10.244.0.0/16") + if clusterCIDR != "- --cluster-cidr=10.244.0.0/16" { + t.Errorf("Invalid format: %s", clusterCIDR) + } +}