diff options
author | syasonik <syasonik@gitlab.com> | 2019-04-25 09:00:51 +0300 |
---|---|---|
committer | syasonik <syasonik@gitlab.com> | 2019-04-25 09:00:51 +0300 |
commit | 8926b37d5b0c48b9ef89e4769e622563a9b11e9f (patch) | |
tree | 8cd60768669a5a8d277356cb77a021aaae9da86a /lib | |
parent | 4a5c48c47cccd8ce2b6bd6912ecff925122778f0 (diff) |
Prefer safe_load and deep_symbolize_keys
Diffstat (limited to 'lib')
-rw-r--r-- | lib/gitlab/metrics/dashboard/processor.rb | 13 | ||||
-rw-r--r-- | lib/gitlab/metrics/dashboard/service.rb | 4 |
2 files changed, 8 insertions, 9 deletions
diff --git a/lib/gitlab/metrics/dashboard/processor.rb b/lib/gitlab/metrics/dashboard/processor.rb index 36de1d033f2..46fd2f9440d 100644 --- a/lib/gitlab/metrics/dashboard/processor.rb +++ b/lib/gitlab/metrics/dashboard/processor.rb @@ -21,13 +21,12 @@ module Gitlab # Returns a new dashboard hash with the results of # running transforms on the dashboard. - def process(dashboard) - dashboard = dashboard.deep_symbolize_keys - - stage_params = [@project, @environment] - sequence.each { |stage| stage.new(*stage_params).transform!(dashboard) } - - dashboard + def process(raw_dashboard) + raw_dashboard.deep_symbolize_keys.tap do |dashboard| + sequence.each do |stage| + stage.new(@project, @environment).transform!(dashboard) + end + end end private diff --git a/lib/gitlab/metrics/dashboard/service.rb b/lib/gitlab/metrics/dashboard/service.rb index 966d7279aef..b8f144a7222 100644 --- a/lib/gitlab/metrics/dashboard/service.rb +++ b/lib/gitlab/metrics/dashboard/service.rb @@ -23,7 +23,7 @@ module Gitlab # Returns the base metrics shipped with every GitLab service. def system_dashboard - YAML.load_file(SYSTEM_DASHBOARD_PATH) + YAML.safe_load(File.read(SYSTEM_DASHBOARD_PATH)) end def cache_key @@ -32,7 +32,7 @@ module Gitlab # Returns a new dashboard Hash, supplemented with DB info def process_dashboard(dashboard) - Processor.new(project, params[:environment]).process(dashboard) + Gitlab::Metrics::Dashboard::Processor.new(project, params[:environment]).process(dashboard) end end end |