Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add and change logging for flipper initializer #18575

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions config/initializers/flipper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,12 @@

Flipper::UI.configuration.feature_creation_enabled = false
# Make sure that each feature we reference in code is present in the UI, as long as we have a Database already
added_flippers = []
begin
FLIPPER_FEATURE_CONFIG['features'].each do |feature, feature_config|
unless Flipper.exist?(feature)
Flipper.add(feature)
added_flippers.push(feature)

# Default features to enabled for test and those explicitly set for development
if Rails.env.test? || (Rails.env.development? && feature_config['enable_in_development'])
Expand All @@ -57,9 +59,13 @@
Flipper.enable(feature) if Settings.vsp_environment == 'development' && feature_config['enable_in_development']
end

Rails.logger.info "The following feature flippers were added: #{added_flippers}" unless added_flippers.empty?
removed_features = Flipper.features.collect(&:name) - FLIPPER_FEATURE_CONFIG['features'].keys
Rails.logger.warn "Consider removing features no longer in config/features.yml: #{removed_features.join(', ')}"
rescue
unless removed_features.empty?
Rails.logger.warn "Consider removing features no longer in config/features.yml: #{removed_features.join(', ')}"
end
rescue => e
Rails.logger.error "Error processing Flipper features: #{e.message}"
# make sure we can still run rake tasks before table has been created
nil
end
Expand Down
Loading