diff --git a/.gitignore b/.gitignore index 368aae7..2ee9527 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ *.dll *.so *.dylib +*.swp .idea diff --git a/internal/env/config.go b/internal/env/config.go index 6751be9..4cd5471 100644 --- a/internal/env/config.go +++ b/internal/env/config.go @@ -33,6 +33,7 @@ type Config struct { StringValues string `split_words:"true"` // Argument to pass to --set-string in applicable helm commands ValuesFiles []string `split_words:"true"` // Arguments to pass to --values in applicable helm commands Namespace string `` // Kubernetes namespace for all helm commands + KubeInitSkip bool `envconfig:"kube_init_skip"` // Skip kubeconfig creation KubeToken string `split_words:"true"` // Kubernetes authentication token to put in .kube/config SkipTLSVerify bool `envconfig:"skip_tls_verify"` // Put insecure-skip-tls-verify in .kube/config Certificate string `envconfig:"kube_certificate"` // The Kubernetes cluster CA's self-signed certificate (must be base64-encoded) diff --git a/internal/helm/plan.go b/internal/helm/plan.go index 4f62162..50cb17b 100644 --- a/internal/helm/plan.go +++ b/internal/helm/plan.go @@ -92,7 +92,9 @@ func (p *Plan) Execute() error { var upgrade = func(cfg env.Config) []Step { var steps []Step - steps = append(steps, run.NewInitKube(cfg, kubeConfigTemplate, kubeConfigFile)) + if !cfg.KubeInitSkip { + steps = append(steps, run.NewInitKube(cfg, kubeConfigTemplate, kubeConfigFile)) + } for _, repo := range cfg.AddRepos { steps = append(steps, run.NewAddRepo(cfg, repo)) } @@ -112,7 +114,9 @@ var upgrade = func(cfg env.Config) []Step { var uninstall = func(cfg env.Config) []Step { var steps []Step - steps = append(steps, run.NewInitKube(cfg, kubeConfigTemplate, kubeConfigFile)) + if !cfg.KubeInitSkip { + steps = append(steps, run.NewInitKube(cfg, kubeConfigTemplate, kubeConfigFile)) + } if cfg.UpdateDependencies { steps = append(steps, run.NewDepUpdate(cfg)) } diff --git a/internal/helm/plan_test.go b/internal/helm/plan_test.go index 77e913c..3f8a9a3 100644 --- a/internal/helm/plan_test.go +++ b/internal/helm/plan_test.go @@ -122,6 +122,12 @@ func (suite *PlanTestSuite) TestUpgrade() { suite.IsType(&run.Upgrade{}, steps[1]) } +func (suite *PlanTestSuite) TestUpgradeWithKubeInitSkip() { + steps := upgrade(env.Config{KubeInitSkip: true}) + suite.Require().Equal(1, len(steps), "upgrade should return 1 step") + suite.IsType(&run.Upgrade{}, steps[0]) +} + func (suite *PlanTestSuite) TestUpgradeWithUpdateDependencies() { cfg := env.Config{ UpdateDependencies: true,