Fix cluster reconciliation logic
When reconciling clusters, airshipctl points the bootstrapInfo and managementConfiguration to an entry named default, and the user is unaware of this change. The result is that user settings are ignored unless the user defines settings under entries named "default". This change updates the cluster reconciliation logic to do this only when a cluster is added to the airshipconfig by airshipctl. Fixes #244 Change-Id: I2cefbf83a74d9cd566015509a4f768698d274746 Signed-off-by: Drew Walters <andrew.walters@att.com>
This commit is contained in:
parent
2b293b82b2
commit
fa2b0eecff
@ -175,21 +175,26 @@ func (c *Config) reconcileClusters() (map[string]string, bool) {
|
||||
// Probable should just add a number _<COUNTER to it
|
||||
}
|
||||
|
||||
// Update the airship config file
|
||||
// The cluster in the kubeconfig is not present in the airship config. Create it.
|
||||
if c.Clusters[clusterComplexName.Name] == nil {
|
||||
c.Clusters[clusterComplexName.Name] = NewClusterPurpose()
|
||||
}
|
||||
|
||||
// NOTE(drewwalters96): This is a user error because a cluster is defined in name but incomplete. We
|
||||
// need to fail sooner than this function; add up-front validation for this later.
|
||||
if c.Clusters[clusterComplexName.Name].ClusterTypes == nil {
|
||||
c.Clusters[clusterComplexName.Name].ClusterTypes = make(map[string]*Cluster)
|
||||
}
|
||||
|
||||
// The cluster is defined, but the type is not. Define the type.
|
||||
if c.Clusters[clusterComplexName.Name].ClusterTypes[clusterComplexName.Type] == nil {
|
||||
// We have to make sure that ClusterTypes map is initialized properly before assignment
|
||||
if c.Clusters[clusterComplexName.Name].ClusterTypes == nil {
|
||||
c.Clusters[clusterComplexName.Name].ClusterTypes = make(map[string]*Cluster)
|
||||
}
|
||||
c.Clusters[clusterComplexName.Name].ClusterTypes[clusterComplexName.Type] = NewCluster()
|
||||
}
|
||||
|
||||
// Point cluster at kubeconfig
|
||||
configCluster := c.Clusters[clusterComplexName.Name].ClusterTypes[clusterComplexName.Type]
|
||||
configCluster.NameInKubeconf = clusterComplexName.String()
|
||||
configCluster.Bootstrap = AirshipDefaultBootstrapInfo
|
||||
configCluster.ManagementConfiguration = AirshipDefaultManagementConfiguration
|
||||
|
||||
// Store the reference to the KubeConfig Cluster in the Airship Config
|
||||
configCluster.SetKubeCluster(cluster)
|
||||
}
|
||||
|
@ -91,7 +91,11 @@ func NewContext() *Context {
|
||||
|
||||
// NewCluster is a convenience function that returns a new Cluster
|
||||
func NewCluster() *Cluster {
|
||||
return &Cluster{}
|
||||
return &Cluster{
|
||||
NameInKubeconf: "",
|
||||
Bootstrap: AirshipDefaultBootstrapInfo,
|
||||
ManagementConfiguration: AirshipDefaultManagementConfiguration,
|
||||
}
|
||||
}
|
||||
|
||||
// NewManifest is a convenience function that returns a new Manifest
|
||||
|
Loading…
Reference in New Issue
Block a user