kumo_keisei 1.0.0 → 2.0.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 359900941b787e935e12301f79e9689e4c930fd1
|
4
|
+
data.tar.gz: 1c4c3bf8d3341f174067f63ff7230ae3595d90c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b2f680a64a1f28a6322555182f81345f7aa168216ba60978e20490a9a7bf241bc560ef946747ec4ecbe0265079d60aafcca4e653c30203554d2ce406e1386db0
|
7
|
+
data.tar.gz: 5f699f518da44562cd9ca1b004e456d877e038c7a322d78817e78f60c5e9e7f5335e4576ee0e110cbe28c89653ee2c254e06e528e231746b0a94a15552b83b57
|
data/CHANGELOG.md
ADDED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
2.0.0
|
@@ -30,11 +30,11 @@ module KumoKeisei
|
|
30
30
|
self.new(stack_name, nil).exists?
|
31
31
|
end
|
32
32
|
|
33
|
-
def initialize(stack_name, stack_template, stack_params_filepath = nil)
|
33
|
+
def initialize(stack_name, stack_template, stack_params_filepath = nil, confirmation_timeout=30)
|
34
34
|
@stack_name = stack_name
|
35
35
|
@stack_template = stack_template
|
36
36
|
@stack_params_filepath = stack_params_filepath
|
37
|
-
|
37
|
+
@confirmation_timeout = confirmation_timeout
|
38
38
|
flash_message "Stack name: #{stack_name}"
|
39
39
|
end
|
40
40
|
|
@@ -51,6 +51,9 @@ module KumoKeisei
|
|
51
51
|
def destroy!
|
52
52
|
return if get_stack.nil?
|
53
53
|
|
54
|
+
flash_message "Warning! You are about to delete the CloudFormation Stack #{@stack_name}, enter 'yes' to continue."
|
55
|
+
return unless ConsoleJockey.get_confirmation(@confirmation_timeout)
|
56
|
+
|
54
57
|
wait_until_ready(false)
|
55
58
|
ensure_deleted!
|
56
59
|
end
|
@@ -1,5 +1,8 @@
|
|
1
|
+
require 'timeout'
|
2
|
+
|
1
3
|
module KumoKeisei
|
2
4
|
class ConsoleJockey
|
5
|
+
|
3
6
|
def self.flash_message(message)
|
4
7
|
puts "\n"
|
5
8
|
puts "###################=============================------------"
|
@@ -15,5 +18,18 @@ module KumoKeisei
|
|
15
18
|
|
16
19
|
$stdout.flush
|
17
20
|
end
|
21
|
+
|
22
|
+
def self.get_confirmation(timeout=30)
|
23
|
+
begin
|
24
|
+
status = Timeout::timeout(timeout) {
|
25
|
+
STDIN.gets.chomp
|
26
|
+
}
|
27
|
+
rescue
|
28
|
+
status = false
|
29
|
+
end
|
30
|
+
proceed = status == "yes"
|
31
|
+
proceed ? puts('Proceeding.') : puts('Aborted!')
|
32
|
+
proceed
|
33
|
+
end
|
18
34
|
end
|
19
35
|
end
|
@@ -27,12 +27,13 @@ describe KumoKeisei::CloudFormationStack do
|
|
27
27
|
let(:cf_stack_create_params) do
|
28
28
|
cf_stack_update_params.merge(on_failure: "DELETE")
|
29
29
|
end
|
30
|
-
|
31
|
-
subject(:instance) { KumoKeisei::CloudFormationStack.new(stack_name, stack_template_path, file_params_path) }
|
30
|
+
let(:confirmation_timeout) { 0.5 }
|
31
|
+
subject(:instance) { KumoKeisei::CloudFormationStack.new(stack_name, stack_template_path, file_params_path, confirmation_timeout) }
|
32
32
|
|
33
33
|
before do
|
34
34
|
allow(KumoKeisei::ConsoleJockey).to receive(:flash_message)
|
35
35
|
allow(KumoKeisei::ConsoleJockey).to receive(:write_line).and_return(nil)
|
36
|
+
allow(KumoKeisei::ConsoleJockey).to receive(:get_confirmation).with(confirmation_timeout).and_return(false)
|
36
37
|
allow(Aws::CloudFormation::Client).to receive(:new).and_return(cloudformation)
|
37
38
|
allow(cloudformation).to receive(:describe_stacks).with({stack_name: stack_name}).and_return(cf_stack)
|
38
39
|
allow(KumoKeisei::ParameterBuilder).to receive(:new).and_return(parameter_builder)
|
@@ -40,12 +41,21 @@ describe KumoKeisei::CloudFormationStack do
|
|
40
41
|
end
|
41
42
|
|
42
43
|
describe "#destroy!" do
|
44
|
+
it "notifies the user of what it is about to delete" do
|
45
|
+
expect(KumoKeisei::ConsoleJockey).to receive(:flash_message).with("Warning! You are about to delete the CloudFormation Stack #{stack_name}, enter 'yes' to continue.")
|
46
|
+
subject.destroy!
|
47
|
+
end
|
43
48
|
|
44
|
-
|
45
|
-
|
46
|
-
|
49
|
+
it "does delete the stack if the user confirms" do
|
50
|
+
expect(KumoKeisei::ConsoleJockey).to receive(:get_confirmation).with(confirmation_timeout).and_return(true)
|
51
|
+
expect(cloudformation).to receive(:delete_stack).with({stack_name: stack_name}).and_return(cf_stack)
|
52
|
+
allow(cloudformation).to receive(:wait_until).with(:stack_delete_complete, stack_name: stack_name).and_return(nil)
|
53
|
+
subject.destroy!
|
54
|
+
end
|
47
55
|
|
48
|
-
|
56
|
+
it "does not delete the stack if the the user refuses confirmation" do
|
57
|
+
expect(KumoKeisei::ConsoleJockey).to receive(:get_confirmation).with(confirmation_timeout).and_return(false)
|
58
|
+
subject.destroy!
|
49
59
|
end
|
50
60
|
|
51
61
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'ostruct'
|
3
|
+
|
4
|
+
describe KumoKeisei::ConsoleJockey do
|
5
|
+
describe "#get_confirmation" do
|
6
|
+
let(:timeout) { 0.5 }
|
7
|
+
subject { described_class }
|
8
|
+
|
9
|
+
context 'no timeout' do
|
10
|
+
|
11
|
+
it 'returns true if user enters yes' do
|
12
|
+
allow(STDIN).to receive(:gets) { 'yes'}
|
13
|
+
expect(subject.get_confirmation(timeout)).to be true
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'returns false if user enters anything other than yes' do
|
17
|
+
allow(STDIN).to receive(:gets) { 'aoisdjofa'}
|
18
|
+
expect(subject.get_confirmation).to be false
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
context 'timeout' do
|
23
|
+
it 'returns false if there is a timeout' do
|
24
|
+
expect(subject.get_confirmation(timeout)).to be false
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
end
|
29
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kumo_keisei
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Redbubble
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-05-
|
11
|
+
date: 2016-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk
|
@@ -89,6 +89,7 @@ extra_rdoc_files: []
|
|
89
89
|
files:
|
90
90
|
- ".buildkite/pipeline.yml"
|
91
91
|
- ".gitignore"
|
92
|
+
- CHANGELOG.md
|
92
93
|
- Gemfile
|
93
94
|
- LICENSE.txt
|
94
95
|
- README.md
|
@@ -105,6 +106,7 @@ files:
|
|
105
106
|
- script/release-gem
|
106
107
|
- script/unit_test.sh
|
107
108
|
- spec/lib/kumo_keisei/cloud_formation_stack_spec.rb
|
109
|
+
- spec/lib/kumo_keisei/console_jockey_spec.rb
|
108
110
|
- spec/lib/kumo_keisei/environment_config_spec.rb
|
109
111
|
- spec/lib/kumo_keisei/file_loader_spec.rb
|
110
112
|
- spec/lib/kumo_keisei/parameter_builder_spec.rb
|
@@ -135,6 +137,7 @@ specification_version: 4
|
|
135
137
|
summary: A collection of utilities for dealing with AWS Cloud Formation.
|
136
138
|
test_files:
|
137
139
|
- spec/lib/kumo_keisei/cloud_formation_stack_spec.rb
|
140
|
+
- spec/lib/kumo_keisei/console_jockey_spec.rb
|
138
141
|
- spec/lib/kumo_keisei/environment_config_spec.rb
|
139
142
|
- spec/lib/kumo_keisei/file_loader_spec.rb
|
140
143
|
- spec/lib/kumo_keisei/parameter_builder_spec.rb
|