From 1d1117ba4981cace9fd76a6d9d6df83560e9d962 Mon Sep 17 00:00:00 2001 From: Erin Call Date: Tue, 7 Jan 2020 15:39:05 -0800 Subject: [PATCH] Use "kube" in setting aliases [#66] Nobody likes typing "kubernetes"! Writing out that whole word without typos is the third hard problem in computer science. --- internal/helm/config.go | 12 ++++++++++-- internal/helm/config_test.go | 10 ++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/internal/helm/config.go b/internal/helm/config.go index 2eda281..3f5991c 100644 --- a/internal/helm/config.go +++ b/internal/helm/config.go @@ -87,6 +87,12 @@ func NewConfig(stdout, stderr io.Writer) (*Config, error) { if aliases.Force != nil { cfg.Force = *aliases.Force } + if aliases.KubeToken != nil { + cfg.KubeToken = *aliases.KubeToken + } + if aliases.Certificate != nil { + cfg.Certificate = *aliases.Certificate + } if justNumbers.MatchString(cfg.Timeout) { cfg.Timeout = fmt.Sprintf("%ss", cfg.Timeout) @@ -121,8 +127,10 @@ func (cfg *Config) deprecationWarn() { type settingAliases struct { Command *string `envconfig:"mode"` AddRepos *[]string `envconfig:"add_repos"` - APIServer *string `envconfig:"kubernetes_api_server"` - ServiceAccount *string `envconfig:"kubernetes_service_account"` + APIServer *string `envconfig:"kube_api_server"` + ServiceAccount *string `envconfig:"kube_service_account"` Wait *bool `envconfig:"wait_for_upgrade"` Force *bool `envconfig:"force_upgrade"` + KubeToken *string `envconfig:"kube_token"` + Certificate *string `envconfig:"kube_certificate"` } diff --git a/internal/helm/config_test.go b/internal/helm/config_test.go index cb4c3ee..70ce91a 100644 --- a/internal/helm/config_test.go +++ b/internal/helm/config_test.go @@ -78,16 +78,20 @@ func (suite *ConfigTestSuite) TestNewConfigWithAliases() { "SERVICE_ACCOUNT", "WAIT", "FORCE", + "KUBERNETES_TOKEN", + "KUBERNETES_CERTIFICATE", } { suite.unsetenv(varname) suite.unsetenv("PLUGIN_" + varname) } suite.setenv("PLUGIN_MODE", "iambic") suite.setenv("PLUGIN_ADD_REPOS", "chortle=http://calloo.callay/frabjous/day") - suite.setenv("PLUGIN_KUBERNETES_API_SERVER", "http://tumtum.tree") - suite.setenv("PLUGIN_KUBERNETES_SERVICE_ACCOUNT", "tulgey") + suite.setenv("PLUGIN_KUBE_API_SERVER", "http://tumtum.tree") + suite.setenv("PLUGIN_KUBE_SERVICE_ACCOUNT", "tulgey") suite.setenv("PLUGIN_WAIT_FOR_UPGRADE", "true") suite.setenv("PLUGIN_FORCE_UPGRADE", "true") + suite.setenv("PLUGIN_KUBE_TOKEN", "Y29tZSB0byBteSBhcm1z") + suite.setenv("PLUGIN_KUBE_CERTIFICATE", "d2l0aCBpdHMgaGVhZA==") cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{}) suite.Require().NoError(err) @@ -97,6 +101,8 @@ func (suite *ConfigTestSuite) TestNewConfigWithAliases() { suite.Equal("tulgey", cfg.ServiceAccount) suite.True(cfg.Wait, "Wait should be aliased") suite.True(cfg.Force, "Force should be aliased") + suite.Equal("Y29tZSB0byBteSBhcm1z", cfg.KubeToken, "KubeToken should be aliased") + suite.Equal("d2l0aCBpdHMgaGVhZA==", cfg.Certificate, "Certificate should be aliased") } func (suite *ConfigTestSuite) TestNewConfigSetsWriters() {