From b0d171d0ec6db95f49901779ef0b4e125b375587 Mon Sep 17 00:00:00 2001 From: Vladimir Kozhukalov Date: Wed, 16 Dec 2020 17:37:52 +0300 Subject: [PATCH] Remove unnecessary constants Change-Id: Ib54ce13e552efb4ac8efe00c18956ed65b46d564 --- cmd/config/get_context_test.go | 2 +- .../get-all-contexts.golden | 6 +++--- .../TestGetContextCmdGoldenOutput/get-context.golden | 2 +- .../get-current-context.golden | 2 +- .../get-multiple-contexts.golden | 6 +++--- pkg/config/constants.go | 10 ++++++---- pkg/k8s/kubectl/kubectl.go | 3 ++- 7 files changed, 17 insertions(+), 14 deletions(-) diff --git a/cmd/config/get_context_test.go b/cmd/config/get_context_test.go index 3b608d5e8..28ce64918 100644 --- a/cmd/config/get_context_test.go +++ b/cmd/config/get_context_test.go @@ -91,7 +91,7 @@ func TestNoContextsGetContextCmd(t *testing.T) { func getNamedTestContext(contextName string) *config.Context { newContext := &config.Context{ - NameInKubeconf: fmt.Sprintf("%s_%s", contextName, config.Ephemeral), + NameInKubeconf: contextName, Manifest: fmt.Sprintf("Manifest_%s", contextName), } diff --git a/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-all-contexts.golden b/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-all-contexts.golden index 1b9bd3d8f..e5ca803f3 100644 --- a/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-all-contexts.golden +++ b/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-all-contexts.golden @@ -1,12 +1,12 @@ -contextKubeconf: ContextBar_ephemeral +contextKubeconf: ContextBar managementConfiguration: "" manifest: Manifest_ContextBar -contextKubeconf: ContextBaz_ephemeral +contextKubeconf: ContextBaz managementConfiguration: "" manifest: Manifest_ContextBaz -contextKubeconf: ContextFoo_ephemeral +contextKubeconf: ContextFoo managementConfiguration: "" manifest: Manifest_ContextFoo diff --git a/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-context.golden b/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-context.golden index eb4c50474..dcb24aadd 100644 --- a/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-context.golden +++ b/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-context.golden @@ -1,4 +1,4 @@ -contextKubeconf: ContextFoo_ephemeral +contextKubeconf: ContextFoo managementConfiguration: "" manifest: Manifest_ContextFoo diff --git a/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-current-context.golden b/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-current-context.golden index 85adf307a..d95b36d79 100644 --- a/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-current-context.golden +++ b/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-current-context.golden @@ -1,4 +1,4 @@ -contextKubeconf: ContextBaz_ephemeral +contextKubeconf: ContextBaz managementConfiguration: "" manifest: Manifest_ContextBaz diff --git a/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-multiple-contexts.golden b/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-multiple-contexts.golden index 1b9bd3d8f..e5ca803f3 100644 --- a/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-multiple-contexts.golden +++ b/cmd/config/testdata/TestGetContextCmdGoldenOutput/get-multiple-contexts.golden @@ -1,12 +1,12 @@ -contextKubeconf: ContextBar_ephemeral +contextKubeconf: ContextBar managementConfiguration: "" manifest: Manifest_ContextBar -contextKubeconf: ContextBaz_ephemeral +contextKubeconf: ContextBaz managementConfiguration: "" manifest: Manifest_ContextBaz -contextKubeconf: ContextFoo_ephemeral +contextKubeconf: ContextFoo managementConfiguration: "" manifest: Manifest_ContextFoo diff --git a/pkg/config/constants.go b/pkg/config/constants.go index 2621dee01..4ce93f1c1 100644 --- a/pkg/config/constants.go +++ b/pkg/config/constants.go @@ -18,10 +18,7 @@ import "opendev.org/airship/airshipctl/pkg/remote/redfish" // Constants related to Phases const ( - Ephemeral = "ephemeral" - InitinfraPhase = "initinfra" - ClusterctlPhase = InitinfraPhase - BootstrapPhase = "bootstrap-iso" + BootstrapPhase = "bootstrap-iso" ) // Constants defining default values @@ -63,3 +60,8 @@ const ( // DefaultManifestMetadataFile default path to manifest metadata file DefaultManifestMetadataFile = "manifests/site/test-site/metadata.yaml" ) + +// Default values for auxiliary parameters +const ( + KubectlTempFilePrefix = "initinfra" +) diff --git a/pkg/k8s/kubectl/kubectl.go b/pkg/k8s/kubectl/kubectl.go index 7311a7199..75e22c24e 100644 --- a/pkg/k8s/kubectl/kubectl.go +++ b/pkg/k8s/kubectl/kubectl.go @@ -21,6 +21,7 @@ import ( "k8s.io/cli-runtime/pkg/genericclioptions" cmdutil "k8s.io/kubectl/pkg/cmd/util" + "opendev.org/airship/airshipctl/pkg/config" "opendev.org/airship/airshipctl/pkg/document" "opendev.org/airship/airshipctl/pkg/fs" "opendev.org/airship/airshipctl/pkg/log" @@ -73,7 +74,7 @@ func (kubectl *Kubectl) ApplyDocs(docs []document.Document, ao *ApplyOptions) er // ApplyYaml is abstraction to kubectl apply command func (kubectl *Kubectl) ApplyYaml(yaml []byte, ao *ApplyOptions) error { - tf, err := kubectl.TempFile(kubectl.bufferDir, "initinfra") + tf, err := kubectl.TempFile(kubectl.bufferDir, config.KubectlTempFilePrefix) if err != nil { return err }