Class: ECSUtil::Runner

Inherits:
Object
  • Object
show all
Includes:
Terraform
Defined in:
lib/ecsutil/runner.rb

Instance Method Summary collapse

Methods included from Terraform

#read_terraform_outputs

Constructor Details

#initialize(dir, args) ⇒ Runner

Returns a new instance of Runner.



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/ecsutil/runner.rb', line 18

def initialize(dir, args)
  stage         = args.shift
  command       = args.shift
  command_parts = command&.split(":", 2)
  
  @dir         = dir
  @stage       = stage
  @command     = command_parts&.shift
  @args        = args
  @action      = command_parts&.shift
  @config_path = File.join(@dir, "deploy", "#{stage}.yml")
end

Instance Method Details

#runObject



31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/ecsutil/runner.rb', line 31

def run
  return print_help unless @command
  return terminate("Please provide stage") unless @stage

  config = read_config
  
  klass = command_class(@command)
  if !klass
    terminate "Invalid command: #{@command}"
  end

  klass.new(config, @action, @args).run
end