Class: ConfigKit::Cli::Deploy

Inherits:
Command
  • Object
show all
Defined in:
lib/config_kit/cli/commands/deploy.rb

Instance Attribute Summary

Attributes inherited from Command

#leftover

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

inherited, run

Constructor Details

#initialize(args) ⇒ Deploy

Returns a new instance of Deploy.



5
6
7
8
9
10
# File 'lib/config_kit/cli/commands/deploy.rb', line 5

def initialize(args)
  @app = nil
  @version = nil
  super(args)
  check_args
end

Class Method Details

.commandObject



3
# File 'lib/config_kit/cli/commands/deploy.rb', line 3

def self.command; "deploy"; end

Instance Method Details

#check_argsObject



12
13
14
15
# File 'lib/config_kit/cli/commands/deploy.rb', line 12

def check_args
  raise ConfigKit::Cli::Command::CommandFailure.new "Missing app parameters" if @app.nil?
  raise ConfigKit::Cli::Command::CommandFailure.new "Missing version parameters" if @version.nil?
end

#runObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/config_kit/cli/commands/deploy.rb', line 17

def run
  begin
    ConfigKit.logger.debug "Run command #{self.class.command} with options #{@app}:#{@version}"
    @output = ConfigKit::Manager.deploy(@app, @version)
    pp @output.to_h.to_json
  rescue ConfigKit::Cli::Command::CommandFailure
    raise
  rescue => e
    ConfigKit.logger.error "Unexpected error attempting to get config data #{@uri} in env #{@env} for #{@app.nil? ? 'all' : @app}"
    ConfigKit.logger.debug "#{e}: #{e.backtrace.join("\n   ")}"
    raise ConfigKit::Cli::Command::CommandFailure.new(e.to_s)
  end
end