cfndk 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.circleci/config.yml +23 -14
- data/.gitignore +0 -1
- data/.rspec_parallel +6 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +811 -0
- data/README.md +122 -10
- data/cfndk.gemspec +1 -0
- data/lib/cfndk/change_set_command.rb +97 -0
- data/lib/cfndk/command.rb +15 -181
- data/lib/cfndk/config_file_loadable.rb +13 -0
- data/lib/cfndk/global_config.rb +15 -0
- data/lib/cfndk/key_pair.rb +7 -4
- data/lib/cfndk/key_pair_command.rb +53 -0
- data/lib/cfndk/key_pairs.rb +2 -1
- data/lib/cfndk/logger.rb +1 -1
- data/lib/cfndk/stack.rb +382 -103
- data/lib/cfndk/stack_command.rb +110 -0
- data/lib/cfndk/stacks.rb +40 -14
- data/lib/cfndk/subcommand_help_returnable.rb +16 -0
- data/lib/cfndk/version.rb +1 -1
- data/lib/cfndk.rb +6 -0
- data/skel/cfndk.yml +4 -0
- data/spec/cfndk_change_set_create_spec.rb +436 -0
- data/spec/cfndk_change_set_destroy_spec.rb +160 -0
- data/spec/cfndk_change_set_execute_spec.rb +179 -0
- data/spec/cfndk_change_set_report_spec.rb +107 -0
- data/spec/cfndk_change_set_spec.rb +37 -0
- data/spec/cfndk_create_spec.rb +56 -141
- data/spec/cfndk_destroy_spec.rb +4 -2
- data/spec/cfndk_keypiar_spec.rb +11 -9
- data/spec/cfndk_report_spec.rb +3 -1
- data/spec/cfndk_spec.rb +5 -3
- data/spec/cfndk_stack_create_spec.rb +454 -0
- data/spec/cfndk_stack_destroy_spec.rb +161 -0
- data/spec/cfndk_stack_report_spec.rb +181 -0
- data/spec/cfndk_stack_spec.rb +6 -1146
- data/spec/cfndk_stack_update_spec.rb +467 -0
- data/spec/spec_helper.rb +4 -1
- data/spec/support/aruba.rb +1 -0
- metadata +42 -2
@@ -0,0 +1,53 @@
|
|
1
|
+
module CFnDK
|
2
|
+
class KeyPairCommand < Thor
|
3
|
+
include SubcommandHelpReturnable
|
4
|
+
include ConfigFileLoadable
|
5
|
+
class_option :verbose, type: :boolean, aliases: 'v', desc: 'More verbose output.'
|
6
|
+
class_option :color, type: :boolean, default: true, desc: 'Use colored output'
|
7
|
+
class_option :config_path, type: :string, aliases: 'c', default: "#{Dir.getwd}/cfndk.yml", desc: 'The configuration file to use'
|
8
|
+
class_option :uuid, type: :string, aliases: 'u', default: ENV['CFNDK_UUID'] || nil, desc: 'Use UUID'
|
9
|
+
class_option :keypair_names, type: :array, desc: 'Target keypair names'
|
10
|
+
|
11
|
+
desc 'create', 'Create keypair'
|
12
|
+
option :properties, type: :hash, aliases: 'p', default: {}, desc: 'Set property'
|
13
|
+
def create
|
14
|
+
CFnDK.logger.info 'create...'.color(:green)
|
15
|
+
data = load_config_data(options)
|
16
|
+
|
17
|
+
credentials = CFnDK::CredentialProviderChain.new.resolve
|
18
|
+
keypairs = CFnDK::KeyPairs.new(data, options, credentials)
|
19
|
+
keypairs.create
|
20
|
+
return 0
|
21
|
+
rescue => e
|
22
|
+
CFnDK.logger.error "#{e.class}: #{e.message}".color(:red)
|
23
|
+
e.backtrace_locations.each do |line|
|
24
|
+
CFnDK.logger.debug line
|
25
|
+
end
|
26
|
+
return 1
|
27
|
+
end
|
28
|
+
|
29
|
+
desc 'destroy', 'Destroy keypair'
|
30
|
+
option :force, type: :boolean, aliases: 'f', default: false, desc: 'Say yes to all prompts for confirmation'
|
31
|
+
def destroy
|
32
|
+
CFnDK.logger.info 'destroy...'.color(:green)
|
33
|
+
data = load_config_data(options)
|
34
|
+
|
35
|
+
credentials = CFnDK::CredentialProviderChain.new.resolve
|
36
|
+
keypairs = CFnDK::KeyPairs.new(data, options, credentials)
|
37
|
+
|
38
|
+
if options[:force] || yes?('Are you sure you want to destroy? (y/n)', :yellow)
|
39
|
+
keypairs.destroy
|
40
|
+
return 0
|
41
|
+
else
|
42
|
+
CFnDK.logger.info 'destroy command was canceled'.color(:green)
|
43
|
+
return 2
|
44
|
+
end
|
45
|
+
rescue => e
|
46
|
+
CFnDK.logger.error "#{e.class}: #{e.message}".color(:red)
|
47
|
+
e.backtrace_locations.each do |line|
|
48
|
+
CFnDK.logger.debug line
|
49
|
+
end
|
50
|
+
return 1
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/lib/cfndk/key_pairs.rb
CHANGED
@@ -3,6 +3,7 @@ module CFnDK
|
|
3
3
|
def initialize(data, option, credentials)
|
4
4
|
@option = option
|
5
5
|
@credentials = credentials
|
6
|
+
@global_config = CFnDK::GlobalConfig.new(data, option)
|
6
7
|
prepare_keypairs(data)
|
7
8
|
end
|
8
9
|
|
@@ -26,7 +27,7 @@ module CFnDK
|
|
26
27
|
@keypairs = {}
|
27
28
|
return unless data['keypairs']
|
28
29
|
data['keypairs'].each do |name, properties|
|
29
|
-
@keypairs[name] = KeyPair.new(name, properties, @option, @credentials)
|
30
|
+
@keypairs[name] = KeyPair.new(name, properties, @option, @global_config, @credentials)
|
30
31
|
end
|
31
32
|
end
|
32
33
|
end
|
data/lib/cfndk/logger.rb
CHANGED
@@ -11,7 +11,7 @@ module CFnDK
|
|
11
11
|
class CFnDKLogger < Logger
|
12
12
|
def initialize(options)
|
13
13
|
super(STDOUT)
|
14
|
-
self.level = Logger::INFO unless options[:
|
14
|
+
self.level = Logger::INFO unless options[:verbose]
|
15
15
|
self.formatter = proc { |severity, datetime, progname, message|
|
16
16
|
message.to_s.split(/\n/).map do |line|
|
17
17
|
"#{datetime} #{severity} #{line}\n"
|