BigW Consortium Gitlab

010_settings.rb 854 Bytes
Newer Older
1
def save(settings, topic)
2
  if settings.save
3
    puts "Saved #{topic}".color(:green)
4
  else
5
    puts "Could not save #{topic}".color(:red)
6 7 8 9 10
    puts
    settings.errors.full_messages.map do |message|
      puts "--> #{message}".color(:red)
    end
    puts
11 12 13 14
    exit(1)
  end
end

15 16 17 18 19
if ENV['GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN'].present?
  settings = Gitlab::CurrentSettings.current_application_settings
  settings.set_runners_registration_token(ENV['GITLAB_SHARED_RUNNERS_REGISTRATION_TOKEN'])
  save(settings, 'Runner Registration Token')
end
20

21 22
if ENV['GITLAB_PROMETHEUS_METRICS_ENABLED'].present?
  settings = Gitlab::CurrentSettings.current_application_settings
23
  value = Gitlab::Utils.to_boolean(ENV['GITLAB_PROMETHEUS_METRICS_ENABLED']) || false
24 25
  settings.prometheus_metrics_enabled = value
  save(settings, 'Prometheus metrics enabled flag')
26
end