Skip to content

Commit ea55673

Browse files
authored
Remove feature toggle for cr (#474)
* remove feature toggle for cr * add test for toggle so it doesn't have linting error
1 parent 8e6d2f4 commit ea55673

6 files changed

Lines changed: 42 additions & 34 deletions

File tree

app/connectivity_rule.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,12 +118,6 @@ func NewConnectivityRuleCommand(getConnectivityRuleClientFn GetConnectivityRuleC
118118
Required: false,
119119
}
120120

121-
if !IsFeatureEnabled(ConnectivityRuleFeatureFlag) {
122-
return CommandOut{
123-
Command: nil,
124-
}, nil
125-
}
126-
127121
return CommandOut{
128122
Command: &cli.Command{
129123
Name: "connectivity-rule",

app/connectivity_rule_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@ type ConnectivityRuleTestSuite struct {
2525
}
2626

2727
func (s *ConnectivityRuleTestSuite) SetupTest() {
28-
if !IsFeatureEnabled(ConnectivityRuleFeatureFlag) {
29-
err := toggleFeature(ConnectivityRuleFeatureFlag)
30-
s.Require().NoError(err)
31-
}
3228
s.mockCtrl = gomock.NewController(s.T())
3329
s.mockCloudService = cloudservicemock.NewMockCloudServiceClient(s.mockCtrl)
3430
out, err := NewConnectivityRuleCommand(func(ctx *cli.Context) (*ConnectivityRuleClient, error) {

app/feature.go

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,11 @@ import (
1111
)
1212

1313
var (
14-
GCPSinkFeatureFlag = "enable-gcp-sink"
15-
ConnectivityRuleFeatureFlag = "enable-connectivity-rule"
16-
featureflagFileName = "feature.json"
14+
GCPSinkFeatureFlag = "enable-gcp-sink"
15+
featureflagFileName = "feature.json"
1716
)
1817

19-
var supportFeatureFlags = []string{ConnectivityRuleFeatureFlag}
18+
var supportFeatureFlags = []string{GCPSinkFeatureFlag}
2019

2120
type FeatureFlag struct {
2221
Name string `json:"Name"`
@@ -134,14 +133,6 @@ func NewFeatureCommand() (CommandOut, error) {
134133
// return toggleFeature(GCPSinkFeatureFlag)
135134
// },
136135
// },
137-
{
138-
Name: "toggle-connectivity-rule",
139-
Aliases: []string{"tcr"},
140-
Usage: "switch connectivity rule on/off",
141-
Action: func(c *cli.Context) error {
142-
return toggleFeature(ConnectivityRuleFeatureFlag)
143-
},
144-
},
145136
{
146137
Name: "get",
147138
Aliases: []string{"g"},

app/feature_test.go

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,43 @@ import (
88
"github.com/stretchr/testify/assert"
99
)
1010

11+
func TestToggleFeature(t *testing.T) {
12+
tmpDir, err := os.MkdirTemp("", "tcld-test-*")
13+
if err != nil {
14+
t.Fatal(err)
15+
}
16+
defer os.RemoveAll(tmpDir) // clean up
17+
18+
// Set the config directory flag to our temp directory
19+
originalConfigDir := ConfigDirFlag.Value
20+
ConfigDirFlag.Value = tmpDir
21+
defer func() {
22+
ConfigDirFlag.Value = originalConfigDir
23+
}()
24+
25+
testFeatureName := supportFeatureFlags[0]
26+
27+
err = toggleFeature(testFeatureName)
28+
if err != nil {
29+
t.Fatal(err)
30+
}
31+
32+
featureFlags, err := getFeatureFlags()
33+
if err != nil {
34+
t.Fatal(err)
35+
}
36+
37+
found := false
38+
for _, flag := range featureFlags {
39+
if flag.Name == testFeatureName {
40+
assert.Equal(t, true, flag.Value)
41+
found = true
42+
break
43+
}
44+
}
45+
assert.True(t, found)
46+
}
47+
1148
func TestToggleFeatureAndRead(t *testing.T) {
1249
testFileName := uuid.NewString() + ".json"
1350
_, err := getFeatureFlagsFromConfigFile(testFileName)

app/namespace.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -596,10 +596,7 @@ func getCreateNamespaceFlags() []cli.Flag {
596596
Usage: "Add tags to the namespace (format: key=value). Flag can be used multiple times.",
597597
Aliases: []string{"t"},
598598
},
599-
}
600-
601-
if IsFeatureEnabled(ConnectivityRuleFeatureFlag) {
602-
baseFlags = append(baseFlags, connectivityRuleIdsFlag)
599+
connectivityRuleIdsFlag,
603600
}
604601

605602
return baseFlags
@@ -2267,9 +2264,7 @@ func NewNamespaceCommand(getNamespaceClientFn GetNamespaceClientFn) (CommandOut,
22672264

22682265
subCommands = append(subCommands, exportCommand)
22692266

2270-
if IsFeatureEnabled(ConnectivityRuleFeatureFlag) {
2271-
subCommands = append(subCommands, coonectivityRuleCommand)
2272-
}
2267+
subCommands = append(subCommands, coonectivityRuleCommand)
22732268

22742269
command := &cli.Command{
22752270
Name: "namespace",

app/namespace_test.go

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,6 @@ type NamespaceTestSuite struct {
4242
}
4343

4444
func (s *NamespaceTestSuite) SetupTest() {
45-
if !IsFeatureEnabled(ConnectivityRuleFeatureFlag) {
46-
err := toggleFeature(ConnectivityRuleFeatureFlag)
47-
s.Require().NoError(err)
48-
}
49-
5045
s.mockCtrl = gomock.NewController(s.T())
5146
s.mockService = namespaceservicemock.NewMockNamespaceServiceClient(s.mockCtrl)
5247
s.mockAuthService = authservicemock.NewMockAuthServiceClient(s.mockCtrl)

0 commit comments

Comments
 (0)