diff --git a/cmd/minikube/cmd/start.go b/cmd/minikube/cmd/start.go index 75712ac641..df2ccfe02c 100644 --- a/cmd/minikube/cmd/start.go +++ b/cmd/minikube/cmd/start.go @@ -401,7 +401,7 @@ func showVersionInfo(k8sVersion string, cr cruntime.Manager) { } } -func showKubectlConnectInfo(kubeconfig *kubeconfig.KubeConfigSetup) { +func showKubectlConnectInfo(kubeconfig *kubeconfig.Setup) { if kubeconfig.KeepContext { out.T(out.Kubectl, "To connect to this cluster, use: kubectl --context={{.name}}", out.V{"name": kubeconfig.ClusterName}) } else { diff --git a/pkg/minikube/bootstrapper/certs.go b/pkg/minikube/bootstrapper/certs.go index 68542d3770..29f768cbc8 100644 --- a/pkg/minikube/bootstrapper/certs.go +++ b/pkg/minikube/bootstrapper/certs.go @@ -67,7 +67,7 @@ func SetupCerts(cmd command.Runner, k8s config.KubernetesConfig) error { copyableFiles = append(copyableFiles, certFile) } - kubeCfgSetup := &kubeconfig.KubeConfigSetup{ + kubeCfgSetup := &kubeconfig.Setup{ ClusterName: k8s.NodeName, ClusterServerAddress: fmt.Sprintf("https://localhost:%d", k8s.NodePort), ClientCertificate: path.Join(util.DefaultCertPath, "apiserver.crt"), diff --git a/pkg/minikube/kubeconfig/kubeconfig.go b/pkg/minikube/kubeconfig/kubeconfig.go index bf1962846c..3e3900b887 100644 --- a/pkg/minikube/kubeconfig/kubeconfig.go +++ b/pkg/minikube/kubeconfig/kubeconfig.go @@ -35,8 +35,8 @@ import ( pkgutil "k8s.io/minikube/pkg/util" ) -// KubeConfigSetup is the kubeconfig setup -type KubeConfigSetup struct { +// Setup is the kubeconfig setup +type Setup struct { // The name of the cluster for this context ClusterName string @@ -64,17 +64,17 @@ type KubeConfigSetup struct { } // SetKubeConfigFile sets the kubeconfig file -func (k *KubeConfigSetup) SetKubeConfigFile(kubeConfigFile string) { +func (k *Setup) SetKubeConfigFile(kubeConfigFile string) { k.kubeConfigFile.Store(kubeConfigFile) } // GetKubeConfigFile gets the kubeconfig file -func (k *KubeConfigSetup) GetKubeConfigFile() string { +func (k *Setup) GetKubeConfigFile() string { return k.kubeConfigFile.Load().(string) } // PopulateKubeConfig populates an api.Config object. -func PopulateKubeConfig(cfg *KubeConfigSetup, kubecfg *api.Config) error { +func PopulateKubeConfig(cfg *Setup, kubecfg *api.Config) error { var err error clusterName := cfg.ClusterName cluster := api.NewCluster() @@ -125,7 +125,7 @@ func PopulateKubeConfig(cfg *KubeConfigSetup, kubecfg *api.Config) error { // SetupKubeConfig reads config from disk, adds the minikube settings, and writes it back. // activeContext is true when minikube is the CurrentContext // If no CurrentContext is set, the given name will be used. -func SetupKubeConfig(cfg *KubeConfigSetup) error { +func SetupKubeConfig(cfg *Setup) error { glog.Infoln("Using kubeconfig: ", cfg.GetKubeConfigFile()) // read existing config or create new if does not exist diff --git a/pkg/minikube/kubeconfig/kubeconfig_test.go b/pkg/minikube/kubeconfig/kubeconfig_test.go index 5bc641b518..7c580f4233 100644 --- a/pkg/minikube/kubeconfig/kubeconfig_test.go +++ b/pkg/minikube/kubeconfig/kubeconfig_test.go @@ -25,7 +25,7 @@ import ( "testing" "k8s.io/client-go/tools/clientcmd/api" - "k8s.io/minikube/pkg/minikube/bootstrapper/kubeadm" + "k8s.io/minikube/pkg/minikube/constants" "k8s.io/client-go/tools/clientcmd" ) @@ -97,7 +97,7 @@ users: `) func TestSetupKubeConfig(t *testing.T) { - setupCfg := &KubeConfigSetup{ + setupCfg := &Setup{ ClusterName: "test", ClusterServerAddress: "192.168.1.1:8080", ClientCertificate: "/home/apiserver.crt", @@ -108,7 +108,7 @@ func TestSetupKubeConfig(t *testing.T) { var tests = []struct { description string - cfg *KubeConfigSetup + cfg *Setup existingCfg []byte expected api.Config err bool @@ -128,7 +128,7 @@ func TestSetupKubeConfig(t *testing.T) { }, { description: "keep context", - cfg: &KubeConfigSetup{ + cfg: &Setup{ ClusterName: "test", ClusterServerAddress: "192.168.1.1:8080", ClientCertificate: "/home/apiserver.crt", @@ -524,7 +524,7 @@ func minikubeConfig(config *api.Config) { // cluster clusterName := "minikube" cluster := api.NewCluster() - cluster.Server = "https://192.168.99.100:" + strconv.Itoa(kubeadm.APIServerPort) + cluster.Server = "https://192.168.99.100:" + strconv.Itoa(constants.APIServerPort) cluster.CertificateAuthority = "/home/tux/.minikube/apiserver.crt" config.Clusters[clusterName] = cluster diff --git a/pkg/minikube/kubeconfig/update.go b/pkg/minikube/kubeconfig/update.go index 73f4850d16..c1b75a4886 100644 --- a/pkg/minikube/kubeconfig/update.go +++ b/pkg/minikube/kubeconfig/update.go @@ -28,7 +28,7 @@ import ( ) // Update sets up kubeconfig to be used by kubectl -func Update(h *host.Host, c *cfg.Config) *KubeConfigSetup { +func Update(h *host.Host, c *cfg.Config) *Setup { addr, err := h.Driver.GetURL() if err != nil { exit.WithError("Failed to get driver URL", err) @@ -39,7 +39,7 @@ func Update(h *host.Host, c *cfg.Config) *KubeConfigSetup { addr = strings.Replace(addr, c.KubernetesConfig.NodeIP, c.KubernetesConfig.APIServerName, -1) } - kcs := &KubeConfigSetup{ + kcs := &Setup{ ClusterName: cfg.GetMachineName(), ClusterServerAddress: addr, ClientCertificate: constants.MakeMiniPath("client.crt"),