Support skipping kubeconfig creation

This commit is contained in:
minhdanh 2020-08-21 15:30:22 +07:00
parent 03b066bfd7
commit 0e58dde591
4 changed files with 14 additions and 2 deletions

1
.gitignore vendored
View file

@ -4,6 +4,7 @@
*.dll *.dll
*.so *.so
*.dylib *.dylib
*.swp
.idea .idea

View file

@ -33,6 +33,7 @@ type Config struct {
StringValues string `split_words:"true"` // Argument to pass to --set-string in applicable helm commands 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 ValuesFiles []string `split_words:"true"` // Arguments to pass to --values in applicable helm commands
Namespace string `` // Kubernetes namespace for all 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 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 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) Certificate string `envconfig:"kube_certificate"` // The Kubernetes cluster CA's self-signed certificate (must be base64-encoded)

View file

@ -92,7 +92,9 @@ func (p *Plan) Execute() error {
var upgrade = func(cfg env.Config) []Step { var upgrade = func(cfg env.Config) []Step {
var steps []Step var steps []Step
if !cfg.KubeInitSkip {
steps = append(steps, run.NewInitKube(cfg, kubeConfigTemplate, kubeConfigFile)) steps = append(steps, run.NewInitKube(cfg, kubeConfigTemplate, kubeConfigFile))
}
for _, repo := range cfg.AddRepos { for _, repo := range cfg.AddRepos {
steps = append(steps, run.NewAddRepo(cfg, repo)) 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 uninstall = func(cfg env.Config) []Step {
var steps []Step var steps []Step
if !cfg.KubeInitSkip {
steps = append(steps, run.NewInitKube(cfg, kubeConfigTemplate, kubeConfigFile)) steps = append(steps, run.NewInitKube(cfg, kubeConfigTemplate, kubeConfigFile))
}
if cfg.UpdateDependencies { if cfg.UpdateDependencies {
steps = append(steps, run.NewDepUpdate(cfg)) steps = append(steps, run.NewDepUpdate(cfg))
} }

View file

@ -122,6 +122,12 @@ func (suite *PlanTestSuite) TestUpgrade() {
suite.IsType(&run.Upgrade{}, steps[1]) 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() { func (suite *PlanTestSuite) TestUpgradeWithUpdateDependencies() {
cfg := env.Config{ cfg := env.Config{
UpdateDependencies: true, UpdateDependencies: true,