Class: SystemCheck::BaseCheck
- Inherits:
-
Object
- Object
- SystemCheck::BaseCheck
- Includes:
- Helpers
- Defined in:
- lib/system_check/base_check.rb
Overview
Base class for Checks. You must inherit from here and implement the methods below when necessary
Direct Known Subclasses
App::ActiveUsersCheck, App::AuthorizedKeysPermissionCheck, App::DatabaseConfigExistsCheck, App::GitUserDefaultSSHConfigCheck, App::GitlabCableConfigExistsCheck, App::GitlabConfigExistsCheck, App::GitlabConfigUpToDateCheck, App::GitlabResqueConfigExistsCheck, App::HashedStorageAllProjectsCheck, App::HashedStorageEnabledCheck, App::LogWritableCheck, App::MigrationsAreUpCheck, App::OrphanedGroupMembersCheck, App::ProjectsHaveNamespaceCheck, App::RedisVersionCheck, App::RubyVersionCheck, App::SystemdUnitFilesOrInitScriptExistCheck, App::SystemdUnitFilesOrInitScriptUpToDateCheck, App::TableTruncateCheck, App::TmpWritableCheck, App::UploadsDirectoryExistsCheck, App::UploadsPathPermissionCheck, App::UploadsPathTmpPermissionCheck, GitalyCheck, GitlabShellCheck, IncomingEmail::ImapAuthenticationCheck, IncomingEmail::MailRoomEnabledCheck, IncomingEmail::MailRoomRunningCheck, IncomingEmailCheck, LdapCheck, SidekiqCheck
Instance Attribute Summary collapse
-
#skip_reason ⇒ String
Define or get a reason why we skipped the SystemCheck (during runtime).
Class Method Summary collapse
-
.check_fail ⇒ String
Term to be displayed when check failed.
-
.check_pass ⇒ String
Term to be displayed when check passed.
-
.display_name ⇒ String
Name of the SystemCheck defined by the subclass.
-
.set_check_fail(term) ⇒ Object
Define a custom term for when check failed.
-
.set_check_pass(term) ⇒ Object
Define a custom term for when check passed.
-
.set_name(name) ⇒ Object
Define the name of the SystemCheck that will be displayed during execution.
-
.set_skip_reason(reason) ⇒ Object
Define the reason why we skipped the SystemCheck.
-
.skip_reason ⇒ String
Skip reason defined by the subclass.
Instance Method Summary collapse
-
#can_repair? ⇒ Boolean
Does the check support automatically repair routine?.
- #can_skip? ⇒ Boolean
-
#check? ⇒ Boolean
Execute the check routine.
-
#multi_check ⇒ Object
Execute a custom check that cover multiple unities.
- #multi_check? ⇒ Boolean
-
#repair! ⇒ Object
When implemented by a subclass, will attempt to fix the issue automatically.
-
#show_error ⇒ Object
Prints troubleshooting instructions.
-
#skip? ⇒ Boolean
When implemented by a subclass, will evaluate whether check should be skipped or not.
Methods included from Helpers
#construct_help_page_url, #finished_checking, #fix_and_rerun, #for_more_information, #omnibus_gitlab?, #sanitized_message, #see_installation_guide_section, #should_sanitize?, #start_checking, #sudo_gitlab, #try_fixing_it
Methods included from Gitlab::TaskHelpers
#ask_to_continue, #checkout_or_clone_version, #checkout_version, #clone_repo, #download_package_file_version, #get_version, #gid_for, #gitlab_user, #gitlab_user?, #invoke_and_time_task, #os_name, #prompt, #prompt_for_password, #run_and_match, #run_command, #run_command!, #uid_for, #user_home, #warn_user_is_not_gitlab
Instance Attribute Details
#skip_reason ⇒ String
Define or get a reason why we skipped the SystemCheck (during runtime)
This is used when you need dynamic evaluation like when you have multiple reasons why a check can fail
74 75 76 |
# File 'lib/system_check/base_check.rb', line 74 def skip_reason @skip_reason end |
Class Method Details
.check_fail ⇒ String
Term to be displayed when check failed
49 50 51 |
# File 'lib/system_check/base_check.rb', line 49 def self.check_fail call_or_return(@check_fail) || 'no' end |
.check_pass ⇒ String
Term to be displayed when check passed
42 43 44 |
# File 'lib/system_check/base_check.rb', line 42 def self.check_pass call_or_return(@check_pass) || 'yes' end |
.display_name ⇒ String
Name of the SystemCheck defined by the subclass
56 57 58 |
# File 'lib/system_check/base_check.rb', line 56 def self.display_name call_or_return(@name) || self.name end |
.set_check_fail(term) ⇒ Object
Define a custom term for when check failed
19 20 21 |
# File 'lib/system_check/base_check.rb', line 19 def self.set_check_fail(term) @check_fail = term end |
.set_check_pass(term) ⇒ Object
Define a custom term for when check passed
12 13 14 |
# File 'lib/system_check/base_check.rb', line 12 def self.set_check_pass(term) @check_pass = term end |
.set_name(name) ⇒ Object
Define the name of the SystemCheck that will be displayed during execution
26 27 28 |
# File 'lib/system_check/base_check.rb', line 26 def self.set_name(name) @name = name end |
.set_skip_reason(reason) ⇒ Object
Define the reason why we skipped the SystemCheck
This is only used if subclass implements ‘#skip?`
35 36 37 |
# File 'lib/system_check/base_check.rb', line 35 def self.set_skip_reason(reason) @skip_reason = reason end |
.skip_reason ⇒ String
Skip reason defined by the subclass
63 64 65 |
# File 'lib/system_check/base_check.rb', line 63 def self.skip_reason call_or_return(@skip_reason) || 'skipped' end |
Instance Method Details
#can_repair? ⇒ Boolean
Does the check support automatically repair routine?
79 80 81 |
# File 'lib/system_check/base_check.rb', line 79 def can_repair? self.class.instance_methods(false).include?(:repair!) end |
#can_skip? ⇒ Boolean
83 84 85 |
# File 'lib/system_check/base_check.rb', line 83 def can_skip? self.class.instance_methods(false).include?(:skip?) end |
#check? ⇒ Boolean
Execute the check routine
This is where you should implement the main logic that will return a boolean at the end
You should not print any output to STDOUT here, use the specific methods instead
99 100 101 |
# File 'lib/system_check/base_check.rb', line 99 def check? raise NotImplementedError end |
#multi_check ⇒ Object
Execute a custom check that cover multiple unities
When using multi_check you have to provide the output yourself
106 107 108 |
# File 'lib/system_check/base_check.rb', line 106 def multi_check raise NotImplementedError end |
#multi_check? ⇒ Boolean
87 88 89 |
# File 'lib/system_check/base_check.rb', line 87 def multi_check? self.class.instance_methods(false).include?(:multi_check) end |
#repair! ⇒ Object
When implemented by a subclass, will attempt to fix the issue automatically
124 125 126 |
# File 'lib/system_check/base_check.rb', line 124 def repair! raise NotImplementedError end |
#show_error ⇒ Object
Prints troubleshooting instructions
This is where you should print detailed information for any error found during #check?
You may use helper methods to help format the output:
119 120 121 |
# File 'lib/system_check/base_check.rb', line 119 def show_error raise NotImplementedError end |
#skip? ⇒ Boolean
When implemented by a subclass, will evaluate whether check should be skipped or not
131 132 133 |
# File 'lib/system_check/base_check.rb', line 131 def skip? raise NotImplementedError end |