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.
This commit is contained in:
parent
04de280821
commit
1d1117ba49
|
@ -87,6 +87,12 @@ func NewConfig(stdout, stderr io.Writer) (*Config, error) {
|
||||||
if aliases.Force != nil {
|
if aliases.Force != nil {
|
||||||
cfg.Force = *aliases.Force
|
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) {
|
if justNumbers.MatchString(cfg.Timeout) {
|
||||||
cfg.Timeout = fmt.Sprintf("%ss", cfg.Timeout)
|
cfg.Timeout = fmt.Sprintf("%ss", cfg.Timeout)
|
||||||
|
@ -121,8 +127,10 @@ func (cfg *Config) deprecationWarn() {
|
||||||
type settingAliases struct {
|
type settingAliases struct {
|
||||||
Command *string `envconfig:"mode"`
|
Command *string `envconfig:"mode"`
|
||||||
AddRepos *[]string `envconfig:"add_repos"`
|
AddRepos *[]string `envconfig:"add_repos"`
|
||||||
APIServer *string `envconfig:"kubernetes_api_server"`
|
APIServer *string `envconfig:"kube_api_server"`
|
||||||
ServiceAccount *string `envconfig:"kubernetes_service_account"`
|
ServiceAccount *string `envconfig:"kube_service_account"`
|
||||||
Wait *bool `envconfig:"wait_for_upgrade"`
|
Wait *bool `envconfig:"wait_for_upgrade"`
|
||||||
Force *bool `envconfig:"force_upgrade"`
|
Force *bool `envconfig:"force_upgrade"`
|
||||||
|
KubeToken *string `envconfig:"kube_token"`
|
||||||
|
Certificate *string `envconfig:"kube_certificate"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -78,16 +78,20 @@ func (suite *ConfigTestSuite) TestNewConfigWithAliases() {
|
||||||
"SERVICE_ACCOUNT",
|
"SERVICE_ACCOUNT",
|
||||||
"WAIT",
|
"WAIT",
|
||||||
"FORCE",
|
"FORCE",
|
||||||
|
"KUBERNETES_TOKEN",
|
||||||
|
"KUBERNETES_CERTIFICATE",
|
||||||
} {
|
} {
|
||||||
suite.unsetenv(varname)
|
suite.unsetenv(varname)
|
||||||
suite.unsetenv("PLUGIN_" + varname)
|
suite.unsetenv("PLUGIN_" + varname)
|
||||||
}
|
}
|
||||||
suite.setenv("PLUGIN_MODE", "iambic")
|
suite.setenv("PLUGIN_MODE", "iambic")
|
||||||
suite.setenv("PLUGIN_ADD_REPOS", "chortle=http://calloo.callay/frabjous/day")
|
suite.setenv("PLUGIN_ADD_REPOS", "chortle=http://calloo.callay/frabjous/day")
|
||||||
suite.setenv("PLUGIN_KUBERNETES_API_SERVER", "http://tumtum.tree")
|
suite.setenv("PLUGIN_KUBE_API_SERVER", "http://tumtum.tree")
|
||||||
suite.setenv("PLUGIN_KUBERNETES_SERVICE_ACCOUNT", "tulgey")
|
suite.setenv("PLUGIN_KUBE_SERVICE_ACCOUNT", "tulgey")
|
||||||
suite.setenv("PLUGIN_WAIT_FOR_UPGRADE", "true")
|
suite.setenv("PLUGIN_WAIT_FOR_UPGRADE", "true")
|
||||||
suite.setenv("PLUGIN_FORCE_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{})
|
cfg, err := NewConfig(&strings.Builder{}, &strings.Builder{})
|
||||||
suite.Require().NoError(err)
|
suite.Require().NoError(err)
|
||||||
|
@ -97,6 +101,8 @@ func (suite *ConfigTestSuite) TestNewConfigWithAliases() {
|
||||||
suite.Equal("tulgey", cfg.ServiceAccount)
|
suite.Equal("tulgey", cfg.ServiceAccount)
|
||||||
suite.True(cfg.Wait, "Wait should be aliased")
|
suite.True(cfg.Wait, "Wait should be aliased")
|
||||||
suite.True(cfg.Force, "Force 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() {
|
func (suite *ConfigTestSuite) TestNewConfigSetsWriters() {
|
||||||
|
|
Loading…
Reference in a new issue