add iam migration warning to upgrade apply

This commit is contained in:
Adrian Stobbe 2023-07-25 11:29:50 +02:00
parent 3b0fb2c0c5
commit a521e25567
2 changed files with 12 additions and 0 deletions

View File

@ -19,6 +19,8 @@ import (
"github.com/spf13/cobra"
)
const upgradeRequiresIAMMigration = true // TODO(elchead): needs to be set on every release. Can we automate this?
func newIAMUpgradeCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "upgrade",

View File

@ -60,6 +60,16 @@ func runUpgradeApply(cmd *cobra.Command, _ []string) error {
return fmt.Errorf("creating logger: %w", err)
}
defer log.Sync()
if upgradeRequiresIAMMigration {
yes, err := askToConfirm(cmd, "WARNING: This upgrade requires an IAM migration. Please make sure you have applied the IAM migration using `iam upgrade apply` before continuing.")
if err != nil {
return fmt.Errorf("asking for confirmation: %w", err)
}
if !yes {
cmd.Println("Skipping upgrade.")
return nil
}
}
fileHandler := file.NewHandler(afero.NewOsFs())
upgrader, err := kubernetes.NewUpgrader(cmd.Context(), cmd.OutOrStdout(), fileHandler, log, kubernetes.UpgradeCmdKindApply)