Exclude kubeconfig from use-context update
Since kubeconfig was moved to manifest we don't need to change it during use-context update. Change-Id: Ib6a0ff19eee89bc86a343e374d50938482e33941 Closes: #294
This commit is contained in:
@@ -174,7 +174,7 @@ func (c *Config) reconcileConfig() error {
|
||||
// Specially useful if the config is loaded during a get operation
|
||||
// If it was a Set this would have happened eventually any way
|
||||
if persistIt {
|
||||
return c.PersistConfig()
|
||||
return c.PersistConfig(true)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
@@ -410,7 +410,7 @@ func (c *Config) EnsureComplete() error {
|
||||
// the current Config and KubeConfig objects.
|
||||
// If either file did not previously exist, the file will be created.
|
||||
// Otherwise, the file will be overwritten
|
||||
func (c *Config) PersistConfig() error {
|
||||
func (c *Config) PersistConfig(persistKubeConfig bool) error {
|
||||
airshipConfigYaml, err := c.ToYaml()
|
||||
if err != nil {
|
||||
return err
|
||||
@@ -429,9 +429,11 @@ func (c *Config) PersistConfig() error {
|
||||
return err
|
||||
}
|
||||
|
||||
// Persist the kubeconfig file referenced
|
||||
if err := clientcmd.WriteToFile(*c.kubeConfig, c.kubeConfigPath); err != nil {
|
||||
return err
|
||||
if persistKubeConfig {
|
||||
// Persist the kubeconfig file referenced
|
||||
if err := clientcmd.WriteToFile(*c.kubeConfig, c.kubeConfigPath); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
@@ -857,7 +859,7 @@ func (c *Config) ImportFromKubeConfig(kubeConfigPath string) error {
|
||||
c.importClusters(kubeConfig)
|
||||
c.importContexts(kubeConfig)
|
||||
c.importAuthInfos(kubeConfig)
|
||||
return c.PersistConfig()
|
||||
return c.PersistConfig(true)
|
||||
}
|
||||
|
||||
func (c *Config) importClusters(importKubeConfig *clientcmdapi.Config) {
|
||||
|
||||
@@ -46,7 +46,7 @@ func RunSetAuthInfo(o *AuthInfoOptions, airconfig *Config, writeToStorage bool)
|
||||
}
|
||||
// Update configuration file just in time persistence approach
|
||||
if writeToStorage {
|
||||
if err := airconfig.PersistConfig(); err != nil {
|
||||
if err := airconfig.PersistConfig(true); err != nil {
|
||||
// Error that it didnt persist the changes
|
||||
return modified, ErrConfigFailed{}
|
||||
}
|
||||
@@ -89,7 +89,7 @@ func RunSetCluster(o *ClusterOptions, airconfig *Config, writeToStorage bool) (b
|
||||
// Update configuration file
|
||||
// Just in time persistence approach
|
||||
if writeToStorage {
|
||||
if err := airconfig.PersistConfig(); err != nil {
|
||||
if err := airconfig.PersistConfig(true); err != nil {
|
||||
// Some warning here , that it didnt persist the changes because of this
|
||||
// Or should we float this up
|
||||
// What would it mean? No value.
|
||||
@@ -142,7 +142,7 @@ func RunSetContext(o *ContextOptions, airconfig *Config, writeToStorage bool) (b
|
||||
}
|
||||
// Update configuration file just in time persistence approach
|
||||
if writeToStorage {
|
||||
if err := airconfig.PersistConfig(); err != nil {
|
||||
if err := airconfig.PersistConfig(true); err != nil {
|
||||
// Error that it didnt persist the changes
|
||||
return modified, ErrConfigFailed{}
|
||||
}
|
||||
@@ -159,7 +159,7 @@ func RunUseContext(desiredContext string, airconfig *Config) error {
|
||||
|
||||
if airconfig.CurrentContext != desiredContext {
|
||||
airconfig.CurrentContext = desiredContext
|
||||
if err := airconfig.PersistConfig(); err != nil {
|
||||
if err := airconfig.PersistConfig(false); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
@@ -189,7 +189,7 @@ func RunSetManifest(o *ManifestOptions, airconfig *Config, writeToStorage bool)
|
||||
}
|
||||
// Update configuration file just in time persistence approach
|
||||
if writeToStorage {
|
||||
if err := airconfig.PersistConfig(); err != nil {
|
||||
if err := airconfig.PersistConfig(true); err != nil {
|
||||
// Error that it didnt persist the changes
|
||||
return modified, ErrConfigFailed{}
|
||||
}
|
||||
|
||||
@@ -133,7 +133,7 @@ func TestPersistConfig(t *testing.T) {
|
||||
conf, cleanup := testutil.InitConfig(t)
|
||||
defer cleanup(t)
|
||||
|
||||
err := conf.PersistConfig()
|
||||
err := conf.PersistConfig(true)
|
||||
require.NoError(t, err)
|
||||
|
||||
// Check that the files were created
|
||||
@@ -305,7 +305,7 @@ func TestPurge(t *testing.T) {
|
||||
defer cleanup(t)
|
||||
|
||||
// Store it
|
||||
err := conf.PersistConfig()
|
||||
err := conf.PersistConfig(true)
|
||||
assert.NoErrorf(t, err, "Unable to persist configuration expected at %v", conf.LoadedConfigPath())
|
||||
|
||||
// Verify that the file is there
|
||||
|
||||
Reference in New Issue
Block a user