Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: remove CSB_DISABLE_TF_UPGRADE_PROVIDER_RENAMES feature flag #905

Merged
merged 3 commits into from
Nov 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions pkg/featureflags/feature_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down
4 changes: 0 additions & 4 deletions pkg/providers/tf/invoker/terraform_invoker_factory.go
Original file line number Diff line number Diff line change
@@ -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"
)
Expand All @@ -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)
}
64 changes: 0 additions & 64 deletions pkg/providers/tf/invoker/terraform_invoker_factory_test.go
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
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() {
Expand Down Expand Up @@ -58,68 +56,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 {
Expand Down
Loading