Class: Kdep::Commands::Env

Inherits:
Object
  • Object
show all
Defined in:
lib/kdep/commands/env.rb

Overview

Dispatcher for ‘kdep env <subcommand>`. Currently only `check` is wired.

Constant Summary collapse

SUBCOMMANDS =
%w[check].freeze

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(global_options:, command_options:, args:) ⇒ Env

Returns a new instance of Env.



20
21
22
23
24
25
# File 'lib/kdep/commands/env.rb', line 20

def initialize(global_options:, command_options:, args:)
  @global_options = global_options
  @command_options = command_options
  @args = args
  @ui = Kdep::UI.new
end

Class Method Details

.option_parserObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/kdep/commands/env.rb', line 9

def self.option_parser
  OptionParser.new do |opts|
    opts.banner = "Usage: kdep env <subcommand> [options] [deploy] [env]"
    opts.separator ""
    opts.separator "Subcommands:"
    opts.separator "  check    Validate ConfigMap+Secret in cluster against env.spec"
    opts.separator ""
    opts.on("--env=ENV", "Environment scope (production|staging|dev)")
  end
end

Instance Method Details

#executeObject



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/kdep/commands/env.rb', line 27

def execute
  sub = @args.shift
  unless SUBCOMMANDS.include?(sub)
    @ui.error("Unknown subcommand: #{sub.inspect}. Available: #{SUBCOMMANDS.join(', ')}")
    exit 2
  end

  case sub
  when "check"
    require "kdep/commands/env_check"
    Kdep::Commands::EnvCheck.new(
      global_options: @global_options,
      command_options: @command_options,
      args: @args
    ).execute
  end
end