From d4bba802eff0c1f033b570f645ee53d9acaa3711 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Wei=C3=9Fe?= Date: Mon, 30 Oct 2023 09:26:54 +0100 Subject: [PATCH] Rename cloudcmd plan functions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Weiße --- cli/internal/cloudcmd/apply.go | 2 +- cli/internal/cloudcmd/iamupgrade.go | 2 +- cli/internal/cloudcmd/{tfupgrade.go => tfplan.go} | 4 ++-- cli/internal/cloudcmd/{tfupgrade_test.go => tfplan_test.go} | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) rename cli/internal/cloudcmd/{tfupgrade.go => tfplan.go} (96%) rename cli/internal/cloudcmd/{tfupgrade_test.go => tfplan_test.go} (98%) diff --git a/cli/internal/cloudcmd/apply.go b/cli/internal/cloudcmd/apply.go index 5c2b6f46e5c..bec3c4c4b37 100644 --- a/cli/internal/cloudcmd/apply.go +++ b/cli/internal/cloudcmd/apply.go @@ -80,7 +80,7 @@ func (a *Applier) Plan(ctx context.Context, conf *config.Config) (bool, error) { return false, fmt.Errorf("creating terraform variables: %w", err) } - return planApply( + return plan( ctx, a.terraformClient, a.fileHandler, a.out, a.logLevel, vars, filepath.Join(constants.TerraformEmbeddedDir, strings.ToLower(conf.GetProvider().String())), a.workingDir, diff --git a/cli/internal/cloudcmd/iamupgrade.go b/cli/internal/cloudcmd/iamupgrade.go index e465e2d23f8..729af5d29d3 100644 --- a/cli/internal/cloudcmd/iamupgrade.go +++ b/cli/internal/cloudcmd/iamupgrade.go @@ -59,7 +59,7 @@ func NewIAMUpgrader(ctx context.Context, existingWorkspace, upgradeWorkspace str // PlanIAMUpgrade prepares the upgrade workspace and plans the possible Terraform migrations for Constellation's IAM resources (service accounts, permissions etc.). // In case of possible migrations, the diff is written to outWriter and this function returns true. func (u *IAMUpgrader) PlanIAMUpgrade(ctx context.Context, outWriter io.Writer, vars terraform.Variables, csp cloudprovider.Provider) (bool, error) { - return planApply( + return plan( ctx, u.tf, u.fileHandler, outWriter, u.logLevel, vars, filepath.Join(constants.TerraformEmbeddedDir, "iam", strings.ToLower(csp.String())), u.existingWorkspace, diff --git a/cli/internal/cloudcmd/tfupgrade.go b/cli/internal/cloudcmd/tfplan.go similarity index 96% rename from cli/internal/cloudcmd/tfupgrade.go rename to cli/internal/cloudcmd/tfplan.go index 4fcc6e5a9ff..69fef4f79b2 100644 --- a/cli/internal/cloudcmd/tfupgrade.go +++ b/cli/internal/cloudcmd/tfplan.go @@ -17,10 +17,10 @@ import ( "github.com/edgelesssys/constellation/v2/internal/file" ) -// planApply prepares a workspace and plans the possible Terraform actions. +// plan prepares a workspace and plans the possible Terraform actions. // This will either create a new workspace or update an existing one. // In case of possible migrations, the diff is written to outWriter and this function returns true. -func planApply( +func plan( ctx context.Context, tfClient tfPlanner, fileHandler file.Handler, outWriter io.Writer, logLevel terraform.LogLevel, vars terraform.Variables, templateDir, existingWorkspace, backupDir string, diff --git a/cli/internal/cloudcmd/tfupgrade_test.go b/cli/internal/cloudcmd/tfplan_test.go similarity index 98% rename from cli/internal/cloudcmd/tfupgrade_test.go rename to cli/internal/cloudcmd/tfplan_test.go index 38795c1e796..2c899c6e4ad 100644 --- a/cli/internal/cloudcmd/tfupgrade_test.go +++ b/cli/internal/cloudcmd/tfplan_test.go @@ -19,7 +19,7 @@ import ( "github.com/stretchr/testify/require" ) -func TestPlanUpgrade(t *testing.T) { +func TestTFPlan(t *testing.T) { const ( templateDir = "templateDir" existingWorkspace = "existing" @@ -99,7 +99,7 @@ func TestPlanUpgrade(t *testing.T) { assert := assert.New(t) fs := tc.prepareFs(require.New(t)) - hasDiff, planErr := planApply( + hasDiff, planErr := plan( context.Background(), tc.tf, fs, io.Discard, terraform.LogLevelDebug, &terraform.QEMUVariables{}, templateDir, existingWorkspace, backupDir,