From adf03120bcb70c8cc947ec8861061c76a6fe68b0 Mon Sep 17 00:00:00 2001 From: Marcela Campo Date: Tue, 21 Nov 2023 14:45:19 +0000 Subject: [PATCH 1/3] chore: remove logic that skips provider renames [#186494059](https://www.pivotaltracker.com/story/show/186494059) --- .../tf/invoker/terraform_invoker_factory.go | 4 -- .../invoker/terraform_invoker_factory_test.go | 65 ------------------- 2 files changed, 69 deletions(-) diff --git a/pkg/providers/tf/invoker/terraform_invoker_factory.go b/pkg/providers/tf/invoker/terraform_invoker_factory.go index 8fe7902d2..646243fd0 100644 --- a/pkg/providers/tf/invoker/terraform_invoker_factory.go +++ b/pkg/providers/tf/invoker/terraform_invoker_factory.go @@ -1,7 +1,6 @@ package invoker import ( - "github.com/cloudfoundry/cloud-service-broker/pkg/featureflags" "github.com/cloudfoundry/cloud-service-broker/pkg/providers/tf/executor" "github.com/hashicorp/go-version" ) @@ -20,8 +19,5 @@ func (factory TerraformInvokerFactory) VersionedTerraformInvoker(tfVersion *vers if tfVersion.LessThan(version.Must(version.NewVersion("0.13.0"))) { return NewTerraform012Invoker(factory.executorBuilder.VersionedExecutor(tfVersion), factory.terraformPluginsDirectory) } - if tfVersion.GreaterThanOrEqual(version.Must(version.NewVersion("1.2.0"))) && featureflags.Enabled(featureflags.DisableTfUpgradeProviderRenames) { - return NewTerraformDefaultInvoker(factory.executorBuilder.VersionedExecutor(tfVersion), factory.terraformPluginsDirectory, map[string]string{}) - } return NewTerraformDefaultInvoker(factory.executorBuilder.VersionedExecutor(tfVersion), factory.terraformPluginsDirectory, factory.pluginRenames) } diff --git a/pkg/providers/tf/invoker/terraform_invoker_factory_test.go b/pkg/providers/tf/invoker/terraform_invoker_factory_test.go index 9860cc1b9..7df192b11 100644 --- a/pkg/providers/tf/invoker/terraform_invoker_factory_test.go +++ b/pkg/providers/tf/invoker/terraform_invoker_factory_test.go @@ -1,13 +1,10 @@ package invoker_test import ( - "github.com/cloudfoundry/cloud-service-broker/pkg/featureflags" "github.com/cloudfoundry/cloud-service-broker/pkg/providers/tf/executor/executorfakes" "github.com/cloudfoundry/cloud-service-broker/pkg/providers/tf/invoker" "github.com/hashicorp/go-version" - . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" - "github.com/spf13/viper" ) var _ = Context("TerraformInvokerFactory", func() { @@ -58,68 +55,6 @@ var _ = Context("TerraformInvokerFactory", func() { Expect(fakeBuilder.VersionedExecutorArgsForCall(0)).To(Equal(newVersion("1.0.4"))) }) }) - - Context("1.2.0+", func() { - Context("with provider renames disabled", func() { - BeforeEach(func() { - viper.Set(string(featureflags.DisableTfUpgradeProviderRenames), true) - - }) - AfterEach(func() { - viper.Reset() - }) - - It("should return an invoker with renames, for terraform version 1.1.9", func() { - Expect( - invokerFactory.VersionedTerraformInvoker(newVersion("1.1.9")), - ).To(Equal(invoker.NewTerraformDefaultInvoker(fakeExecutor, expectedTerraformPluginDir, expectedProviderRenames))) - Expect(fakeBuilder.VersionedExecutorCallCount()).To(Equal(1)) - Expect(fakeBuilder.VersionedExecutorArgsForCall(0)).To(Equal(newVersion("1.1.9"))) - }) - - It("should return an invoker with no renames, for terraform version 1.2.0", func() { - Expect( - invokerFactory.VersionedTerraformInvoker(newVersion("1.2.0")), - ).To(Equal(invoker.NewTerraformDefaultInvoker(fakeExecutor, expectedTerraformPluginDir, map[string]string{}))) - Expect(fakeBuilder.VersionedExecutorCallCount()).To(Equal(1)) - Expect(fakeBuilder.VersionedExecutorArgsForCall(0)).To(Equal(newVersion("1.2.0"))) - }) - - It("should return an invoker with no renames, for terraform version 1.4.2", func() { - Expect( - invokerFactory.VersionedTerraformInvoker(newVersion("1.4.2")), - ).To(Equal(invoker.NewTerraformDefaultInvoker(fakeExecutor, expectedTerraformPluginDir, map[string]string{}))) - Expect(fakeBuilder.VersionedExecutorCallCount()).To(Equal(1)) - Expect(fakeBuilder.VersionedExecutorArgsForCall(0)).To(Equal(newVersion("1.4.2"))) - }) - }) - - Context("with provider renames enabled", func() { - It("should return an invoker that performs renames, for 1.2.0", func() { - Expect( - invokerFactory.VersionedTerraformInvoker(newVersion("1.2.0")), - ).To(Equal(invoker.NewTerraformDefaultInvoker(fakeExecutor, expectedTerraformPluginDir, expectedProviderRenames))) - Expect(fakeBuilder.VersionedExecutorCallCount()).To(Equal(1)) - Expect(fakeBuilder.VersionedExecutorArgsForCall(0)).To(Equal(newVersion("1.2.0"))) - }) - - It("should return an invoker that performs renames, for 1.4.2", func() { - Expect( - invokerFactory.VersionedTerraformInvoker(newVersion("1.4.2")), - ).To(Equal(invoker.NewTerraformDefaultInvoker(fakeExecutor, expectedTerraformPluginDir, expectedProviderRenames))) - Expect(fakeBuilder.VersionedExecutorCallCount()).To(Equal(1)) - Expect(fakeBuilder.VersionedExecutorArgsForCall(0)).To(Equal(newVersion("1.4.2"))) - }) - - It("should return an invoker with renames, for terraform version 1.1.9", func() { - Expect( - invokerFactory.VersionedTerraformInvoker(newVersion("1.1.9")), - ).To(Equal(invoker.NewTerraformDefaultInvoker(fakeExecutor, expectedTerraformPluginDir, expectedProviderRenames))) - Expect(fakeBuilder.VersionedExecutorCallCount()).To(Equal(1)) - Expect(fakeBuilder.VersionedExecutorArgsForCall(0)).To(Equal(newVersion("1.1.9"))) - }) - }) - }) }) func newVersion(v string) *version.Version { From 6060e788058eba6c206d4a35ef28a0d611e08dd1 Mon Sep 17 00:00:00 2001 From: Marcela Campo Date: Tue, 21 Nov 2023 14:47:02 +0000 Subject: [PATCH 2/3] chore: remove flag that disabled provider renames [#186494059](https://www.pivotaltracker.com/story/show/186494059) --- pkg/featureflags/feature_flags.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/pkg/featureflags/feature_flags.go b/pkg/featureflags/feature_flags.go index fc7379225..812edb1a2 100644 --- a/pkg/featureflags/feature_flags.go +++ b/pkg/featureflags/feature_flags.go @@ -14,8 +14,7 @@ const ( // IF YOU USE THIS, PLEASE RAISE AN ISSUE. Since the new way of running examples was added, // the authors don't expect anyone to use the legacy method. Please let us know if you need // the old way to stay around. - EnableLegacyExamplesCommands FeatureFlagName = "legacy.examples.enabled" - DisableTfUpgradeProviderRenames FeatureFlagName = "brokerpak.terraform.upgrades.providerRenames.disabled" + EnableLegacyExamplesCommands FeatureFlagName = "legacy.examples.enabled" ) var AllFeatureFlagEnvVars []string @@ -26,7 +25,6 @@ func init() { DynamicHCLEnabled: "BROKERPAK_UPDATES_ENABLED", // deprecated pattern - future variables should start CSB_ DisableRequestPropertyValidation: "CSB_DISABLE_REQUEST_PROPERTY_VALIDATION", EnableLegacyExamplesCommands: "CSB_ENABLE_LEGACY_EXAMPLES_COMMANDS", - DisableTfUpgradeProviderRenames: "CSB_DISABLE_TF_UPGRADE_PROVIDER_RENAMES", } { viper.BindEnv(string(ffName), varName) viper.SetDefault(string(ffName), false) From 222a2b7132ac18c7e728109d79d3e825ae0601fb Mon Sep 17 00:00:00 2001 From: Marcela Campo Date: Tue, 21 Nov 2023 14:54:17 +0000 Subject: [PATCH 3/3] chore: fix imports [#186494059](https://www.pivotaltracker.com/story/show/186494059) --- pkg/providers/tf/invoker/terraform_invoker_factory_test.go | 1 + 1 file changed, 1 insertion(+) diff --git a/pkg/providers/tf/invoker/terraform_invoker_factory_test.go b/pkg/providers/tf/invoker/terraform_invoker_factory_test.go index 7df192b11..07fbc6efd 100644 --- a/pkg/providers/tf/invoker/terraform_invoker_factory_test.go +++ b/pkg/providers/tf/invoker/terraform_invoker_factory_test.go @@ -4,6 +4,7 @@ import ( "github.com/cloudfoundry/cloud-service-broker/pkg/providers/tf/executor/executorfakes" "github.com/cloudfoundry/cloud-service-broker/pkg/providers/tf/invoker" "github.com/hashicorp/go-version" + . "github.com/onsi/ginkgo/v2" . "github.com/onsi/gomega" )