From 84f2bc60c91931a481c6f72e042ab405f450c089 Mon Sep 17 00:00:00 2001 From: Alexander Noskov Date: Tue, 12 May 2020 00:53:11 -0500 Subject: [PATCH] Fix default Airshipctl config parameters Problems description: Once we execute airshipctl config init, the default config in ~/.airship/config doesn't contain default values for: currentContext: ~ clusters: default: clusterType: target: bootstrapInfo: ~ managementConfiguration: ~ --- This PS set default values for Airshipctl config to use it out of the box. Closes: #234 Change-Id: I57449e678f19ab1c0e2212c38b01ea195f62aa44 --- pkg/cluster/initinfra/testdata/config.yaml | 2 +- .../cmd/testdata/airshipconfig.yaml | 2 +- pkg/config/config.go | 4 +-- pkg/config/constants.go | 30 ++++++++++--------- pkg/config/utils.go | 5 ++-- pkg/phase/apply/testdata/config.yaml | 2 +- .../defaults/main.yaml | 2 +- testdata/k8s/config.yaml | 2 +- 8 files changed, 26 insertions(+), 23 deletions(-) diff --git a/pkg/cluster/initinfra/testdata/config.yaml b/pkg/cluster/initinfra/testdata/config.yaml index 28a74101c..97635df0d 100644 --- a/pkg/cluster/initinfra/testdata/config.yaml +++ b/pkg/cluster/initinfra/testdata/config.yaml @@ -3,7 +3,7 @@ bootstrapInfo: dummy_bootstrap_config: container: volume: /tmp/airship:/config - image: quay.io/airshipit/isogen:latest + image: quay.io/airshipit/isogen:latest-debian_stable containerRuntime: docker builder: userDataFileName: user-data diff --git a/pkg/clusterctl/cmd/testdata/airshipconfig.yaml b/pkg/clusterctl/cmd/testdata/airshipconfig.yaml index 121b9c1f9..d9566c1eb 100644 --- a/pkg/clusterctl/cmd/testdata/airshipconfig.yaml +++ b/pkg/clusterctl/cmd/testdata/airshipconfig.yaml @@ -3,7 +3,7 @@ bootstrapInfo: dummy_bootstrap_config: container: volume: /tmp/airship:/config - image: quay.io/airshipit/isogen:latest + image: quay.io/airshipit/isogen:latest-debian_stable containerRuntime: docker builder: userDataFileName: user-data diff --git a/pkg/config/config.go b/pkg/config/config.go index 1959af612..6ce0a7e6b 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -188,8 +188,8 @@ func (c *Config) reconcileClusters() (map[string]string, bool) { } configCluster := c.Clusters[clusterComplexName.Name].ClusterTypes[clusterComplexName.Type] configCluster.NameInKubeconf = clusterComplexName.String() - // TODO What do we do with the BOOTSTRAP CONFIG - + configCluster.Bootstrap = AirshipDefaultBootstrapInfo + configCluster.ManagementConfiguration = AirshipDefaultManagementConfiguration // Store the reference to the KubeConfig Cluster in the Airship Config configCluster.SetKubeCluster(cluster) } diff --git a/pkg/config/constants.go b/pkg/config/constants.go index b2e05b546..521bdda34 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -36,22 +36,24 @@ var AllClusterTypes = [2]string{Ephemeral, Target} // Constants defining default values const ( - AirshipConfigGroup = "airshipit.org" - AirshipConfigVersion = "v1alpha1" - AirshipConfigAPIVersion = AirshipConfigGroup + "/" + AirshipConfigVersion - AirshipConfigKind = "Config" - AirshipConfigDir = ".airship" - AirshipConfig = "config" - AirshipKubeConfig = "kubeconfig" - AirshipConfigEnv = "AIRSHIPCONFIG" - AirshipKubeConfigEnv = "AIRSHIP_KUBECONFIG" - AirshipDefaultContext = "default" - AirshipDefaultManifest = "default" - AirshipDefaultManifestRepo = "treasuremap" - AirshipDefaultManifestRepoLocation = "https://opendev.org/airship/" + AirshipDefaultManifestRepo + AirshipConfig = "config" + AirshipConfigAPIVersion = AirshipConfigGroup + "/" + AirshipConfigVersion + AirshipConfigDir = ".airship" + AirshipConfigEnv = "AIRSHIPCONFIG" + AirshipConfigGroup = "airshipit.org" + AirshipConfigKind = "Config" + AirshipConfigVersion = "v1alpha1" + AirshipDefaultBootstrapInfo = "default" + AirshipDefaultContext = "default" + AirshipDefaultManagementConfiguration = "default" + AirshipDefaultManifest = "default" + AirshipDefaultManifestRepo = "treasuremap" + AirshipDefaultManifestRepoLocation = "https://opendev.org/airship/" + AirshipDefaultManifestRepo + AirshipKubeConfig = "kubeconfig" + AirshipKubeConfigEnv = "AIRSHIP_KUBECONFIG" // Modules - AirshipDefaultBootstrapImage = "quay.io/airshipit/isogen:latest" + AirshipDefaultBootstrapImage = "quay.io/airshipit/isogen:latest-debian_stable" AirshipDefaultIsoURL = "http://localhost:8099/debian-custom.iso" AirshipDefaultRemoteType = redfish.ClientType ) diff --git a/pkg/config/utils.go b/pkg/config/utils.go index b6cb891c6..e8ea54729 100644 --- a/pkg/config/utils.go +++ b/pkg/config/utils.go @@ -33,7 +33,7 @@ func NewConfig() *Config { Kind: AirshipConfigKind, APIVersion: AirshipConfigAPIVersion, BootstrapInfo: map[string]*Bootstrap{ - AirshipDefaultContext: { + AirshipDefaultBootstrapInfo: { Container: &Container{ Volume: "/srv/iso:/config", Image: AirshipDefaultBootstrapImage, @@ -56,8 +56,9 @@ func NewConfig() *Config { Manifest: AirshipDefaultManifest, }, }, + CurrentContext: AirshipDefaultContext, ManagementConfiguration: map[string]*ManagementConfiguration{ - AirshipDefaultContext: { + AirshipDefaultManagementConfiguration: { Type: redfish.ClientType, Insecure: true, UseProxy: false, diff --git a/pkg/phase/apply/testdata/config.yaml b/pkg/phase/apply/testdata/config.yaml index 28a74101c..97635df0d 100644 --- a/pkg/phase/apply/testdata/config.yaml +++ b/pkg/phase/apply/testdata/config.yaml @@ -3,7 +3,7 @@ bootstrapInfo: dummy_bootstrap_config: container: volume: /tmp/airship:/config - image: quay.io/airshipit/isogen:latest + image: quay.io/airshipit/isogen:latest-debian_stable containerRuntime: docker builder: userDataFileName: user-data diff --git a/roles/airshipctl-test-configs/defaults/main.yaml b/roles/airshipctl-test-configs/defaults/main.yaml index 75ec210c5..fc1583245 100644 --- a/roles/airshipctl-test-configs/defaults/main.yaml +++ b/roles/airshipctl-test-configs/defaults/main.yaml @@ -16,7 +16,7 @@ airship_config_manifest_directory: /tmp/airship airship_config_primary_repo_url: "https://review.opendev.org/airship/airshipctl" airship_config_primary_repo_branch: "master" airship_config_ephemeral_ip: "10.23.25.101" -airship_config_iso_builder_docker_image: quay.io/airshipit/isogen:latest +airship_config_iso_builder_docker_image: quay.io/airshipit/isogen:latest-debian_stable airship_config_iso_port: 8099 airship_config_iso_serve_host: localhost airship_config_iso_name: debian-custom.iso diff --git a/testdata/k8s/config.yaml b/testdata/k8s/config.yaml index c7a6119c1..cbd4c354d 100644 --- a/testdata/k8s/config.yaml +++ b/testdata/k8s/config.yaml @@ -7,7 +7,7 @@ bootstrapInfo: userDataFileName: user-data container: containerRuntime: docker - image: quay.io/airshipit/isogen:latest + image: quay.io/airshipit/isogen:latest-debian_stable volume: /srv/iso:/config remoteDirect: isoUrl: http://localhost:8099/debian-custom.iso