Skip to content

Commit

Permalink
make iam upgrade provider specific
Browse files Browse the repository at this point in the history
  • Loading branch information
elchead committed Jul 26, 2023
1 parent 99b41fd commit e9c0c89
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 12 deletions.
9 changes: 8 additions & 1 deletion cli/internal/cmd/iamupgradeapply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down
20 changes: 10 additions & 10 deletions cli/internal/cmd/upgradeapply.go
Original file line number Diff line number Diff line change
Expand Up @@ -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?")
Expand All @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion dev-docs/workflows/release.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.



Expand Down

0 comments on commit e9c0c89

Please sign in to comment.