diff --git a/cli/internal/cmd/iamupgradeapply.go b/cli/internal/cmd/iamupgradeapply.go index 84c0327f279..dc6b56b3f14 100644 --- a/cli/internal/cmd/iamupgradeapply.go +++ b/cli/internal/cmd/iamupgradeapply.go @@ -19,7 +19,14 @@ import ( "github.com/spf13/cobra" ) -const upgradeRequiresIAMMigration = true // TODO(elchead): needs to be set on every release. Can we automate this? +func upgradeRequiresIAMMigration(provider cloudprovider.Provider) bool { + switch provider { + case cloudprovider.AWS: + return true // needs to be set on every release. Can we automate this? + default: + return false + } +} func newIAMUpgradeCmd() *cobra.Command { cmd := &cobra.Command{ diff --git a/cli/internal/cmd/upgradeapply.go b/cli/internal/cmd/upgradeapply.go index 672fdef9527..3177e123c5a 100644 --- a/cli/internal/cmd/upgradeapply.go +++ b/cli/internal/cmd/upgradeapply.go @@ -85,7 +85,16 @@ func (u *upgradeApplyCmd) upgradeApply(cmd *cobra.Command, fileHandler file.Hand if err != nil { return fmt.Errorf("parsing flags: %w", err) } - if upgradeRequiresIAMMigration { + + conf, err := config.New(fileHandler, flags.configPath, u.configFetcher, flags.force) + var configValidationErr *config.ValidationError + if errors.As(err, &configValidationErr) { + cmd.PrintErrln(configValidationErr.LongMessage()) + } + if err != nil { + return err + } + if upgradeRequiresIAMMigration(conf.GetProvider()) { cmd.Println("WARNING: This upgrade requires an IAM migration. Please make sure you have applied the IAM migration using `iam upgrade apply` before continuing.") if !flags.yes { yes, err := askToConfirm(cmd, "Did you upgrade the IAM resources?") @@ -99,15 +108,6 @@ func (u *upgradeApplyCmd) upgradeApply(cmd *cobra.Command, fileHandler file.Hand } } - conf, err := config.New(fileHandler, flags.configPath, u.configFetcher, flags.force) - var configValidationErr *config.ValidationError - if errors.As(err, &configValidationErr) { - cmd.PrintErrln(configValidationErr.LongMessage()) - } - if err != nil { - return err - } - if err := handleInvalidK8sPatchVersion(cmd, conf.KubernetesVersion, flags.yes); err != nil { return err } diff --git a/dev-docs/workflows/release.md b/dev-docs/workflows/release.md index 605bb45b9e4..5fd9b1783a4 100644 --- a/dev-docs/workflows/release.md +++ b/dev-docs/workflows/release.md @@ -6,7 +6,7 @@ This checklist will prepare `v1.3.0` from `v1.2.0` (minor release) or `v1.3.1` f 1. Search the code for TODOs and FIXMEs that should be resolved before releasing. 2. [Update titles and labels for all PRs relevant for this release](/dev-docs/conventions.md#pr-conventions) to aid in the [changelog generation](/.github/release.yml). -3. Check PRs for the label `iam upgrade`. If there is any, the `upgradeRequiresIAMMigration` constant in `iamupgradeapply.go` needs to be set to `true`, otherwise set to `false`. This ensures the CLI issues a warning on `upgrade apply` to run `iam upgrade apply` before upgrading the cluster. +3. Check PRs for the label `iam upgrade`. If there is any, update `upgradeRequiresIAMMigration` in `iamupgradeapply.go` This ensures the CLI issues a warning on `upgrade apply` to run `iam upgrade apply` before upgrading the cluster.