Skip to content

Commit

Permalink
feat: add feature flag for clustertask (#542)
Browse files Browse the repository at this point in the history
* feat: add feature flag for clustertask
* feat: add config for katanomi system namespace
* feat: add feature flag for gitsource and hub resolver
  • Loading branch information
l-qing authored Mar 3, 2024
1 parent 56b7e5b commit 9c0e96a
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 8 deletions.
47 changes: 41 additions & 6 deletions config/feature_flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,39 @@ const (

// PprofEnabledKey indicates the configuration key of the /debug/pprof debugging api/
PprofEnabledKey = "pprof.enabled"

// ClusterTaskDisabledKey specifies the key for the clustertask feature gate configuration.
// When set to true, the clustertasks is disabled, cannot create new clustertasks.
ClusterTaskDisabledKey = "clustertask.disabled"

// KatanomiSystemNamespaceKey specifies the key for the katanomi system namespace
KatanomiSystemNamespaceKey = "katanomi.system.namespace"

// GitSourceResolverFeatureKey indicates the configuration key of the gitsource resolver feature gate.
GitSourceResolverFeatureKey = "gitsourceResolver.enabled"

// HubResolverFeatureKey indicates the configuration key of the hub resolver feature gate.
HubResolverFeatureKey = "hubResolver.enabled"
)

const (
// True represents the value "true" for the feature switch.
True FeatureValue = "true"

// False represents the value "false" for the feature switch.
False FeatureValue = "false"

// DefaultVersionEnabled indicates the default value of the version feature gate.
// If the corresponding key does not exist, the default value is returned.
DefaultVersionEnabled FeatureValue = "false"
DefaultVersionEnabled FeatureValue = False

// DefaultProxyEnabled indicates the default value of the proxy feature gate.
// If the corresponding key does not exist, the default value is returned.
DefaultProxyEnabled FeatureValue = "false"
DefaultProxyEnabled FeatureValue = False

// DefaultInitializeAllowLocalRequests indicates the configuration key of.
// If the corresponding key does not exist, the default value is returned.
DefaultInitializeAllowLocalRequests FeatureValue = "true"
DefaultInitializeAllowLocalRequests FeatureValue = True

// DefaultPrunerDelayAfterCompleted represent default duration for delay taskRun
// If the corresponding key does not exist, the default value is returned.
Expand All @@ -90,7 +109,7 @@ const (
DefaultMRCheckTimeout FeatureValue = "10m"

// DefaultMRCheckTimeoutContinue represent default timeout continue for merge request status check
DefaultMRCheckTimeoutContinue FeatureValue = "true"
DefaultMRCheckTimeoutContinue FeatureValue = True

// DefaultTemplateRenderCheckTimeout represent default timeout for templaterender check
DefaultTemplateRenderCheckTimeout FeatureValue = "30s"
Expand All @@ -103,7 +122,7 @@ const (

// DefaultPolicyCheckEnabled indicates the default value of the policy check feature gate.
// If the corresponding key does not exist, the default value is returned.
DefaultPolicyCheckEnabled FeatureValue = "true"
DefaultPolicyCheckEnabled FeatureValue = True

// DefaultClusterIntegrationSyncPeriod defines the default time interval of clusterintegration synchronization
DefaultClusterIntegrationSyncPeriod = "5m"
Expand All @@ -113,7 +132,19 @@ const (

// DefaultPprofEnabled stores the default value "false" for the "pprof.enabled" /debug/pprof debugging api.
// If the corresponding key does not exist, the default value is returned.
DefaultPprofEnabled FeatureValue = "false"
DefaultPprofEnabled FeatureValue = False

// DefaultClusterTaskDisabled stores the default value "true" for the "clustertask.disabled" feature.
DefaultClusterTaskDisabled FeatureValue = True

// DefaultKatanomiSystemNamespace defines the default namespace for katanomi system
DefaultKatanomiSystemNamespace = "katanomi-system"

// DefaultGitSourceResolverEnabled defines the default value "true" for the "gitsourceResolver.enabled" feature.
DefaultGitSourceResolverEnabled = True

// DefaultHubResolverEnabled defines the default value "true" for the "hubResolver.enabled" feature.
DefaultHubResolverEnabled = True
)

// defaultFeatureValue defines the default value for the feature switch.
Expand All @@ -132,6 +163,10 @@ var defaultFeatureValue = map[string]FeatureValue{
ClusterIntegrationSyncPeriodKey: DefaultClusterIntegrationSyncPeriod,
IntegrationSyncPeriodKey: DefaultIntegrationsSyncPeriod,
PprofEnabledKey: DefaultPprofEnabled,
ClusterTaskDisabledKey: DefaultClusterTaskDisabled,
KatanomiSystemNamespaceKey: DefaultKatanomiSystemNamespace,
GitSourceResolverFeatureKey: DefaultGitSourceResolverEnabled,
HubResolverFeatureKey: DefaultHubResolverEnabled,
}

// FeatureFlags holds the features configurations
Expand Down
11 changes: 9 additions & 2 deletions config/feature_flags_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,16 @@ func TestFeatureFlags_FeatureValue(t *testing.T) {
want: DefaultVersionEnabled,
},
"not match feature": {
featureFlags: &FeatureFlags{
Data: map[string]string{},
},
flag: "notfound.flag",
want: "",
},
"the default clustertask creation disabled flag is true": {
featureFlags: &FeatureFlags{},
flag: "notfound.flag",
want: "",
flag: ClusterTaskDisabledKey,
want: DefaultClusterTaskDisabled,
},
}
for name, tt := range tests {
Expand Down

0 comments on commit 9c0e96a

Please sign in to comment.