From 407fcd4e1fcc44c1947c50f3d990c0f1322e4ec0 Mon Sep 17 00:00:00 2001 From: iwilltry42 Date: Mon, 20 Apr 2020 17:22:56 +0200 Subject: [PATCH] rename to UpdateKubeConfig --- cmd/get/getKubeconfig.go | 3 +-- pkg/cluster/kubeconfig.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/cmd/get/getKubeconfig.go b/cmd/get/getKubeconfig.go index 93b49831..9333f135 100644 --- a/cmd/get/getKubeconfig.go +++ b/cmd/get/getKubeconfig.go @@ -37,12 +37,11 @@ func NewCmdGetKubeconfig() *cobra.Command { // create new command cmd := &cobra.Command{ - Use: "kubeconfig NAME", // TODO: getKubeconfig: allow more than one cluster name or even --all + Use: "kubeconfig CLUSTER", // TODO: getKubeconfig: allow more than one cluster name or even --all Short: "Get kubeconfig", Long: `Get kubeconfig.`, Args: cobra.MinimumNArgs(1), Run: func(cmd *cobra.Command, args []string) { - log.Debugln("get kubeconfig called") selectedClusters, path := parseGetKubeconfigCmd(cmd, args) kubeconfigpath, err := cluster.GetKubeconfigPath(runtimes.SelectedRuntime, selectedClusters, path) if err != nil { diff --git a/pkg/cluster/kubeconfig.go b/pkg/cluster/kubeconfig.go index 734db816..cdbd2bd1 100644 --- a/pkg/cluster/kubeconfig.go +++ b/pkg/cluster/kubeconfig.go @@ -37,6 +37,11 @@ import ( clientcmdapi "k8s.io/client-go/tools/clientcmd/api" ) +type WriteKubeConfigOptions struct { + UpdateExisting bool + ExistingKubeConfigPath string +} + // GetKubeconfig grabs the kubeconfig file from /output from a master node container, // modifies it by updating some fields with cluster-specific information // and returns a Config object for further processing @@ -190,11 +195,11 @@ func UpdateDefaultKubeConfig(newKubeConfig *clientcmdapi.Config) error { log.Errorln("Failed to load default kubeconfig") return err } - return MergeKubeConfig(newKubeConfig, existingKubeConfig, existingKubeConfigPath) + return UpdateKubeConfig(newKubeConfig, existingKubeConfig, existingKubeConfigPath) } -// MergeKubeConfig merges a new kubeconfig into the existing default kubeconfig -func MergeKubeConfig(newKubeConfig *clientcmdapi.Config, existingKubeConfig *clientcmdapi.Config, outPath string) error { +// UpdateKubeConfig merges a new kubeconfig into the existing default kubeconfig +func UpdateKubeConfig(newKubeConfig *clientcmdapi.Config, existingKubeConfig *clientcmdapi.Config, outPath string) error { log.Debugf("Merging new KubeConfig:\n%+v\n>>> into existing KubeConfig:\n%+v", newKubeConfig, existingKubeConfig)