diff options
author | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-06-02 13:41:30 +0200 |
---|---|---|
committer | Pawel Chojnacki <pawel@chojnacki.ws> | 2017-06-02 19:46:29 +0200 |
commit | e21b1501ff16de7657a4a5eccb3b8124ba07709c (patch) | |
tree | 513d81fa14bde7c31987e9377d8929865f174f58 /db/fixtures | |
parent | 7b75004d603618d67aa50574bfc80627a6eaf72b (diff) | |
download | gitlab-ce-e21b1501ff16de7657a4a5eccb3b8124ba07709c.tar.gz |
Allow enabling Prometheus metrics via ENV variable when db is seeded
Diffstat (limited to 'db/fixtures')
-rw-r--r-- | db/fixtures/production/010_settings.rb | 27 |
1 files changed, 20 insertions, 7 deletions
diff --git a/db/fixtures/production/010_settings.rb b/db/fixtures/production/010_settings.rb index 5522f31629a..7978ceefa79 100644 --- a/db/fixtures/production/010_settings.rb +++ b/db/fixtures/production/010_settings.rb @@ -1,16 +1,29 @@ -if ENV['GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN'].present? - settings = ApplicationSetting.current || ApplicationSetting.create_from_defaults - settings.set_runners_registration_token(ENV['GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN']) - +def save(settings, topic) if settings.save - puts "Saved Runner Registration Token".color(:green) + puts "Saved #{topic}".color(:green) else - puts "Could not save Runner Registration Token".color(:red) + puts "Could not save #{topic}".color(:red) puts settings.errors.full_messages.map do |message| puts "--> #{message}".color(:red) end puts - exit 1 + exit(1) + end +end + +envs = %w{ GITLAB_PROMETHEUS_METRICS_ENABLED GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN } + +if envs.any? {|env_name| ENV[env_name].present? } + settings = ApplicationSetting.current || ApplicationSetting.create_from_defaults + if ENV['GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN'].present? + settings.set_runners_registration_token(ENV['GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN']) + save(settings, 'Runner Registration Token') + end + + if ENV['GITLAB_PROMETHEUS_METRICS_ENABLED'].present? + value = Gitlab::Utils.to_boolean(ENV['GITLAB_PROMETHEUS_METRICS_ENABLED']) + settings.prometheus_metrics_enabled = value + save(settings, 'GITLAB_PROMETHEUS_METRICS_ENABLED') end end |