rename to UpdateKubeConfig

This commit is contained in:
iwilltry42 2020-04-20 17:22:56 +02:00
parent fc1b858325
commit 407fcd4e1f
No known key found for this signature in database
GPG Key ID: 7BA57AD1CFF16110
2 changed files with 9 additions and 5 deletions

View File

@ -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 {

View File

@ -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)