From 0eb9ca2e185d789cf508567fb2ac84b06e7d1fac Mon Sep 17 00:00:00 2001 From: Adrian Stobbe Date: Thu, 7 Sep 2023 12:10:36 +0200 Subject: [PATCH] move csp logic to cloudcmd (#2311) --- cli/internal/cloudcmd/iamupgrade.go | 8 ++++++++ cli/internal/cmd/iamupgradeapply.go | 7 ------- cli/internal/cmd/upgradeapply.go | 2 +- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/cli/internal/cloudcmd/iamupgrade.go b/cli/internal/cloudcmd/iamupgrade.go index 952efb35aa..4594930a09 100644 --- a/cli/internal/cloudcmd/iamupgrade.go +++ b/cli/internal/cloudcmd/iamupgrade.go @@ -19,6 +19,14 @@ import ( "github.com/edgelesssys/constellation/v2/internal/file" ) +// UpgradeRequiresIAMMigration returns true if the given cloud provider requires an IAM migration. +func UpgradeRequiresIAMMigration(provider cloudprovider.Provider) bool { + switch provider { + default: + return false + } +} + // IAMUpgrader handles upgrades to IAM resources required by Constellation. type IAMUpgrader struct { tf tfIAMUpgradeClient diff --git a/cli/internal/cmd/iamupgradeapply.go b/cli/internal/cmd/iamupgradeapply.go index 07436d883d..4642a8f8af 100644 --- a/cli/internal/cmd/iamupgradeapply.go +++ b/cli/internal/cmd/iamupgradeapply.go @@ -23,13 +23,6 @@ import ( "github.com/spf13/cobra" ) -func upgradeRequiresIAMMigration(provider cloudprovider.Provider) bool { - switch provider { - default: - return false - } -} - func newIAMUpgradeCmd() *cobra.Command { cmd := &cobra.Command{ Use: "upgrade", diff --git a/cli/internal/cmd/upgradeapply.go b/cli/internal/cmd/upgradeapply.go index 7ed0234732..ff52bf140c 100644 --- a/cli/internal/cmd/upgradeapply.go +++ b/cli/internal/cmd/upgradeapply.go @@ -136,7 +136,7 @@ func (u *upgradeApplyCmd) upgradeApply(cmd *cobra.Command, upgradeDir string, fl if err != nil { return err } - if upgradeRequiresIAMMigration(conf.GetProvider()) { + if cloudcmd.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?")