From cd9b4dddb4d31db20a789ca106ed6f1415d36c53 Mon Sep 17 00:00:00 2001 From: Stanislav Egorov Date: Mon, 20 Apr 2020 16:27:59 -0700 Subject: [PATCH] Refactored airshipctl config Removed Modules from config. There are no other types of modules that need additional configuration. BootstrapInfo is defined in the config directly. Used camelCase for config parameters. Change-Id: I3531a061026f3b2f1e72af6272ba4709f28d1b3d --- .../get-all-ephemeral.golden | 24 ++++----- .../get-all-target.golden | 24 ++++----- .../get-ephemeral.golden | 4 +- .../get-multiple-ephemeral.golden | 24 ++++----- .../get-multiple-target.golden | 24 ++++----- .../get-target.golden | 4 +- .../get-all-contexts.golden | 6 +-- .../get-context.golden | 2 +- .../get-current-context.golden | 2 +- .../get-multiple-contexts.golden | 6 +-- pkg/cluster/initinfra/testdata/config.yaml | 44 +++++++-------- pkg/config/config.go | 13 +---- pkg/config/config_test.go | 14 ++--- pkg/config/repo_test.go | 34 ++++++------ ...-string.yaml => bootstrapinfo-string.yaml} | 0 pkg/config/testdata/cluster-string.yaml | 4 +- pkg/config/testdata/config-string.yaml | 45 ++++++++-------- pkg/config/testdata/context-string.yaml | 2 +- pkg/config/testdata/manifest-string.yaml | 10 ++-- pkg/config/testdata/modules-string.yaml | 10 ---- pkg/config/testdata/prettycluster-string.yaml | 4 +- pkg/config/testdata/repo-auth-string.yaml | 2 +- pkg/config/testdata/repo-checkout-string.yaml | 2 +- pkg/config/testdata/repository-string.yaml | 4 +- pkg/config/types.go | 42 ++++++--------- pkg/config/utils.go | 48 +++++++---------- .../templates/airshipconfig.j2 | 49 +++++++++-------- testdata/k8s/config.yaml | 45 ++++++++-------- testutil/testconfig.go | 54 +++++++++---------- 29 files changed, 247 insertions(+), 299 deletions(-) rename pkg/config/testdata/{bootstrap-string.yaml => bootstrapinfo-string.yaml} (100%) delete mode 100644 pkg/config/testdata/modules-string.yaml diff --git a/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-all-ephemeral.golden b/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-all-ephemeral.golden index ea96bf06c..2774bd228 100644 --- a/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-all-ephemeral.golden +++ b/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-all-ephemeral.golden @@ -1,7 +1,7 @@ Cluster: clusterBar ephemeral: -bootstrap-info: "" -cluster-kubeconf: clusterBar_ephemeral +bootstrapInfo: "" +clusterKubeconf: clusterBar_ephemeral LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -9,8 +9,8 @@ server: "" Cluster: clusterBar target: -bootstrap-info: "" -cluster-kubeconf: clusterBar_target +bootstrapInfo: "" +clusterKubeconf: clusterBar_target LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -18,8 +18,8 @@ server: "" Cluster: clusterBaz ephemeral: -bootstrap-info: "" -cluster-kubeconf: clusterBaz_ephemeral +bootstrapInfo: "" +clusterKubeconf: clusterBaz_ephemeral LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -27,8 +27,8 @@ server: "" Cluster: clusterBaz target: -bootstrap-info: "" -cluster-kubeconf: clusterBaz_target +bootstrapInfo: "" +clusterKubeconf: clusterBaz_target LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -36,8 +36,8 @@ server: "" Cluster: clusterFoo ephemeral: -bootstrap-info: "" -cluster-kubeconf: clusterFoo_ephemeral +bootstrapInfo: "" +clusterKubeconf: clusterFoo_ephemeral LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -45,8 +45,8 @@ server: "" Cluster: clusterFoo target: -bootstrap-info: "" -cluster-kubeconf: clusterFoo_target +bootstrapInfo: "" +clusterKubeconf: clusterFoo_target LocationOfOrigin: "" insecure-skip-tls-verify: true diff --git a/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-all-target.golden b/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-all-target.golden index ea96bf06c..2774bd228 100644 --- a/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-all-target.golden +++ b/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-all-target.golden @@ -1,7 +1,7 @@ Cluster: clusterBar ephemeral: -bootstrap-info: "" -cluster-kubeconf: clusterBar_ephemeral +bootstrapInfo: "" +clusterKubeconf: clusterBar_ephemeral LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -9,8 +9,8 @@ server: "" Cluster: clusterBar target: -bootstrap-info: "" -cluster-kubeconf: clusterBar_target +bootstrapInfo: "" +clusterKubeconf: clusterBar_target LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -18,8 +18,8 @@ server: "" Cluster: clusterBaz ephemeral: -bootstrap-info: "" -cluster-kubeconf: clusterBaz_ephemeral +bootstrapInfo: "" +clusterKubeconf: clusterBaz_ephemeral LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -27,8 +27,8 @@ server: "" Cluster: clusterBaz target: -bootstrap-info: "" -cluster-kubeconf: clusterBaz_target +bootstrapInfo: "" +clusterKubeconf: clusterBaz_target LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -36,8 +36,8 @@ server: "" Cluster: clusterFoo ephemeral: -bootstrap-info: "" -cluster-kubeconf: clusterFoo_ephemeral +bootstrapInfo: "" +clusterKubeconf: clusterFoo_ephemeral LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -45,8 +45,8 @@ server: "" Cluster: clusterFoo target: -bootstrap-info: "" -cluster-kubeconf: clusterFoo_target +bootstrapInfo: "" +clusterKubeconf: clusterFoo_target LocationOfOrigin: "" insecure-skip-tls-verify: true diff --git a/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-ephemeral.golden b/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-ephemeral.golden index c4cdc695c..04a90037b 100644 --- a/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-ephemeral.golden +++ b/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-ephemeral.golden @@ -1,7 +1,7 @@ Cluster: clusterFoo ephemeral: -bootstrap-info: "" -cluster-kubeconf: clusterFoo_ephemeral +bootstrapInfo: "" +clusterKubeconf: clusterFoo_ephemeral LocationOfOrigin: "" insecure-skip-tls-verify: true diff --git a/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-multiple-ephemeral.golden b/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-multiple-ephemeral.golden index ea96bf06c..2774bd228 100644 --- a/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-multiple-ephemeral.golden +++ b/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-multiple-ephemeral.golden @@ -1,7 +1,7 @@ Cluster: clusterBar ephemeral: -bootstrap-info: "" -cluster-kubeconf: clusterBar_ephemeral +bootstrapInfo: "" +clusterKubeconf: clusterBar_ephemeral LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -9,8 +9,8 @@ server: "" Cluster: clusterBar target: -bootstrap-info: "" -cluster-kubeconf: clusterBar_target +bootstrapInfo: "" +clusterKubeconf: clusterBar_target LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -18,8 +18,8 @@ server: "" Cluster: clusterBaz ephemeral: -bootstrap-info: "" -cluster-kubeconf: clusterBaz_ephemeral +bootstrapInfo: "" +clusterKubeconf: clusterBaz_ephemeral LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -27,8 +27,8 @@ server: "" Cluster: clusterBaz target: -bootstrap-info: "" -cluster-kubeconf: clusterBaz_target +bootstrapInfo: "" +clusterKubeconf: clusterBaz_target LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -36,8 +36,8 @@ server: "" Cluster: clusterFoo ephemeral: -bootstrap-info: "" -cluster-kubeconf: clusterFoo_ephemeral +bootstrapInfo: "" +clusterKubeconf: clusterFoo_ephemeral LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -45,8 +45,8 @@ server: "" Cluster: clusterFoo target: -bootstrap-info: "" -cluster-kubeconf: clusterFoo_target +bootstrapInfo: "" +clusterKubeconf: clusterFoo_target LocationOfOrigin: "" insecure-skip-tls-verify: true diff --git a/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-multiple-target.golden b/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-multiple-target.golden index ea96bf06c..2774bd228 100644 --- a/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-multiple-target.golden +++ b/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-multiple-target.golden @@ -1,7 +1,7 @@ Cluster: clusterBar ephemeral: -bootstrap-info: "" -cluster-kubeconf: clusterBar_ephemeral +bootstrapInfo: "" +clusterKubeconf: clusterBar_ephemeral LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -9,8 +9,8 @@ server: "" Cluster: clusterBar target: -bootstrap-info: "" -cluster-kubeconf: clusterBar_target +bootstrapInfo: "" +clusterKubeconf: clusterBar_target LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -18,8 +18,8 @@ server: "" Cluster: clusterBaz ephemeral: -bootstrap-info: "" -cluster-kubeconf: clusterBaz_ephemeral +bootstrapInfo: "" +clusterKubeconf: clusterBaz_ephemeral LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -27,8 +27,8 @@ server: "" Cluster: clusterBaz target: -bootstrap-info: "" -cluster-kubeconf: clusterBaz_target +bootstrapInfo: "" +clusterKubeconf: clusterBaz_target LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -36,8 +36,8 @@ server: "" Cluster: clusterFoo ephemeral: -bootstrap-info: "" -cluster-kubeconf: clusterFoo_ephemeral +bootstrapInfo: "" +clusterKubeconf: clusterFoo_ephemeral LocationOfOrigin: "" insecure-skip-tls-verify: true @@ -45,8 +45,8 @@ server: "" Cluster: clusterFoo target: -bootstrap-info: "" -cluster-kubeconf: clusterFoo_target +bootstrapInfo: "" +clusterKubeconf: clusterFoo_target LocationOfOrigin: "" insecure-skip-tls-verify: true diff --git a/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-target.golden b/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-target.golden index 13da9d1d7..ec5485ad8 100644 --- a/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-target.golden +++ b/cmd/config/testdata/TestGetClusterCmdGoldenOutput/get-target.golden @@ -1,7 +1,7 @@ Cluster: clusterFoo target: -bootstrap-info: "" -cluster-kubeconf: clusterFoo_target +bootstrapInfo: "" +clusterKubeconf: clusterFoo_target LocationOfOrigin: "" insecure-skip-tls-verify: true diff --git a/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-all-contexts.golden b/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-all-contexts.golden index 67adb08e2..88ac45bbe 100644 --- a/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-all-contexts.golden +++ b/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-all-contexts.golden @@ -1,5 +1,5 @@ Context: ContextBar -context-kubeconf: ContextBar_ephemeral +contextKubeconf: ContextBar_ephemeral manifest: Manifest_ContextBar LocationOfOrigin: "" @@ -9,7 +9,7 @@ user: dummy_user Context: ContextBaz -context-kubeconf: ContextBaz_ephemeral +contextKubeconf: ContextBaz_ephemeral manifest: Manifest_ContextBaz LocationOfOrigin: "" @@ -19,7 +19,7 @@ user: dummy_user Context: ContextFoo -context-kubeconf: ContextFoo_ephemeral +contextKubeconf: ContextFoo_ephemeral manifest: Manifest_ContextFoo LocationOfOrigin: "" diff --git a/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-context.golden b/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-context.golden index 833456c43..d5195ef78 100644 --- a/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-context.golden +++ b/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-context.golden @@ -1,5 +1,5 @@ Context: ContextFoo -context-kubeconf: ContextFoo_ephemeral +contextKubeconf: ContextFoo_ephemeral manifest: Manifest_ContextFoo LocationOfOrigin: "" diff --git a/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-current-context.golden b/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-current-context.golden index fca20db48..5afc037ec 100644 --- a/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-current-context.golden +++ b/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-current-context.golden @@ -1,5 +1,5 @@ Context: ContextBaz -context-kubeconf: ContextBaz_ephemeral +contextKubeconf: ContextBaz_ephemeral manifest: Manifest_ContextBaz LocationOfOrigin: "" diff --git a/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-multiple-contexts.golden b/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-multiple-contexts.golden index 67adb08e2..88ac45bbe 100644 --- a/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-multiple-contexts.golden +++ b/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-multiple-contexts.golden @@ -1,5 +1,5 @@ Context: ContextBar -context-kubeconf: ContextBar_ephemeral +contextKubeconf: ContextBar_ephemeral manifest: Manifest_ContextBar LocationOfOrigin: "" @@ -9,7 +9,7 @@ user: dummy_user Context: ContextBaz -context-kubeconf: ContextBaz_ephemeral +contextKubeconf: ContextBaz_ephemeral manifest: Manifest_ContextBaz LocationOfOrigin: "" @@ -19,7 +19,7 @@ user: dummy_user Context: ContextFoo -context-kubeconf: ContextFoo_ephemeral +contextKubeconf: ContextFoo_ephemeral manifest: Manifest_ContextFoo LocationOfOrigin: "" diff --git a/pkg/cluster/initinfra/testdata/config.yaml b/pkg/cluster/initinfra/testdata/config.yaml index 6d0c76e94..28a74101c 100644 --- a/pkg/cluster/initinfra/testdata/config.yaml +++ b/pkg/cluster/initinfra/testdata/config.yaml @@ -1,42 +1,44 @@ apiVersion: airshipit.org/v1alpha1 +bootstrapInfo: + dummy_bootstrap_config: + container: + volume: /tmp/airship:/config + image: quay.io/airshipit/isogen:latest + containerRuntime: docker + builder: + userDataFileName: user-data + networkConfigFileName: network-config + outputMetadataFileName: output-metadata.yaml + remoteDirect: + isoUrl: http://localhost:8099/debian-custom.iso + remoteType: redfish clusters: dummycluster: - cluster-type: + clusterType: ephemeral: - bootstrap-info: dummy_bootstrap_config - cluster-kubeconf: dummycluster_ephemeral + bootstrapInfo: dummy_bootstrap_config + clusterKubeconf: dummycluster_ephemeral contexts: dummy_cluster: - context-kubeconf: dummy_cluster + contextKubeconf: dummy_cluster manifest: dummy_manifest -current-context: dummy_cluster +currentContext: dummy_cluster kind: Config manifests: dummy_manifest: - primary-repository-name: primary + primaryRepositoryName: primary repositories: primary: auth: - ssh-key: testdata/test-key.pem + sshKey: testdata/test-key.pem type: ssh-key checkout: branch: "" force: false - remote-ref: "" + remoteRef: "" tag: v1.0.1 url: http://dummy.url.com/primary.git - sub-path: primary/site/test-site - target-path: testdata -modules-config: - bootstrapInfo: - dummy_bootstrap_config: - container: - volume: /tmp/airship:/config - image: quay.io/airshipit/isogen:latest - containerRuntime: docker - builder: - userDataFileName: user-data - networkConfigFileName: network-config - outputMetadataFileName: output-metadata.yaml + subPath: primary/site/test-site + targetPath: testdata users: dummy_user: {} \ No newline at end of file diff --git a/pkg/config/config.go b/pkg/config/config.go index 21b11e90c..f3596326a 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -716,11 +716,11 @@ func (c *Config) CurrentContextBootstrapInfo() (*Bootstrap, error) { if currentCluster.Bootstrap == "" { return nil, ErrMissingConfig{ - What: fmt.Sprintf("No bootstrap-info defined for context %q", c.CurrentContext), + What: fmt.Sprintf("No bootstrapInfo defined for context %q", c.CurrentContext), } } - bootstrap, exists := c.ModulesConfig.BootstrapInfo[currentCluster.Bootstrap] + bootstrap, exists := c.BootstrapInfo[currentCluster.Bootstrap] if !exists { return nil, ErrBootstrapInfoNotFound{Name: currentCluster.Bootstrap} } @@ -815,15 +815,6 @@ func (m *Manifest) String() string { return string(yamlData) } -// Modules functions -func (m *Modules) String() string { - yamlData, err := yaml.Marshal(&m) - if err != nil { - return "" - } - return string(yamlData) -} - // Bootstrap functions func (b *Bootstrap) String() string { yamlData, err := yaml.Marshal(&b) diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 8acb9e678..74548e6b4 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -61,10 +61,6 @@ func TestString(t *testing.T) { name: "manifest", stringer: testutil.DummyManifest(), }, - { - name: "modules", - stringer: testutil.DummyModules(), - }, { name: "repository", stringer: testutil.DummyRepository(), @@ -78,12 +74,8 @@ func TestString(t *testing.T) { stringer: testutil.DummyRepoCheckout(), }, { - name: "bootstrap", - stringer: testutil.DummyBootstrap(), - }, - { - name: "bootstrap", - stringer: testutil.DummyBootstrap(), + name: "bootstrapinfo", + stringer: testutil.DummyBootstrapInfo(), }, { name: "builder", @@ -282,7 +274,7 @@ func TestCurrentContextBootstrapInfo(t *testing.T) { bootstrapInfo, err = conf.CurrentContextBootstrapInfo() require.NoError(t, err) - assert.Equal(t, conf.ModulesConfig.BootstrapInfo[defaultString], bootstrapInfo) + assert.Equal(t, conf.BootstrapInfo[defaultString], bootstrapInfo) } func TestPurge(t *testing.T) { diff --git a/pkg/config/repo_test.go b/pkg/config/repo_test.go index d3ca0ea51..29939ff3c 100644 --- a/pkg/config/repo_test.go +++ b/pkg/config/repo_test.go @@ -42,7 +42,7 @@ const ( url: git@github.com:go-git/go-git.git auth: type: ssh-key - ssh-key: "testdata/test-key.pem" + sshKey: "testdata/test-key.pem" username: git checkout: branch: master @@ -50,62 +50,62 @@ const ( url: /home/ubuntu/some-gitrepo auth: type: ssh-pass - ssh-pass: "qwerty123" + sshPass: "qwerty123" username: deployer checkout: - commit-hash: 01c4f7f32beb9851ae8f119a6b8e497d2b1e2bb8 + commitHash: 01c4f7f32beb9851ae8f119a6b8e497d2b1e2bb8 http-basic-auth: url: /home/ubuntu/some-gitrepo auth: type: http-basic - http-pass: "qwerty123" + httpPass: "qwerty123" username: deployer checkout: - commit-hash: 01c4f7f32beb9851ae8f119a6b8e497d2b1e2bb8 + commitHash: 01c4f7f32beb9851ae8f119a6b8e497d2b1e2bb8 empty-checkout: url: /home/ubuntu/some-gitrepo auth: type: http-basic - http-pass: "qwerty123" + httpPass: "qwerty123" username: deployer wrong-type-auth: url: /home/ubuntu/some-gitrepo auth: type: wrong-type - http-pass: "qwerty123" + httpPass: "qwerty123" username: deployer checkout: - commit-hash: 01c4f7f32beb9851ae8f119a6b8e497d2b1e2bb8 + commitHash: 01c4f7f32beb9851ae8f119a6b8e497d2b1e2bb8 mutually-exclusive-auth-opts: url: /home/ubuntu/some-gitrepo auth: type: http-basic - ssh-key: "/path-to-key" + sshKey: "/path-to-key" username: deployer mutually-exclusive-checkout-opts: url: /home/ubuntu/some-gitrepo checkout: - commit-hash: 01c4f7f32beb9851ae8f119a6b8e497d2b1e2bb8 + commitHash: 01c4f7f32beb9851ae8f119a6b8e497d2b1e2bb8 branch: master mutually-exclusive-auth-opts-ssh-key: url: /home/ubuntu/some-gitrepo auth: type: ssh-key - http-pass: "qwerty123" - ssh-key: "/path-to-key" + httpPass: "qwerty123" + sshKey: "/path-to-key" username: deployer checkout: - commit-hash: 01c4f7f32beb9851ae8f119a6b8e497d2b1e2bb8 + commitHash: 01c4f7f32beb9851ae8f119a6b8e497d2b1e2bb8 mutually-exclusive-auth-opts-ssh-pass: url: /home/ubuntu/some-gitrepo auth: type: ssh-pass - ssh-pass: "qwerty123" - http-pass: "qwerty123" - ssh-key: "/path-to-key" + sshPass: "qwerty123" + httpPass: "qwerty123" + sshKey: "/path-to-key" username: deployer checkout: - commit-hash: 01c4f7f32beb9851ae8f119a6b8e497d2b1e2bb8` + commitHash: 01c4f7f32beb9851ae8f119a6b8e497d2b1e2bb8` ) var ( diff --git a/pkg/config/testdata/bootstrap-string.yaml b/pkg/config/testdata/bootstrapinfo-string.yaml similarity index 100% rename from pkg/config/testdata/bootstrap-string.yaml rename to pkg/config/testdata/bootstrapinfo-string.yaml diff --git a/pkg/config/testdata/cluster-string.yaml b/pkg/config/testdata/cluster-string.yaml index 8da43a305..b9555a30a 100644 --- a/pkg/config/testdata/cluster-string.yaml +++ b/pkg/config/testdata/cluster-string.yaml @@ -1,5 +1,5 @@ -bootstrap-info: dummy_bootstrap_config -cluster-kubeconf: dummy_cluster_target +bootstrapInfo: dummy_bootstrap_config +clusterKubeconf: dummy_cluster_target LocationOfOrigin: "" certificate-authority: dummy_ca diff --git a/pkg/config/testdata/config-string.yaml b/pkg/config/testdata/config-string.yaml index caf8b0e90..55f2eb20b 100644 --- a/pkg/config/testdata/config-string.yaml +++ b/pkg/config/testdata/config-string.yaml @@ -1,45 +1,44 @@ apiVersion: airshipit.org/v1alpha1 +bootstrapInfo: + dummy_bootstrap_config: + builder: + networkConfigFileName: netconfig + outputMetadataFileName: output-metadata.yaml + userDataFileName: user-data + container: + containerRuntime: docker + image: dummy_image:dummy_tag + volume: /dummy:dummy clusters: dummy_cluster: - cluster-type: + clusterType: ephemeral: - bootstrap-info: dummy_bootstrap_config - cluster-kubeconf: dummy_cluster_ephemeral + bootstrapInfo: dummy_bootstrap_config + clusterKubeconf: dummy_cluster_ephemeral target: - bootstrap-info: dummy_bootstrap_config - cluster-kubeconf: dummy_cluster_target + bootstrapInfo: dummy_bootstrap_config + clusterKubeconf: dummy_cluster_target contexts: dummy_context: - context-kubeconf: dummy_cluster_ephemeral + contextKubeconf: dummy_cluster_ephemeral manifest: dummy_manifest -current-context: dummy_context +currentContext: dummy_context kind: Config manifests: dummy_manifest: - primary-repository-name: primary + primaryRepositoryName: primary repositories: primary: auth: - ssh-key: testdata/test-key.pem + sshKey: testdata/test-key.pem type: ssh-key checkout: branch: "" force: false - remote-ref: "" + remoteRef: "" tag: v1.0.1 url: http://dummy.url.com/manifests.git - sub-path: manifests/site/test-site - target-path: /var/tmp/ -modules-config: - bootstrapInfo: - dummy_bootstrap_config: - builder: - networkConfigFileName: netconfig - outputMetadataFileName: output-metadata.yaml - userDataFileName: user-data - container: - containerRuntime: docker - image: dummy_image:dummy_tag - volume: /dummy:dummy + subPath: manifests/site/test-site + targetPath: /var/tmp/ users: dummy_user: {} diff --git a/pkg/config/testdata/context-string.yaml b/pkg/config/testdata/context-string.yaml index 0ec7bc8b8..0f0c5975a 100644 --- a/pkg/config/testdata/context-string.yaml +++ b/pkg/config/testdata/context-string.yaml @@ -1,4 +1,4 @@ -context-kubeconf: dummy_cluster_ephemeral +contextKubeconf: dummy_cluster_ephemeral manifest: dummy_manifest LocationOfOrigin: "" diff --git a/pkg/config/testdata/manifest-string.yaml b/pkg/config/testdata/manifest-string.yaml index 2e817499a..f1eed1d4d 100644 --- a/pkg/config/testdata/manifest-string.yaml +++ b/pkg/config/testdata/manifest-string.yaml @@ -1,14 +1,14 @@ -primary-repository-name: primary +primaryRepositoryName: primary repositories: primary: auth: - ssh-key: testdata/test-key.pem + sshKey: testdata/test-key.pem type: ssh-key checkout: branch: "" force: false - remote-ref: "" + remoteRef: "" tag: v1.0.1 url: http://dummy.url.com/manifests.git -sub-path: manifests/site/test-site -target-path: /var/tmp/ +subPath: manifests/site/test-site +targetPath: /var/tmp/ diff --git a/pkg/config/testdata/modules-string.yaml b/pkg/config/testdata/modules-string.yaml deleted file mode 100644 index 87b9b3ec7..000000000 --- a/pkg/config/testdata/modules-string.yaml +++ /dev/null @@ -1,10 +0,0 @@ -bootstrapInfo: - dummy_bootstrap_config: - builder: - networkConfigFileName: netconfig - outputMetadataFileName: output-metadata.yaml - userDataFileName: user-data - container: - containerRuntime: docker - image: dummy_image:dummy_tag - volume: /dummy:dummy diff --git a/pkg/config/testdata/prettycluster-string.yaml b/pkg/config/testdata/prettycluster-string.yaml index 4e3d6b5fc..aa8b1cd0b 100644 --- a/pkg/config/testdata/prettycluster-string.yaml +++ b/pkg/config/testdata/prettycluster-string.yaml @@ -1,7 +1,7 @@ Cluster: dummy_cluster target: -bootstrap-info: dummy_bootstrap_config -cluster-kubeconf: dummy_cluster_target +bootstrapInfo: dummy_bootstrap_config +clusterKubeconf: dummy_cluster_target LocationOfOrigin: "" certificate-authority: dummy_ca diff --git a/pkg/config/testdata/repo-auth-string.yaml b/pkg/config/testdata/repo-auth-string.yaml index 6760b3bc3..2942594af 100644 --- a/pkg/config/testdata/repo-auth-string.yaml +++ b/pkg/config/testdata/repo-auth-string.yaml @@ -1,2 +1,2 @@ -ssh-key: testdata/test-key.pem +sshKey: testdata/test-key.pem type: ssh-key diff --git a/pkg/config/testdata/repo-checkout-string.yaml b/pkg/config/testdata/repo-checkout-string.yaml index 9fca83c90..6608a6ebf 100644 --- a/pkg/config/testdata/repo-checkout-string.yaml +++ b/pkg/config/testdata/repo-checkout-string.yaml @@ -1,4 +1,4 @@ branch: "" force: false -remote-ref: "" +remoteRef: "" tag: v1.0.1 diff --git a/pkg/config/testdata/repository-string.yaml b/pkg/config/testdata/repository-string.yaml index 97b3772ba..8f5625131 100644 --- a/pkg/config/testdata/repository-string.yaml +++ b/pkg/config/testdata/repository-string.yaml @@ -1,9 +1,9 @@ auth: - ssh-key: testdata/test-key.pem + sshKey: testdata/test-key.pem type: ssh-key checkout: branch: "" force: false - remote-ref: "" + remoteRef: "" tag: v1.0.1 url: http://dummy.url.com/manifests.git diff --git a/pkg/config/types.go b/pkg/config/types.go index 3b647e905..e6dc957ae 100644 --- a/pkg/config/types.go +++ b/pkg/config/types.go @@ -47,12 +47,10 @@ type Config struct { Manifests map[string]*Manifest `json:"manifests"` // CurrentContext is the name of the context that you would like to use by default - CurrentContext string `json:"current-context"` + CurrentContext string `json:"currentContext"` - // Modules Section - // Will store configuration required by the different airshipctl modules - // Such as Bootstrap, Workflows, Document, etc - ModulesConfig *Modules `json:"modules-config"` + // BootstrapInfo is the configuration for container runtime, ISO builder and remote management + BootstrapInfo map[string]*Bootstrap `json:"bootstrapInfo"` // loadedConfigPath is the full path to the the location of the config // file from which this config was loaded @@ -71,34 +69,26 @@ type Config struct { // ClusterPurpose encapsulates the Cluster Type as an enumeration type ClusterPurpose struct { // Cluster map of referenceable names to cluster configs - ClusterTypes map[string]*Cluster `json:"cluster-type"` + ClusterTypes map[string]*Cluster `json:"clusterType"` } // Cluster contains information about how to communicate with a kubernetes cluster type Cluster struct { // Complex cluster name defined by the using _) - NameInKubeconf string `json:"cluster-kubeconf"` + NameInKubeconf string `json:"clusterKubeconf"` // KubeConfig Cluster Object cluster *kubeconfig.Cluster // Bootstrap configuration this clusters ephemeral hosts will rely on - Bootstrap string `json:"bootstrap-info"` -} - -// Modules encapsulates all module configurations -// Configuration that the Bootstrap Module would need -// Configuration that the Document Module would need -// Configuration that the Workflows Module would need -type Modules struct { - BootstrapInfo map[string]*Bootstrap `json:"bootstrapInfo"` + Bootstrap string `json:"bootstrapInfo"` } // Context is a tuple of references to a cluster (how do I communicate with a kubernetes context), // a user (how do I identify myself), and a namespace (what subset of resources do I want to work with) type Context struct { // Context name in kubeconf - NameInKubeconf string `json:"context-kubeconf"` + NameInKubeconf string `json:"contextKubeconf"` // Manifest is the default manifest to be use with this context // +optional @@ -118,18 +108,18 @@ type AuthInfo struct { type Manifest struct { // PrimaryRepositoryName is a name of the repo, that contains site/ directory // and is a starting point for building document bundle - PrimaryRepositoryName string `json:"primary-repository-name"` + PrimaryRepositoryName string `json:"primaryRepositoryName"` // ExtraRepositories is the map of extra repositories addressable by a name Repositories map[string]*Repository `json:"repositories,omitempty"` // TargetPath Local Target path for working or home dirctory for all Manifest Cloned/Returned/Generated - TargetPath string `json:"target-path"` + TargetPath string `json:"targetPath"` // SubPath is a path relative to TargetPath + Path where PrimaryRepository is cloned and contains // directories with ClusterType and Phase bundles, example: // Repositories[PrimaryRepositoryName].Url = 'https://github.com/airshipit/treasuremap' // SubPath = "manifests" // you would expect that at treasuremap/manifests you would have ephemeral/initinfra and // ephemera/target directories, containing kustomize.yaml. - SubPath string `json:"sub-path"` + SubPath string `json:"subPath"` } // Repository is a tuple that holds the information for the remote sources of manifest yaml documents. @@ -150,13 +140,13 @@ type RepoAuth struct { // supported types are "ssh-key", "ssh-pass", "http-basic" Type string `json:"type,omitempty"` //KeyPassword is a password decrypt ssh private key (used with ssh-key auth type) - KeyPassword string `json:"key-pass,omitempty"` + KeyPassword string `json:"keyPass,omitempty"` // KeyPath is path to private ssh key on disk (used with ssh-key auth type) - KeyPath string `json:"ssh-key,omitempty"` + KeyPath string `json:"sshKey,omitempty"` //HTTPPassword is password for basic http authentication (used with http-basic auth type) - HTTPPassword string `json:"http-pass,omitempty"` + HTTPPassword string `json:"httpPass,omitempty"` // SSHPassword is password for ssh password authentication (used with ssh-pass) - SSHPassword string `json:"ssh-pass,omitempty"` + SSHPassword string `json:"sshPass,omitempty"` // Username to authenticate against git remote (used with any type) Username string `json:"username,omitempty"` } @@ -165,7 +155,7 @@ type RepoAuth struct { // Each field is mutually exclusive type RepoCheckout struct { // CommitHash is full hash of the commit that will be used to checkout - CommitHash string `json:"commit-hash,omitempty"` + CommitHash string `json:"commitHash,omitempty"` // Branch is the branch name to checkout Branch string `json:"branch"` // Tag is the tag name to checkout @@ -174,7 +164,7 @@ type RepoCheckout struct { // RemoteRef is used for remote checkouts such as gerrit change requests/github pull request // for example refs/changes/04/691202/5 // TODO Add support for fetching remote refs - RemoteRef string `json:"remote-ref"` + RemoteRef string `json:"remoteRef"` // ForceCheckout is a boolean to indicate whether to use the `--force` option when checking out ForceCheckout bool `json:"force"` } diff --git a/pkg/config/utils.go b/pkg/config/utils.go index a57720a67..23c0ebc8c 100644 --- a/pkg/config/utils.go +++ b/pkg/config/utils.go @@ -27,8 +27,26 @@ func NewConfig() *Config { return &Config{ Kind: AirshipConfigKind, APIVersion: AirshipConfigAPIVersion, - Clusters: make(map[string]*ClusterPurpose), - AuthInfos: make(map[string]*AuthInfo), + BootstrapInfo: map[string]*Bootstrap{ + AirshipDefaultContext: { + Container: &Container{ + Volume: "/srv/iso:/config", + Image: AirshipDefaultBootstrapImage, + ContainerRuntime: "docker", + }, + Builder: &Builder{ + UserDataFileName: "user-data", + NetworkConfigFileName: "network-config", + OutputMetadataFileName: "output-metadata.yaml", + }, + RemoteDirect: &RemoteDirect{ + RemoteType: AirshipDefaultRemoteType, + IsoURL: AirshipDefaultIsoURL, + }, + }, + }, + Clusters: make(map[string]*ClusterPurpose), + AuthInfos: make(map[string]*AuthInfo), Contexts: map[string]*Context{ AirshipDefaultContext: { Manifest: AirshipDefaultManifest, @@ -51,26 +69,6 @@ func NewConfig() *Config { SubPath: AirshipDefaultManifestRepo + "/manifests/site", }, }, - ModulesConfig: &Modules{ - BootstrapInfo: map[string]*Bootstrap{ - AirshipDefaultContext: { - Container: &Container{ - Volume: "/srv/iso:/config", - Image: AirshipDefaultBootstrapImage, - ContainerRuntime: "docker", - }, - Builder: &Builder{ - UserDataFileName: "user-data", - NetworkConfigFileName: "network-config", - OutputMetadataFileName: "output-metadata.yaml", - }, - RemoteDirect: &RemoteDirect{ - RemoteType: AirshipDefaultRemoteType, - IsoURL: AirshipDefaultIsoURL, - }, - }, - }, - }, } } @@ -101,12 +99,6 @@ func NewAuthInfo() *AuthInfo { return &AuthInfo{} } -func NewModules() *Modules { - return &Modules{ - BootstrapInfo: make(map[string]*Bootstrap), - } -} - // NewClusterPurpose is a convenience function that returns a new ClusterPurpose func NewClusterPurpose() *ClusterPurpose { return &ClusterPurpose{ diff --git a/roles/airshipctl-test-configs/templates/airshipconfig.j2 b/roles/airshipctl-test-configs/templates/airshipconfig.j2 index 3523ee44d..bba8aedfc 100644 --- a/roles/airshipctl-test-configs/templates/airshipconfig.j2 +++ b/roles/airshipctl-test-configs/templates/airshipconfig.j2 @@ -1,47 +1,46 @@ apiVersion: airshipit.org/v1alpha1 +bootstrapInfo: + dummy_bootstrap_config: + container: + volume: {{ airship_config_iso_gen_target_path }}:/config + image: {{ airship_config_iso_builder_docker_image }} + containerRuntime: docker + remoteDirect: + remoteType: {{ remote_type }} + insecure: {{ remote_insecure }} + useproxy: {{ remote_proxy }} + isoUrl: http://{{ airship_config_iso_serve_host }}:{{ airship_config_iso_port }}/{{ airship_config_iso_name }} + builder: + userDataFileName: user-data + networkConfigFileName: network-config + outputMetadataFileName: output-metadata.yaml clusters: dummycluster: - cluster-type: + clusterType: ephemeral: - bootstrap-info: dummy_bootstrap_config - cluster-kubeconf: dummycluster_ephemeral + bootstrapInfo: dummy_bootstrap_config + clusterKubeconf: dummycluster_ephemeral contexts: dummy_cluster: - context-kubeconf: dummy_cluster + contextKubeconf: dummy_cluster manifest: dummy_manifest -current-context: dummy_cluster +currentContext: dummy_cluster kind: Config manifests: dummy_manifest: - primary-repository-name: primary + primaryRepositoryName: primary repositories: primary: checkout: branch: "master" force: false - remote-ref: "" + remoteRef: "" tag: "" url: {{ airship_config_primary_repo_url }} ## this is temporary hack, as soon as we use `document pull` command in gate process ## this will subpath will be airshipctl/manifests/site/test-bootstrap, as airshipctl ## will be primary repository - sub-path: {{ airship_site_name }} - target-path: {{ airship_config_manifest_directory }} -modules-config: - bootstrapInfo: - dummy_bootstrap_config: - container: - volume: {{ airship_config_iso_gen_target_path }}:/config - image: {{ airship_config_iso_builder_docker_image }} - containerRuntime: docker - remoteDirect: - remoteType: {{ remote_type }} - insecure: {{ remote_insecure }} - useproxy: {{ remote_proxy }} - isoUrl: http://{{ airship_config_iso_serve_host }}:{{ airship_config_iso_port }}/{{ airship_config_iso_name }} - builder: - userDataFileName: user-data - networkConfigFileName: network-config - outputMetadataFileName: output-metadata.yaml + subPath: {{ airship_site_name }} + targetPath: {{ airship_config_manifest_directory }} users: dummy_user: {} diff --git a/testdata/k8s/config.yaml b/testdata/k8s/config.yaml index 78aace764..c7a6119c1 100644 --- a/testdata/k8s/config.yaml +++ b/testdata/k8s/config.yaml @@ -1,42 +1,41 @@ apiVersion: airshipit.org/v1alpha1 +bootstrapInfo: + default: + builder: + networkConfigFileName: network-config + outputMetadataFileName: output-metadata.yaml + userDataFileName: user-data + container: + containerRuntime: docker + image: quay.io/airshipit/isogen:latest + volume: /srv/iso:/config + remoteDirect: + isoUrl: http://localhost:8099/debian-custom.iso + remoteType: redfish clusters: default: - cluster-type: + clusterType: target: - bootstrap-info: "" - cluster-kubeconf: default_target + bootstrapInfo: "" + clusterKubeconf: default_target kubernetes: - cluster-type: {} + clusterType: {} contexts: default: - context-kubeconf: default_target + contextKubeconf: default_target manifest: default -current-context: "" +currentContext: "" kind: Config manifests: default: repository: checkout: branch: master - commit-hash: master + commitHash: master force: false - remote-ref: master + remoteRef: master tag: "" url: https://opendev.org/airship/treasuremap - target-path: /tmp/default -modules-config: - bootstrapInfo: - default: - builder: - networkConfigFileName: network-config - outputMetadataFileName: output-metadata.yaml - userDataFileName: user-data - container: - containerRuntime: docker - image: quay.io/airshipit/isogen:latest - volume: /srv/iso:/config - remoteDirect: - isoUrl: http://localhost:8099/debian-custom.iso - remoteType: redfish + targetPath: /tmp/default users: admin: {} diff --git a/testutil/testconfig.go b/testutil/testconfig.go index a3d2f4794..19795626e 100644 --- a/testutil/testconfig.go +++ b/testutil/testconfig.go @@ -47,7 +47,9 @@ func DummyConfig() *config.Config { Manifests: map[string]*config.Manifest{ "dummy_manifest": DummyManifest(), }, - ModulesConfig: DummyModules(), + BootstrapInfo: map[string]*config.Bootstrap{ + "dummy_bootstrap_config": DummyBootstrapInfo(), + }, CurrentContext: "dummy_context", } conf.SetKubeConfig(kubeconfig.NewConfig()) @@ -154,13 +156,6 @@ func DummyKubeAuthInfo() *kubeconfig.AuthInfo { return authinfo } -// DummyModules returns Modules config objects for unit testing -func DummyModules() *config.Modules { - m := config.NewModules() - m.BootstrapInfo["dummy_bootstrap_config"] = DummyBootstrap() - return m -} - // DummyClusterPurpose creates ClusterPurpose config object for unit testing func DummyClusterPurpose() *config.ClusterPurpose { cp := config.NewClusterPurpose() @@ -234,8 +229,7 @@ func DummyAuthInfoOptions() *config.AuthInfoOptions { return authinfo } -// DummyBootstrap creates Bootstrap config object for unit testing -func DummyBootstrap() *config.Bootstrap { +func DummyBootstrapInfo() *config.Bootstrap { bs := &config.Bootstrap{} cont := config.Container{ Volume: "/dummy:dummy", @@ -256,43 +250,43 @@ func DummyBootstrap() *config.Bootstrap { const ( testConfigYAML = `apiVersion: airshipit.org/v1alpha1 +bootstrapInfo: + default: {} clusters: straggler: - cluster-type: + clusterType: ephemeral: - cluster-kubeconf: notThere + clusterKubeconf: notThere def: - cluster-type: + clusterType: ephemeral: - bootstrap-info: "" - cluster-kubeconf: def_ephemeral + bootstrapInfo: "" + clusterKubeconf: def_ephemeral target: - bootstrap-info: "" - cluster-kubeconf: def_target + bootstrapInfo: "" + clusterKubeconf: def_target onlyinkubeconf: - cluster-type: + clusterType: target: - bootstrap-info: "" - cluster-kubeconf: onlyinkubeconf_target + bootstrapInfo: "" + clusterKubeconf: onlyinkubeconf_target wrongonlyinconfig: - cluster-type: {} + clusterType: {} wrongonlyinkubeconf: - cluster-type: + clusterType: target: - bootstrap-info: "" - cluster-kubeconf: wrongonlyinkubeconf_target + bootstrapInfo: "" + clusterKubeconf: wrongonlyinkubeconf_target contexts: def_ephemeral: - context-kubeconf: def_ephemeral + contextKubeconf: def_ephemeral def_target: - context-kubeconf: def_target + contextKubeconf: def_target onlyink: - context-kubeconf: onlyinkubeconf_target -current-context: "" + contextKubeconf: onlyinkubeconf_target +currentContext: "" kind: Config manifests: {} -modules-config: - dummy-for-tests: "" users: k-admin: {} k-other: {}