Class: CFnDK::Command
- Inherits:
-
Thor
- Object
- Thor
- CFnDK::Command
- Includes:
- ConfigFileLoadable, CredentialResolvable, 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
8 9 10 |
# File 'lib/cfndk/command.rb', line 8 def exit_on_failure? true end |
Instance Method Details
#create ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/cfndk/command.rb', line 51 def create CFnDK.logger.info 'create...'.color(:green) data = load_config_data() credentials = resolve_credential(data, ) global_config = CFnDK::GlobalConfig.new(data, ) stacks = CFnDK::Stacks.new(data, , credentials) keypairs = CFnDK::KeyPairs.new(data, , credentials) global_config.pre_command_execute stacks.pre_command_execute stacks.validate keypairs.pre_command_execute keypairs.create keypairs.post_command_execute stacks.create stacks.post_command_execute global_config.post_command_execute 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
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/cfndk/command.rb', line 81 def destroy CFnDK.logger.info 'destroy...'.color(:green) data = load_config_data() credentials = resolve_credential(data, ) 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
22 23 24 25 |
# File 'lib/cfndk/command.rb', line 22 def generate_uuid puts SecureRandom.uuid 0 end |
#help(command = nil, subcommand = false) ⇒ Object
13 14 15 16 |
# File 'lib/cfndk/command.rb', line 13 def help(command = nil, subcommand = false) super(command, subcommand) 2 end |
#init ⇒ Object
34 35 36 37 38 39 40 41 42 43 |
# File 'lib/cfndk/command.rb', line 34 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
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/cfndk/command.rb', line 110 def report CFnDK.logger.info 'report...'.color(:green) data = load_config_data() credentials = resolve_credential(data, ) 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 |