Skip to content

Commit

Permalink
Simplify message on feature flag target specified as reviewed
Browse files Browse the repository at this point in the history
like below:

````
Configuring gitlab::feature_flags...
- Launching rails runner to set feature flags. This will take some time....
- Specified feature flags  to be disabled:
--- "auto_devops_banner_disabled"
--- "invalid_flag_name"
- Specified feature flags  to be enabled
--- "git_push_create_all_pipelines"
--- "another_invalid_flag_name"
- Following flags are probably invalid and have been ignored
--- invalid_flag_name
--- another_invalid_flag_name
- Apply user defined feature flags:
--- auto_devops_banner_disabled : off
--- git_push_create_all_pipelines : on
````

- Do not `puts` parsed options (formatted by ruby's `.to_s`),
  `puts` each specified target with three hyphens instead
- `puts` each ignored target on each line with three hyphens instead of single line csv
  • Loading branch information
kkimurak committed Mar 24, 2024
1 parent 05794a2 commit 351711c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions assets/runtime/scripts/configure_feature_flags.rb
Expand Up @@ -38,9 +38,13 @@ def parse_options(argv = ARGV)

op.on("-d", "--disable feature_a,feature_b,feature_c", Array, "comma-separated list of feature flags to be disabled (defaults: ${opts[:to_be_disabled]})") { |v|
opts[:to_be_disabled] = v.uniq
puts "- Specified feature flags to be disabled"
puts opts[:to_be_disabled].map { |f| format("--- %<opt>s", opt: f) }
}
op.on("-e", "--enable feature_a,feature_b,feature_c", Array, "comma-separated list of feature flags to be enabled (defaults: ${opts[:to_be_enabled]})") { |v|
opts[:to_be_enabled] = v.uniq
puts "- Specified feature flags to be enabled"
puts opts[:to_be_enabled].map { |f| format("--- %<opt>s", opt: f) }
}

begin
Expand All @@ -58,8 +62,6 @@ def parse_options(argv = ARGV)
def run
succeed, opts, args = parse_options
if succeed
puts "- specified feature flags: #{opts.to_s}"

available_flags = self.available_feature_flags
disable_targets = available_flags & opts[:to_be_disabled]
enable_targets = available_flags & opts[:to_be_disabled]
Expand All @@ -76,7 +78,8 @@ def run
invalid_disable_targets = opts[:to_be_disabled] - disable_targets
invalid_targets = invalid_disable_targets | invalid_enable_targets
if invalid_targets.length > 0
puts "- Following flags are probably invalid and have been ignored: #{invalid_enable_targets.to_a.join(",")}"
puts "- Following flags are probably invalid and have been ignored"
puts invalid_targets.map { |f| format("--- %<name>s", name: f) }
end
end

Expand Down

0 comments on commit 351711c

Please sign in to comment.