Class: CFnDK::Command
- Inherits:
-
Thor
- Object
- Thor
- CFnDK::Command
- Includes:
- ConfigFileLoadable, Thor::Actions
- Defined in:
- lib/cfndk/command.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #generate_uuid ⇒ Object
- #help(command = nil, subcommand = false) ⇒ Object
- #init ⇒ Object
- #report ⇒ Object
- #version ⇒ Object
Class Method Details
.exit_on_failure? ⇒ Boolean
6 7 8 |
# File 'lib/cfndk/command.rb', line 6 def exit_on_failure? true end |
Instance Method Details
#create ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/cfndk/command.rb', line 49 def create CFnDK.logger.info 'create...'.color(:green) data = load_config_data() credentials = CFnDK::CredentialProviderChain.new.resolve stacks = CFnDK::Stacks.new(data, , credentials) keypairs = CFnDK::KeyPairs.new(data, , credentials) stacks.validate keypairs.create stacks.create return 0 rescue => e CFnDK.logger.error "#{e.class}: #{e.}".color(:red) e.backtrace_locations.each do |line| CFnDK.logger.debug line end return 1 end |
#destroy ⇒ Object
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/cfndk/command.rb', line 73 def destroy CFnDK.logger.info 'destroy...'.color(:green) data = load_config_data() credentials = CFnDK::CredentialProviderChain.new.resolve stacks = CFnDK::Stacks.new(data, , credentials) keypairs = CFnDK::KeyPairs.new(data, , credentials) if [:force] || yes?('Are you sure you want to destroy? (y/n)', :yellow) stacks.destroy keypairs.destroy return 0 else CFnDK.logger.info 'destroy command was canceled'.color(:green) return 2 end rescue => e CFnDK.logger.error "#{e.class}: #{e.}".color(:red) e.backtrace_locations.each do |line| CFnDK.logger.debug line end return 1 end |
#generate_uuid ⇒ Object
20 21 22 23 |
# File 'lib/cfndk/command.rb', line 20 def generate_uuid puts SecureRandom.uuid 0 end |
#help(command = nil, subcommand = false) ⇒ Object
11 12 13 14 |
# File 'lib/cfndk/command.rb', line 11 def help(command = nil, subcommand = false) super(command, subcommand) 2 end |
#init ⇒ Object
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/cfndk/command.rb', line 32 def init config_path = "#{Dir.getwd}/cfndk.yml" if File.file?(config_path) CFnDK.logger.error "File exist. #{config_path}".color(:red) return 1 end CFnDK.logger.info 'init...'.color(:green) FileUtils.cp_r(Dir.glob(File.dirname(__FILE__) + '/../../skel/*'), './') CFnDK.logger.info "create #{config_path}".color(:green) end |
#report ⇒ Object
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/cfndk/command.rb', line 102 def report CFnDK.logger.info 'report...'.color(:green) data = load_config_data() credentials = CFnDK::CredentialProviderChain.new.resolve stacks = CFnDK::Stacks.new(data, , credentials) stacks.report return 0 rescue => e CFnDK.logger.error "#{e.class}: #{e.}".color(:red) e.backtrace_locations.each do |line| CFnDK.logger.debug line end return 1 end |