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 <Alexander.Hughes@pm.me>
This commit is contained in:
parent
ea9fba7278
commit
6832164372
@ -445,7 +445,7 @@ func (c *Config) AddCluster(theCluster *ClusterOptions) (*Cluster, error) {
|
|||||||
// Create the new Airship config Cluster
|
// Create the new Airship config Cluster
|
||||||
nCluster := NewCluster()
|
nCluster := NewCluster()
|
||||||
c.Clusters[theCluster.Name].ClusterTypes[theCluster.ClusterType] = nCluster
|
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()
|
kcluster := clientcmdapi.NewCluster()
|
||||||
clusterName := NewClusterComplexName()
|
clusterName := NewClusterComplexName()
|
||||||
clusterName.WithType(theCluster.Name, theCluster.ClusterType)
|
clusterName.WithType(theCluster.Name, theCluster.ClusterType)
|
||||||
@ -554,7 +554,7 @@ func (c *Config) AddContext(theContext *ContextOptions) *Context {
|
|||||||
// Create the new Airship config context
|
// Create the new Airship config context
|
||||||
nContext := NewContext()
|
nContext := NewContext()
|
||||||
c.Contexts[theContext.Name] = nContext
|
c.Contexts[theContext.Name] = nContext
|
||||||
// Create a new Kubeconfig Context object as well
|
// Create a new KubeConfig Context object as well
|
||||||
context := clientcmdapi.NewContext()
|
context := clientcmdapi.NewContext()
|
||||||
nContext.NameInKubeconf = theContext.Name
|
nContext.NameInKubeconf = theContext.Name
|
||||||
contextName := NewClusterComplexName()
|
contextName := NewClusterComplexName()
|
||||||
@ -685,7 +685,7 @@ func (c *Config) AddAuthInfo(theAuthInfo *AuthInfoOptions) *AuthInfo {
|
|||||||
// Create the new Airship config context
|
// Create the new Airship config context
|
||||||
nAuthInfo := NewAuthInfo()
|
nAuthInfo := NewAuthInfo()
|
||||||
c.AuthInfos[theAuthInfo.Name] = nAuthInfo
|
c.AuthInfos[theAuthInfo.Name] = nAuthInfo
|
||||||
// Create a new Kubeconfig AuthInfo object as well
|
// Create a new KubeConfig AuthInfo object as well
|
||||||
authInfo := clientcmdapi.NewAuthInfo()
|
authInfo := clientcmdapi.NewAuthInfo()
|
||||||
nAuthInfo.SetKubeAuthInfo(authInfo)
|
nAuthInfo.SetKubeAuthInfo(authInfo)
|
||||||
c.KubeConfig().AuthInfos[theAuthInfo.Name] = authInfo
|
c.KubeConfig().AuthInfos[theAuthInfo.Name] = authInfo
|
||||||
|
@ -79,7 +79,7 @@ type Cluster struct {
|
|||||||
// Complex cluster name defined by the using <cluster name>_<cluster type>)
|
// Complex cluster name defined by the using <cluster name>_<cluster type>)
|
||||||
NameInKubeconf string `json:"cluster-kubeconf"`
|
NameInKubeconf string `json:"cluster-kubeconf"`
|
||||||
|
|
||||||
// Kubeconfig Cluster Object
|
// KubeConfig Cluster Object
|
||||||
cluster *kubeconfig.Cluster
|
cluster *kubeconfig.Cluster
|
||||||
|
|
||||||
// Bootstrap configuration this clusters ephemeral hosts will rely on
|
// Bootstrap configuration this clusters ephemeral hosts will rely on
|
||||||
@ -104,12 +104,12 @@ type Context struct {
|
|||||||
// +optional
|
// +optional
|
||||||
Manifest string `json:"manifest,omitempty"`
|
Manifest string `json:"manifest,omitempty"`
|
||||||
|
|
||||||
// Kubeconfig Context Object
|
// KubeConfig Context Object
|
||||||
context *kubeconfig.Context
|
context *kubeconfig.Context
|
||||||
}
|
}
|
||||||
|
|
||||||
type AuthInfo struct {
|
type AuthInfo struct {
|
||||||
// Kubeconfig AuthInfo Object
|
// KubeConfig AuthInfo Object
|
||||||
authInfo *kubeconfig.AuthInfo
|
authInfo *kubeconfig.AuthInfo
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ func NewClient(settings *environment.AirshipCTLSettings) (Interface, error) {
|
|||||||
client := new(Client)
|
client := new(Client)
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
f := k8sutils.FactoryFromKubeconfigPath(settings.KubeConfigPath())
|
f := k8sutils.FactoryFromKubeConfigPath(settings.KubeConfigPath())
|
||||||
|
|
||||||
pathToBufferDir := filepath.Join(filepath.Dir(settings.AirshipConfigPath()), buffDir)
|
pathToBufferDir := filepath.Join(filepath.Dir(settings.AirshipConfigPath()), buffDir)
|
||||||
client.kubectl = kubectl.NewKubectl(f).WithBufferDir(pathToBufferDir)
|
client.kubectl = kubectl.NewKubectl(f).WithBufferDir(pathToBufferDir)
|
||||||
|
@ -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) Write([]byte) (int, error) { return f.MockWrite() }
|
||||||
func (f TestFile) Close() error { return f.MockClose() }
|
func (f TestFile) Close() error { return f.MockClose() }
|
||||||
|
|
||||||
func TestNewKubectlFromKubeconfigPath(t *testing.T) {
|
func TestNewKubectlFromKubeConfigPath(t *testing.T) {
|
||||||
f := k8sutils.FactoryFromKubeconfigPath(kubeconfigPath)
|
f := k8sutils.FactoryFromKubeConfigPath(kubeconfigPath)
|
||||||
kctl := kubectl.NewKubectl(f).WithBufferDir("/tmp/.airship")
|
kctl := kubectl.NewKubectl(f).WithBufferDir("/tmp/.airship")
|
||||||
|
|
||||||
assert.NotNil(t, kctl.Factory)
|
assert.NotNil(t, kctl.Factory)
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
cmdutil "k8s.io/kubectl/pkg/cmd/util"
|
||||||
)
|
)
|
||||||
|
|
||||||
func FactoryFromKubeconfigPath(kp string) cmdutil.Factory {
|
func FactoryFromKubeConfigPath(kp string) cmdutil.Factory {
|
||||||
kf := genericclioptions.NewConfigFlags(false)
|
kf := genericclioptions.NewConfigFlags(false)
|
||||||
kf.KubeConfig = &kp
|
kf.KubeConfig = &kp
|
||||||
return cmdutil.NewFactory(kf)
|
return cmdutil.NewFactory(kf)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user