From 6832164372dbeeef71a5f004b35b5c76fb6712ce Mon Sep 17 00:00:00 2001 From: Alexander Hughes Date: Tue, 24 Mar 2020 08:19:41 -0400 Subject: [PATCH] Standardize KubeConfig variables Settings variable, function names, and comments inconsistently use either Kubeconfig, KubeconfigPath or KubeConfigPath capitalizations. This is a minor refactor to consistently use the KubeConfig capitalization variants. Relates-To: #124 Change-Id: Iaece6683931164ccaa213f4f3385de9c077d26b7 Signed-off-by: Alexander Hughes --- pkg/config/config.go | 6 +++--- pkg/config/types.go | 6 +++--- pkg/k8s/client/client.go | 2 +- pkg/k8s/kubectl/kubectl_test.go | 4 ++-- pkg/k8s/utils/utils.go | 2 +- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 46f49734a..ab3c2a0c5 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -445,7 +445,7 @@ func (c *Config) AddCluster(theCluster *ClusterOptions) (*Cluster, error) { // Create the new Airship config Cluster nCluster := NewCluster() c.Clusters[theCluster.Name].ClusterTypes[theCluster.ClusterType] = nCluster - // Create a new Kubeconfig Cluster object as well + // Create a new KubeConfig Cluster object as well kcluster := clientcmdapi.NewCluster() clusterName := NewClusterComplexName() clusterName.WithType(theCluster.Name, theCluster.ClusterType) @@ -554,7 +554,7 @@ func (c *Config) AddContext(theContext *ContextOptions) *Context { // Create the new Airship config context nContext := NewContext() c.Contexts[theContext.Name] = nContext - // Create a new Kubeconfig Context object as well + // Create a new KubeConfig Context object as well context := clientcmdapi.NewContext() nContext.NameInKubeconf = theContext.Name contextName := NewClusterComplexName() @@ -685,7 +685,7 @@ func (c *Config) AddAuthInfo(theAuthInfo *AuthInfoOptions) *AuthInfo { // Create the new Airship config context nAuthInfo := NewAuthInfo() c.AuthInfos[theAuthInfo.Name] = nAuthInfo - // Create a new Kubeconfig AuthInfo object as well + // Create a new KubeConfig AuthInfo object as well authInfo := clientcmdapi.NewAuthInfo() nAuthInfo.SetKubeAuthInfo(authInfo) c.KubeConfig().AuthInfos[theAuthInfo.Name] = authInfo diff --git a/pkg/config/types.go b/pkg/config/types.go index c61296321..0b3990259 100644 --- a/pkg/config/types.go +++ b/pkg/config/types.go @@ -79,7 +79,7 @@ type Cluster struct { // Complex cluster name defined by the using _) NameInKubeconf string `json:"cluster-kubeconf"` - // Kubeconfig Cluster Object + // KubeConfig Cluster Object cluster *kubeconfig.Cluster // Bootstrap configuration this clusters ephemeral hosts will rely on @@ -104,12 +104,12 @@ type Context struct { // +optional Manifest string `json:"manifest,omitempty"` - // Kubeconfig Context Object + // KubeConfig Context Object context *kubeconfig.Context } type AuthInfo struct { - // Kubeconfig AuthInfo Object + // KubeConfig AuthInfo Object authInfo *kubeconfig.AuthInfo } diff --git a/pkg/k8s/client/client.go b/pkg/k8s/client/client.go index 4d758483b..b6b580fae 100644 --- a/pkg/k8s/client/client.go +++ b/pkg/k8s/client/client.go @@ -46,7 +46,7 @@ func NewClient(settings *environment.AirshipCTLSettings) (Interface, error) { client := new(Client) var err error - f := k8sutils.FactoryFromKubeconfigPath(settings.KubeConfigPath()) + f := k8sutils.FactoryFromKubeConfigPath(settings.KubeConfigPath()) pathToBufferDir := filepath.Join(filepath.Dir(settings.AirshipConfigPath()), buffDir) client.kubectl = kubectl.NewKubectl(f).WithBufferDir(pathToBufferDir) diff --git a/pkg/k8s/kubectl/kubectl_test.go b/pkg/k8s/kubectl/kubectl_test.go index 8e5b761d5..2dfdca1d5 100644 --- a/pkg/k8s/kubectl/kubectl_test.go +++ b/pkg/k8s/kubectl/kubectl_test.go @@ -44,8 +44,8 @@ func (f TestFile) Name() string { return f.MockName() } func (f TestFile) Write([]byte) (int, error) { return f.MockWrite() } func (f TestFile) Close() error { return f.MockClose() } -func TestNewKubectlFromKubeconfigPath(t *testing.T) { - f := k8sutils.FactoryFromKubeconfigPath(kubeconfigPath) +func TestNewKubectlFromKubeConfigPath(t *testing.T) { + f := k8sutils.FactoryFromKubeConfigPath(kubeconfigPath) kctl := kubectl.NewKubectl(f).WithBufferDir("/tmp/.airship") assert.NotNil(t, kctl.Factory) diff --git a/pkg/k8s/utils/utils.go b/pkg/k8s/utils/utils.go index 2977eede9..207d462f0 100644 --- a/pkg/k8s/utils/utils.go +++ b/pkg/k8s/utils/utils.go @@ -5,7 +5,7 @@ import ( cmdutil "k8s.io/kubectl/pkg/cmd/util" ) -func FactoryFromKubeconfigPath(kp string) cmdutil.Factory { +func FactoryFromKubeConfigPath(kp string) cmdutil.Factory { kf := genericclioptions.NewConfigFlags(false) kf.KubeConfig = &kp return cmdutil.NewFactory(kf)