Class: GDK::Command::BaseCommand
- Inherits:
-
Object
- Object
- GDK::Command::BaseCommand
- Defined in:
- lib/gdk/command/base_command.rb
Overview
Base interface for GDK commands
Direct Known Subclasses
Bao, Cells, Cleanup, Clickhouse, Config, DebugInfo, DiffConfig, Doctor, Env, Evaluate, Help, Install, Kill, MeasureBase, Open, Pristine, Psql, PsqlGeo, Rails, Reconfigure, RedisCli, ResetData, ResetPraefectData, Restart, Run, Start, Status, Stop, Tail, Telemetry, Thin, TruncateLegacyTables, Trust, Update, Version
Instance Attribute Summary collapse
-
#stderr ⇒ Object
readonly
Returns the value of attribute stderr.
-
#stdout ⇒ Object
readonly
Returns the value of attribute stdout.
Class Method Summary collapse
-
.validate_config? ⇒ Boolean
Ensure that gdk.yml is valid by default.
Instance Method Summary collapse
- #config ⇒ Object protected
- #display_help_message ⇒ Object protected
- #help ⇒ Object
-
#initialize(stdout: GDK::Output, stderr: GDK::Output) ⇒ BaseCommand
constructor
A new instance of BaseCommand.
- #print_help(args) ⇒ Object protected
- #print_ready_message ⇒ Object protected
-
#ready_messages ⇒ Object
protected
rubocop:disable Metrics/AbcSize – Just simple if statements.
- #run(args = []) ⇒ Object
Constructor Details
#initialize(stdout: GDK::Output, stderr: GDK::Output) ⇒ BaseCommand
Returns a new instance of BaseCommand.
14 15 16 17 |
# File 'lib/gdk/command/base_command.rb', line 14 def initialize(stdout: GDK::Output, stderr: GDK::Output) @stdout = stdout @stderr = stderr end |
Instance Attribute Details
#stderr ⇒ Object (readonly)
Returns the value of attribute stderr.
7 8 9 |
# File 'lib/gdk/command/base_command.rb', line 7 def stderr @stderr end |
#stdout ⇒ Object (readonly)
Returns the value of attribute stdout.
7 8 9 |
# File 'lib/gdk/command/base_command.rb', line 7 def stdout @stdout end |
Class Method Details
.validate_config? ⇒ Boolean
Ensure that gdk.yml is valid by default.
10 11 12 |
# File 'lib/gdk/command/base_command.rb', line 10 def self.validate_config? true end |
Instance Method Details
#config ⇒ Object (protected)
29 30 31 |
# File 'lib/gdk/command/base_command.rb', line 29 def config GDK.config end |
#display_help_message ⇒ Object (protected)
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/gdk/command/base_command.rb', line 41 def GDK::Output.divider(length: 55) GDK::Output.puts <<~HELP_MESSAGE You can try the following that may be of assistance: - Run 'gdk doctor'. - Visit the troubleshooting documentation: https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/troubleshooting/index.md. - Visit https://gitlab.com/gitlab-org/gitlab-development-kit/-/issues to see if there are known issues. - Run 'gdk reset-data' if appropriate. - Run 'gdk pristine' which will restore your GDK to a pristine state. HELP_MESSAGE GDK::Output.divider(length: 55) end |
#help ⇒ Object
23 24 25 |
# File 'lib/gdk/command/base_command.rb', line 23 def help raise NotImplementedError end |
#print_help(args) ⇒ Object (protected)
33 34 35 36 37 38 39 |
# File 'lib/gdk/command/base_command.rb', line 33 def print_help(args) return false unless (args & ['-h', '--help']).any? GDK::Output.puts(help) true end |
#print_ready_message ⇒ Object (protected)
59 60 61 62 63 64 65 |
# File 'lib/gdk/command/base_command.rb', line 59 def notices = return if notices.empty? GDK::Output.puts notices.each { |msg| GDK::Output.notice(msg) } end |
#ready_messages ⇒ Object (protected)
rubocop:disable Metrics/AbcSize – Just simple if statements
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/gdk/command/base_command.rb', line 68 def notices = [] if config.rails_web? debug_info = GDK::Command::DebugInfo.new notices << "GitLab available at #{config.__uri}." notices << " - Ruby: #{debug_info.ruby_version}." notices << " - Node.js: #{debug_info.node_version}." end notices << "GitLab Docs available at #{config.gitlab_docs.__uri}." if config.gitlab_docs? if config.gitlab_k8s_agent? notices << "GitLab Agent Server (KAS) available at #{config.gitlab_k8s_agent.__url_for_agentk}." notices << "Kubernetes proxy (via KAS) available at #{config.gitlab_k8s_agent.__k8s_api_url}." end notices << "GitLab AI Gateway is available at #{config.gitlab_ai_gateway.__listen}/docs." if config.gitlab_ai_gateway? notices << "Prometheus available at #{config.prometheus.__uri}." if config.prometheus? notices << "Grafana available at #{config.grafana.__uri}." if config.grafana? notices << "A container registry is available at #{config.registry.__listen}." if config.registry? notices << GDK::Services::GitlabHttpRouter.new. if config.gitlab_http_router? notices << GDK::Services::GitlabTopologyService.new. if config.gitlab_topology_service? notices end |
#run(args = []) ⇒ Object
19 20 21 |
# File 'lib/gdk/command/base_command.rb', line 19 def run(args = []) raise NotImplementedError end |