Skip to content

Commit f7d057a

Browse files
authored
Add feature flag support for dataset commands (#80)
One of the new features being considered for the application is support for datasets. Datasets provide bulk import and export of types of assets. This feature is under heavy consideration but is not ready for production use; therefore, it is being feature flagged. By default, dataset commands are disabled. To enable dataset commands add the following to your configuration: ``` [features] datasets_enabled = [true, false*] ``` The default value for `datasets_enabled` is `false` which means the command will not show up when running the application. When set to `true` the commands will show up. Please use with caution as there are no guarantees this will be available in future releases.
1 parent c878cbb commit f7d057a

2 files changed

Lines changed: 13 additions & 1 deletion

File tree

cmd/root.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ const description = `Manage Itential Platform
2828

2929
func loadCommands(cmd *cobra.Command, h handlers.Handler, cfg *config.Config) {
3030
addCommandGroup(cmd, h, "Asset Commands:", assetCommands)
31-
addCommandGroup(cmd, h, "Dataset Commands:", datasetCommands)
31+
if cfg.FeaturesDatasetsEnabled {
32+
addCommandGroup(cmd, h, "Dataset Commands:", datasetCommands)
33+
}
3234
addCommandGroup(cmd, h, "Platform Commands:", platformCommands)
3335
addCommandGroup(cmd, h, "Plugin Commands:", pluginCommands)
3436
}

pkg/config/config.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ const (
2323
defaultAppDefaultProfile = ""
2424
defaultAppDefaultRepository = ""
2525

26+
defaultFeaturesDatasetsEnabled = false
27+
2628
defaultLogLevel = "INFO"
2729
defaultLogFileJson = false
2830
defaultLogConsoleJson = false
@@ -43,6 +45,8 @@ type Config struct {
4345
DefaultProfile string `json:"default_profile"`
4446
DefaultRepository string `json:"default_repository"`
4547

48+
FeaturesDatasetsEnabled bool `json:"datasets_enabled"`
49+
4650
// Profiles
4751
profileName string
4852
profiles map[string]*Profile
@@ -182,6 +186,8 @@ func (ac *Config) populateFields() {
182186
ac.DefaultProfile = viper.GetString("application.default_profile")
183187
ac.DefaultRepository = viper.GetString("application.default_repository")
184188

189+
ac.FeaturesDatasetsEnabled = viper.GetBool("features.datasets_enabled")
190+
185191
ac.LogLevel = viper.GetString("log.level")
186192
ac.LogFileJSON = viper.GetBool("log.file_json")
187193
ac.LogConsoleJSON = viper.GetBool("log.console_json")
@@ -201,6 +207,8 @@ var defaultValues = map[string]interface{}{
201207
"application.default_profile": defaultAppDefaultProfile,
202208
"application.default_repository": defaultAppDefaultRepository,
203209

210+
"features.datasets_enabled": defaultFeaturesDatasetsEnabled,
211+
204212
"log.level": defaultLogLevel,
205213
"log.file_json": defaultLogFileJson,
206214
"log.console_json": defaultLogConsoleJson,
@@ -220,6 +228,8 @@ var defaultEnvVarBindings = map[string]string{
220228
"application.default_profile": "IPCTL_APPLICATION_DEFAULT_PROFILE",
221229
"application.default_repository": "IPCTL_APPLICATION_DEFAULT_REPOSITORY",
222230

231+
"features.datasets_enabled": "IPCTL_FEATURES_DATASETS_ENABLED",
232+
223233
"log.level": "IPCTL_LOG_LEVEL",
224234
"log.file_json": "IPCTL_LOG_FILE_JSON",
225235
"log.console_json": "IPCTL_LOG_CONSOLE_JSON",

0 commit comments

Comments
 (0)