gitlab-org--gitlab-foss/lib/system_check.rb

31 lines
1.1 KiB
Ruby
Raw Normal View History

# Library to perform System Checks
#
# Every Check is implemented as its own class inherited from SystemCheck::BaseCheck
# Execution coordination and boilerplate output is done by the SystemCheck::SimpleExecutor
#
# This structure decouples checks from Rake tasks and facilitates unit-testing
module SystemCheck
# Executes a bunch of checks for specified component
#
# @param [String] component name of the component relative to the checks being executed
# @param [Array<BaseCheck>] checks classes of corresponding checks to be executed in the same order
# @param [BaseExecutor] executor_klass optionally specifiy a different executor class
def self.run(component, checks = [], executor_klass = SimpleExecutor)
2017-02-13 11:20:56 +00:00
unless executor_klass < BaseExecutor
raise ArgumentError, 'Invalid executor'
end
prepare(component, checks, executor_klass).execute
end
def self.prepare(component, checks = [], executor_klass = SimpleExecutor)
executor = executor_klass.new(component)
checks.each do |check|
executor << check
end
executor
end
private_class_method :prepare
end