Rename kube_init_skip to skip_kubeconfig

This commit is contained in:
minhdanh
2020-08-25 09:59:06 +07:00
parent 0e58dde591
commit 5b4e3ab2ea
4 changed files with 23 additions and 15 deletions

View File

@@ -33,8 +33,8 @@ 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
SkipKubeconfig bool `envconfig:"skip_kubeconfig"` // Skip kubeconfig creation
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)
APIServer string `envconfig:"kube_api_server"` // The Kubernetes cluster's API endpoint
@@ -88,6 +88,12 @@ func NewConfig(stdout, stderr io.Writer) (*Config, error) {
return nil, err
}
if cfg.SkipKubeconfig {
if cfg.KubeToken != "" || cfg.Certificate != "" || cfg.APIServer != "" || cfg.ServiceAccount != "" || cfg.SkipTLSVerify {
fmt.Fprintf(cfg.Stderr, "Warning: skip_kubeconfig is set. The following kubeconfig-related settings will be ignored: kube_config, kube_certificate, kube_api_server, kube_service_account, skip_tls_verify.")
}
}
if justNumbers.MatchString(cfg.Timeout) {
cfg.Timeout = fmt.Sprintf("%ss", cfg.Timeout)
}

View File

@@ -92,7 +92,7 @@ func (p *Plan) Execute() error {
var upgrade = func(cfg env.Config) []Step {
var steps []Step
if !cfg.KubeInitSkip {
if !cfg.SkipKubeconfig {
steps = append(steps, run.NewInitKube(cfg, kubeConfigTemplate, kubeConfigFile))
}
for _, repo := range cfg.AddRepos {
@@ -114,7 +114,7 @@ var upgrade = func(cfg env.Config) []Step {
var uninstall = func(cfg env.Config) []Step {
var steps []Step
if !cfg.KubeInitSkip {
if !cfg.SkipKubeconfig {
steps = append(steps, run.NewInitKube(cfg, kubeConfigTemplate, kubeConfigFile))
}
if cfg.UpdateDependencies {

View File

@@ -122,8 +122,8 @@ func (suite *PlanTestSuite) TestUpgrade() {
suite.IsType(&run.Upgrade{}, steps[1])
}
func (suite *PlanTestSuite) TestUpgradeWithKubeInitSkip() {
steps := upgrade(env.Config{KubeInitSkip: true})
func (suite *PlanTestSuite) TestUpgradeWithSkipKubeconfig() {
steps := upgrade(env.Config{SkipKubeconfig: true})
suite.Require().Equal(1, len(steps), "upgrade should return 1 step")
suite.IsType(&run.Upgrade{}, steps[0])
}