Commit 16477e02 authored by Michał Flendrich's avatar Michał Flendrich
Browse files

apply, kubeconfig: refactor - simplify and untangle namespace choice.

This change is intended to clean up the code, but leave behavior unmodified.
Showing with 7 additions and 18 deletions
+7 -18
......@@ -188,6 +188,11 @@ func initiateCluster(clusterManifestPath, machinesManifestPath string, closer fu
configDir = filepath.Dir(clusterManifestPath)
}
ns := ""
if !applyOptions.useManifestNamespace {
ns = applyOptions.namespace
}
// TODO(damien): Transform the controller image into an addon.
controllerImage, err := addons.UpdateImage(applyOptions.controllerImage, sp.ClusterSpec.ImageRepository)
if err != nil {
......@@ -217,25 +222,9 @@ func initiateCluster(clusterManifestPath, machinesManifestPath string, closer fu
ImageRepository: sp.ClusterSpec.ImageRepository,
ExternalLoadBalancer: sp.ClusterSpec.APIServer.ExternalLoadBalancer,
AdditionalSANs: sp.ClusterSpec.APIServer.AdditionalSANs,
Namespace: getClusterNamespace(),
Namespace: ns,
}); err != nil {
log.Fatalf("Failed to set up seed node (%s): %v",
sp.GetMasterPublicAddress(), err)
}
}
func getClusterNamespace() string {
if applyOptions.useManifestNamespace {
return ""
}
return firstNonDefaultOrDefault(applyOptions.namespace, kubeconfigOptions.namespace)
}
func firstNonDefaultOrDefault(nses ...string) string {
for _, ns := range nses {
if ns != manifest.DefaultNamespace {
return ns
}
}
return manifest.DefaultNamespace
}
......@@ -63,7 +63,7 @@ func init() {
func configPath(sp *specs.Specs, wksHome string) string {
clusterName := sp.GetClusterName()
configDir := path.WKSResourcePath(wksHome, getClusterNamespace(), clusterName)
configDir := path.WKSResourcePath(wksHome, kubeconfigOptions.namespace, clusterName)
return filepath.Join(configDir, "kubeconfig")
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment