Fix: check if addon is enabled before doing validation
Signed-off-by: Pablo Caderno <kaderno@gmail.com>pull/16139/head
parent
56c99ef91b
commit
5c261e80e9
|
@ -42,22 +42,20 @@ var addonsDisableCmd = &cobra.Command{
|
|||
}
|
||||
cc, err := config.Load(ClusterFlagValue())
|
||||
if err != nil {
|
||||
exit.Error(reason.InternalAddonDisable, "loading profile", err)
|
||||
exit.Error(reason.InternalConfigView, "loading profile", err)
|
||||
}
|
||||
validAddon, ok := assets.Addons[addon]
|
||||
if ok {
|
||||
if validAddon.IsEnabled(cc) {
|
||||
err := addons.SetAndSave(ClusterFlagValue(), addon, "false")
|
||||
if err != nil {
|
||||
exit.Error(reason.InternalAddonDisable, "disable failed", err)
|
||||
}
|
||||
} else {
|
||||
out.Step(style.AddonDisable, `"The '{{.minikube_addon}}' addon is disabled`, out.V{"minikube_addon": addon})
|
||||
}
|
||||
|
||||
} else {
|
||||
out.Step(style.AddonDisable, `"The '{{.minikube_addon}}' seems not to be a valid minikube addon`, out.V{"minikube_addon": addon})
|
||||
if !ok {
|
||||
exit.Message(reason.InternalAddonDisable, `"'{{.minikube_addon}}' is not a valid minikube addon`, out.V{"minikube_addon": addon})
|
||||
}
|
||||
if validAddon.IsEnabled(cc) {
|
||||
err := addons.SetAndSave(ClusterFlagValue(), addon, "false")
|
||||
if err != nil {
|
||||
exit.Error(reason.InternalAddonDisable, "disable failed", err)
|
||||
}
|
||||
}
|
||||
out.Styled(style.AddonDisable, `"The '{{.minikube_addon}}' addon is disabled`, out.V{"minikube_addon": addon})
|
||||
},
|
||||
}
|
||||
|
||||
|
|
|
@ -156,6 +156,11 @@ func TestAddons(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Errorf("failed to disable dashboard addon: args %q : %v", rr.Command(), err)
|
||||
}
|
||||
// Disable a non-enabled addon
|
||||
rr, err = Run(t, exec.CommandContext(ctx, Target(), "addons", "disable", "gvisor", "-p", profile))
|
||||
if err != nil {
|
||||
t.Errorf("failed to disable non-enabled addon: args %q : %v", rr.Command(), err)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"\n\n": "",
|
||||
"\"'{{.minikube_addon}}' is not a valid minikube addon": "",
|
||||
"\"The '{{.minikube_addon}}' addon is disabled": "Das {{.minikube_addon}} Addon ist deaktiviert",
|
||||
"\"minikube cache\" will be deprecated in upcoming versions, please switch to \"minikube image load\"": "\"minikube cache\" wird in der nächsten Version veraltet (deprecated) sein, bitte wechsle zu \"minikube image load\"",
|
||||
"\"{{.context}}\" context has been updated to point to {{.hostname}}:{{.port}}": "Der Kontext \"{{.context}}\" wurde aktualisiert, um auf {{.hostname}}:{{.port}} zu zeigen",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"\n\n": "",
|
||||
"\"'{{.minikube_addon}}' is not a valid minikube addon": "",
|
||||
"\"The '{{.minikube_addon}}' addon is disabled": "El complemento \"{{.minikube_addon}}\" está desactivado",
|
||||
"\"minikube cache\" will be deprecated in upcoming versions, please switch to \"minikube image load\"": "",
|
||||
"\"{{.context}}\" context has been updated to point to {{.hostname}}:{{.port}}": "El contexto \"{{.context}}\" ha sido actualizado para apuntar a {{.hostname}}:{{.port}}",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"\n\n": "",
|
||||
"\"'{{.minikube_addon}}' is not a valid minikube addon": "",
|
||||
"\"The '{{.minikube_addon}}' addon is disabled": "Le module \"{{.minikube_addon}}\" est désactivé",
|
||||
"\"minikube cache\" will be deprecated in upcoming versions, please switch to \"minikube image load\"": "\"minikube cache\" sera obsolète dans les prochaines versions, veuillez passer à \"minikube image load\"",
|
||||
"\"{{.context}}\" context has been updated to point to {{.hostname}}:{{.port}}": "Le contexte \"{{.context}}\" a été mis à jour pour pointer vers {{.hostname}}:{{.port}}",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"\n\n": "",
|
||||
"\"'{{.minikube_addon}}' is not a valid minikube addon": "",
|
||||
"\"The '{{.minikube_addon}}' addon is disabled": "'{{.minikube_addon}}' アドオンが無効です",
|
||||
"\"minikube cache\" will be deprecated in upcoming versions, please switch to \"minikube image load\"": "「minikube cache」は今後のバージョンで廃止予定になりますので、「minikube image load」に切り替えてください",
|
||||
"\"{{.context}}\" context has been updated to point to {{.hostname}}:{{.port}}": "「{{.context}}」コンテキストが更新されて、{{.hostname}}:{{.port}} を指すようになりました",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"\n\n": "",
|
||||
"\"'{{.minikube_addon}}' is not a valid minikube addon": "",
|
||||
"\"The '{{.minikube_addon}}' addon is disabled": "\"The '{{.minikube_addon}}' 이 비활성화되었습니다",
|
||||
"\"minikube cache\" will be deprecated in upcoming versions, please switch to \"minikube image load\"": "\"minikube cache\"는 추후 버전에서 사용 중단됩니다. \"minikube image load\"로 전환하십시오",
|
||||
"\"{{.context}}\" context has been updated to point to {{.hostname}}:{{.port}}": "\"{{.context}}\" 컨텍스트가 {{.hostname}}:{{.port}}로 갱신되었습니다.",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"\n\n": "",
|
||||
"\"'{{.minikube_addon}}' is not a valid minikube addon": "",
|
||||
"\"The '{{.minikube_addon}}' addon is disabled": "",
|
||||
"\"minikube cache\" will be deprecated in upcoming versions, please switch to \"minikube image load\"": "",
|
||||
"\"{{.context}}\" context has been updated to point to {{.hostname}}:{{.port}}": "",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"\n\n": "",
|
||||
"\"'{{.minikube_addon}}' is not a valid minikube addon": "",
|
||||
"\"The '{{.minikube_addon}}' addon is disabled": "\"Дополнение '{{.minikube_addon}}' выключено",
|
||||
"\"minikube cache\" will be deprecated in upcoming versions, please switch to \"minikube image load\"": "",
|
||||
"\"{{.context}}\" context has been updated to point to {{.hostname}}:{{.port}}": "Контекст \"{{.context}}\" был обновлён и теперь указывает на {{.hostname}}:{{.port}}",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"\n\n": "",
|
||||
"\"'{{.minikube_addon}}' is not a valid minikube addon": "",
|
||||
"\"The '{{.minikube_addon}}' addon is disabled": "",
|
||||
"\"minikube cache\" will be deprecated in upcoming versions, please switch to \"minikube image load\"": "",
|
||||
"\"{{.context}}\" context has been updated to point to {{.hostname}}:{{.port}}": "",
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"\n\n": "",
|
||||
"\"'{{.minikube_addon}}' is not a valid minikube addon": "",
|
||||
"\"The '{{.minikube_addon}}' addon is disabled": "'{{.minikube_addon}}' 插件已被禁用",
|
||||
"\"minikube cache\" will be deprecated in upcoming versions, please switch to \"minikube image load\"": "\"minikube cache\" 将在即将发布的版本中弃用,请切换至 \"minikube image load\"",
|
||||
"\"{{.context}}\" context has been updated to point to {{.hostname}}:{{.port}}": "",
|
||||
|
|
Loading…
Reference in New Issue