diff options
author | Gabriel Mazetto <brodock@gmail.com> | 2017-05-25 16:16:25 +0200 |
---|---|---|
committer | Gabriel Mazetto <brodock@gmail.com> | 2017-05-31 14:33:03 +0200 |
commit | 13e88c93956b5b350515b919ef7217a3dccf28ff (patch) | |
tree | 7ed964642da19c553697a7c737e11f55d058829e /lib/system_check/simple_executor.rb | |
parent | 45378bdd3aae75cb155677d91be61e3d39f5f515 (diff) | |
download | gitlab-ce-13e88c93956b5b350515b919ef7217a3dccf28ff.tar.gz |
Refactor gitlab:app:checks to use SystemCheck
Diffstat (limited to 'lib/system_check/simple_executor.rb')
-rw-r--r-- | lib/system_check/simple_executor.rb | 49 |
1 files changed, 40 insertions, 9 deletions
diff --git a/lib/system_check/simple_executor.rb b/lib/system_check/simple_executor.rb index fc07f09dcb2..7a5042047ab 100644 --- a/lib/system_check/simple_executor.rb +++ b/lib/system_check/simple_executor.rb @@ -10,20 +10,51 @@ module SystemCheck start_checking(component) @checks.each do |check| - $stdout.print "#{check.name}" - if check.skip? - $stdout.puts "skipped #{'(' + skip_message + ')' if skip_message}".color(:magenta) - elsif check.check? - $stdout.puts 'yes'.color(:green) - else - $stdout.puts 'no'.color(:red) - check.show_error - end + run_check(check) end finished_checking(component) end + # Executes a single check + # + # @param [SystemCheck::BaseCheck] check + def run_check(check) + $stdout.print "#{check.display_name} ... " + + c = check.new + + # When implements a multi check, we don't control the output + if c.is_multi_check? + c.multi_check + return + end + + # When implements skip method, we run it first, and if true, skip the check + if c.can_skip? && c.skip? + $stdout.puts check.skip_reason.color(:magenta) + return + end + + if c.check? + $stdout.puts check.check_pass.color(:green) + else + $stdout.puts check.check_fail.color(:red) + + if c.can_repair? + $stdout.print 'Trying to fix error automatically. ...' + if c.repair! + $stdout.puts 'Success'.color(:green) + return + else + $stdout.puts 'Failed'.color(:red) + end + end + + c.show_error + end + end + private # Prints header content for the series of checks to be executed for this component |