Skip to content

Commit 11888e6

Browse files
authored
Chore: revert deletion of bucket api FF (#1216)
1 parent d9bb781 commit 11888e6

File tree

9 files changed

+66
-8
lines changed

9 files changed

+66
-8
lines changed

cmd/monaco/download/download_configs.go

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import (
1818
"errors"
1919
"fmt"
2020
"github.com/dynatrace/dynatrace-configuration-as-code/v2/cmd/monaco/dynatrace"
21+
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/featureflags"
2122
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/log"
2223
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/api"
2324
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/config"
@@ -256,14 +257,16 @@ func downloadConfigs(downloaders downloaders, opts downloadConfigsOptions) (proj
256257
}
257258
}
258259

259-
if opts.auth.OAuth != nil {
260-
log.Info("Downloading Grail buckets")
260+
if featureflags.Buckets().Enabled() {
261+
if opts.auth.OAuth != nil {
262+
log.Info("Downloading Grail buckets")
261263

262-
bucketCfgs, err := downloaders.Bucket().Download(opts.projectName)
263-
if err != nil {
264-
return nil, err
264+
bucketCfgs, err := downloaders.Bucket().Download(opts.projectName)
265+
if err != nil {
266+
return nil, err
267+
}
268+
copyConfigs(configs, bucketCfgs)
265269
}
266-
copyConfigs(configs, bucketCfgs)
267270
}
268271

269272
return configs, nil

cmd/monaco/integrationtest/v2/all_configs_integration_test.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
package v2
2121

2222
import (
23+
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/featureflags"
2324
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/testutils"
2425
"testing"
2526

@@ -45,6 +46,8 @@ func runAllConfigsTest(t *testing.T, specificEnvironment string) {
4546
configFolder := "test-resources/integration-all-configs/"
4647
manifest := configFolder + "manifest.yaml"
4748

49+
t.Setenv(featureflags.Buckets().EnvName(), "true")
50+
4851
RunIntegrationWithCleanup(t, configFolder, manifest, specificEnvironment, "AllConfigs", func(fs afero.Fs, _ TestContext) {
4952

5053
// This causes a POST for all configs:
@@ -69,6 +72,7 @@ func runAllConfigsTest(t *testing.T, specificEnvironment string) {
6972
func TestIntegrationValidationAllConfigs(t *testing.T) {
7073

7174
t.Setenv("UNIQUE_TEST_SUFFIX", "can-be-nonunique-for-validation")
75+
t.Setenv(featureflags.Buckets().EnvName(), "true")
7276

7377
configFolder := "test-resources/integration-all-configs/"
7478
manifest := configFolder + "manifest.yaml"

cmd/monaco/integrationtest/v2/bucket_integration_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ package v2
2121

2222
import (
2323
"github.com/dynatrace/dynatrace-configuration-as-code/v2/cmd/monaco/integrationtest"
24+
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/featureflags"
2425
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/testutils"
2526
"github.com/stretchr/testify/assert"
2627
"testing"
@@ -31,6 +32,8 @@ import (
3132

3233
// Tests a dry run (validation)
3334
func TestIntegrationBucketValidation(t *testing.T) {
35+
36+
t.Setenv(featureflags.Buckets().EnvName(), "1")
3437
t.Setenv("UNIQUE_TEST_SUFFIX", "can-be-nonunique-for-validation")
3538

3639
configFolder := "test-resources/integration-bucket/"
@@ -61,6 +64,7 @@ func TestIntegrationBucket(t *testing.T) {
6164
configFolder := "test-resources/integration-bucket/"
6265
manifest := configFolder + "manifest.yaml"
6366
specificEnvironment := ""
67+
t.Setenv(featureflags.Buckets().EnvName(), "1")
6468

6569
RunIntegrationWithCleanup(t, configFolder, manifest, specificEnvironment, "Buckets", func(fs afero.Fs, _ TestContext) {
6670

@@ -85,6 +89,7 @@ func TestIntegrationComplexBucket(t *testing.T) {
8589
configFolder := "test-resources/integration-bucket/"
8690
manifest := configFolder + "manifest.yaml"
8791
specificEnvironment := ""
92+
t.Setenv(featureflags.Buckets().EnvName(), "1")
8893

8994
RunIntegrationWithCleanup(t, configFolder, manifest, specificEnvironment, "ComplexBuckets", func(fs afero.Fs, _ TestContext) {
9095

cmd/monaco/integrationtest/v2/config_restore_e2e_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"fmt"
2323
"github.com/dynatrace/dynatrace-configuration-as-code/v2/cmd/monaco/integrationtest"
2424
"github.com/dynatrace/dynatrace-configuration-as-code/v2/cmd/monaco/runner"
25+
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/featureflags"
2526
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/log"
2627
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/testutils"
2728
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/manifest"
@@ -107,6 +108,8 @@ func TestRestoreConfigs_FromDownloadWithPlatformManifestFile_withPlatformConfigs
107108
subsetOfConfigsToDownload := "alerting-profile,management-zone"
108109
suffixTest := "_download_automations"
109110

111+
t.Setenv(featureflags.Buckets().EnvName(), "true")
112+
110113
testRestoreConfigs(t, initialConfigsFolder, downloadFolder, suffixTest, manifestFile, subsetOfConfigsToDownload, false, execution_downloadConfigs)
111114
}
112115

cmd/monaco/integrationtest/v2/delete_integration_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import (
2222
"fmt"
2323
"github.com/dynatrace/dynatrace-configuration-as-code/v2/cmd/monaco/integrationtest"
2424
"github.com/dynatrace/dynatrace-configuration-as-code/v2/cmd/monaco/runner"
25+
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/featureflags"
2526
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/testutils"
2627
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/config"
2728
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/config/coordinate"
@@ -160,6 +161,7 @@ func TestDelete(t *testing.T) {
160161
}
161162

162163
func TestDeleteSkipsPlatformTypesWhenDeletingFromClassicEnv(t *testing.T) {
164+
t.Setenv(featureflags.Buckets().EnvName(), "true")
163165

164166
configFolder := "test-resources/delete-test-configs/"
165167
deployManifestPath := configFolder + "deploy-manifest.yaml"

internal/featureflags/temporary.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,15 @@ func DependencyGraphBasedDeployParallel() FeatureFlag {
7373
}
7474
}
7575

76+
// Buckets toggles whether the Grail bucket type can be used.
77+
// Introduced: (inactive) 2023-08-09 ->
78+
func Buckets() FeatureFlag {
79+
return FeatureFlag{
80+
envName: "MONACO_FEAT_BUCKETS",
81+
defaultEnabled: false,
82+
}
83+
}
84+
7685
// UnescapeOnConvert toggles whether converting will remove escape chars from v1 values.
7786
// Introduced: 2023-09-01; v2.8.0
7887
func UnescapeOnConvert() FeatureFlag {

pkg/persistence/config/internal/persistence/type_definition.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package persistence
1919
import (
2020
"errors"
2121
"fmt"
22+
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/featureflags"
2223
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/config"
2324
"github.com/mitchellh/mapstructure"
2425
)
@@ -54,6 +55,11 @@ func (c *TypeDefinition) UnmarshalYAML(unmarshal func(interface{}) error) error
5455
switch v := data.(type) {
5556
case string:
5657
if v == BucketType {
58+
// string was a bucket
59+
if !featureflags.Buckets().Enabled() {
60+
return fmt.Errorf("failed to parse 'type' section: unknown type %q", v)
61+
}
62+
5763
c.Bucket = v
5864
return nil
5965
}

pkg/persistence/config/internal/persistence/type_definition_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,15 @@
1919
package persistence
2020

2121
import (
22+
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/featureflags"
2223
"github.com/stretchr/testify/assert"
2324
"gopkg.in/yaml.v2"
2425
"testing"
2526
)
2627

2728
func Test_typeDefinition_isSound(t *testing.T) {
29+
t.Setenv(featureflags.Buckets().EnvName(), "1")
30+
2831
type fields struct {
2932
configType TypeDefinition
3033
knownApis map[string]struct{}

pkg/persistence/config/loader/config_loader_test.go

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ package loader
2020

2121
import (
2222
"fmt"
23+
"github.com/dynatrace/dynatrace-configuration-as-code/v2/internal/featureflags"
2324
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/config"
2425
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/config/coordinate"
2526
"github.com/dynatrace/dynatrace-configuration-as-code/v2/pkg/config/parameter"
@@ -884,7 +885,10 @@ configs:
884885
},
885886
},
886887
{
887-
name: "Bucket config",
888+
name: "Bucket config with FF on",
889+
envVars: map[string]string{
890+
featureflags.Buckets().EnvName(): "true",
891+
},
888892
filePathArgument: "test-file.yaml",
889893
filePathOnDisk: "test-file.yaml",
890894
fileContentOnDisk: `
@@ -911,7 +915,26 @@ configs:
911915
},
912916
},
913917
{
914-
name: "Bucket written as api config",
918+
name: "Bucket with FF off",
919+
envVars: map[string]string{
920+
featureflags.Buckets().EnvName(): "false",
921+
},
922+
filePathArgument: "test-file.yaml",
923+
filePathOnDisk: "test-file.yaml",
924+
fileContentOnDisk: `
925+
configs:
926+
- id: profile-id
927+
config:
928+
template: 'profile.json'
929+
type: bucket
930+
`,
931+
wantErrorsContain: []string{"failed to parse 'type' section: unknown type \"bucket\""},
932+
},
933+
{
934+
name: "Bucket written as api config",
935+
envVars: map[string]string{
936+
featureflags.Buckets().EnvName(): "true",
937+
},
915938
filePathArgument: "test-file.yaml",
916939
filePathOnDisk: "test-file.yaml",
917940
fileContentOnDisk: `

0 commit comments

Comments
 (0)