awful 0.0.184 → 0.0.185
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/awful.rb +4 -0
- data/lib/awful/cloudformation.rb +17 -19
- data/lib/awful/s3.rb +17 -19
- data/lib/awful/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87f2a0676250644bd5230e35158ba527dd25ba96
|
4
|
+
data.tar.gz: fe588f61abad3ecc1fdcd4eb713abf8e954938c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bbd35722e545882c17ea07f6eaf3d387b1f323f26f007c329753c598394a51e5cb5e515b9a24a70675ce0c87c7b4b18c32f674cecd7cbe096e978c7dd2df515
|
7
|
+
data.tar.gz: e1b3fde92c3f5319bcd3eccd057f0dc6e7a0fe1f14db91c3fb419b1a9e7edf65cc859b974e6bcf41aff1aef7568fce9aac28d3614f4181c2be45c25a61600419
|
data/lib/awful.rb
CHANGED
data/lib/awful/cloudformation.rb
CHANGED
@@ -23,6 +23,16 @@ module Awful
|
|
23
23
|
rollback_complete: :red,
|
24
24
|
}
|
25
25
|
|
26
|
+
## stack statuses that are not DELETE_COMPLETE
|
27
|
+
STATUSES = %i[
|
28
|
+
CREATE_IN_PROGRESS CREATE_FAILED CREATE_COMPLETE
|
29
|
+
ROLLBACK_IN_PROGRESS ROLLBACK_FAILED ROLLBACK_COMPLETE
|
30
|
+
DELETE_IN_PROGRESS DELETE_FAILED
|
31
|
+
UPDATE_IN_PROGRESS UPDATE_COMPLETE_CLEANUP_IN_PROGRESS UPDATE_COMPLETE
|
32
|
+
UPDATE_ROLLBACK_IN_PROGRESS UPDATE_ROLLBACK_FAILED UPDATE_ROLLBACK_COMPLETE_CLEANUP_IN_PROGRESS UPDATE_ROLLBACK_COMPLETE
|
33
|
+
REVIEW_IN_PROGRESS
|
34
|
+
]
|
35
|
+
|
26
36
|
no_commands do
|
27
37
|
def color(string)
|
28
38
|
set_color(string, COLORS.fetch(string.downcase.to_sym, :blue))
|
@@ -41,28 +51,16 @@ module Awful
|
|
41
51
|
end
|
42
52
|
|
43
53
|
desc 'ls [PATTERN]', 'list cloudformation stacks matching PATTERN'
|
44
|
-
method_option :long, aliases: '-l', type: :boolean, default: false, desc: '
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
unless options[:all]
|
51
|
-
stacks = stacks.select { |stack| stack.stack_status != 'DELETE_COMPLETE' }
|
52
|
-
end
|
53
|
-
|
54
|
-
## match on given arg
|
55
|
-
stacks.select do |stack|
|
56
|
-
stack.stack_name.match(name)
|
54
|
+
method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'long listing'
|
55
|
+
def ls(name = nil)
|
56
|
+
paginate(:stack_summaries) do |next_token|
|
57
|
+
cf.list_stacks(stack_status_filter: STATUSES, next_token: next_token)
|
58
|
+
end.tap do |stacks|
|
59
|
+
stacks.select! { |s| s.stack_name.match(name) } if name
|
57
60
|
end.output do |list|
|
58
61
|
if options[:long]
|
59
62
|
print_table list.map { |s|
|
60
|
-
[
|
61
|
-
s.stack_name,
|
62
|
-
s.creation_time,
|
63
|
-
color(s.stack_status),
|
64
|
-
s.template_description,
|
65
|
-
]
|
63
|
+
[s.stack_name, s.creation_time, color(s.stack_status), s.template_description]
|
66
64
|
}.sort
|
67
65
|
else
|
68
66
|
puts list.map(&:stack_name).sort
|
data/lib/awful/s3.rb
CHANGED
@@ -18,11 +18,16 @@ module Awful
|
|
18
18
|
nil
|
19
19
|
end
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
def get_stack_tag(name)
|
22
|
+
(get_tags(name) || []).find do |tag|
|
23
|
+
tag.key == 'aws:cloudformation:stack-name'
|
24
|
+
end&.value
|
25
|
+
end
|
26
|
+
|
27
|
+
def stack_exists?(name)
|
28
|
+
cf.describe_stacks(stack_name: name) && true
|
29
|
+
rescue ::Aws::CloudFormation::Errors::ValidationError
|
30
|
+
false
|
26
31
|
end
|
27
32
|
end
|
28
33
|
|
@@ -205,21 +210,14 @@ module Awful
|
|
205
210
|
)
|
206
211
|
end
|
207
212
|
|
208
|
-
desc 'orphans', '
|
209
|
-
method_option :delete,
|
213
|
+
desc 'orphans', 'find empty buckets from a deleted CFN stack'
|
214
|
+
method_option :delete, type: :boolean, default: false, desc: 'delete orphaned buckets'
|
210
215
|
def orphans
|
211
|
-
s3.list_buckets.buckets.each do |
|
212
|
-
stack =
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
if s3.list_objects_v2(bucket: b.name, max_keys: 1).key_count == 0
|
217
|
-
s3.delete_bucket(bucket: b.name) if yes?("Delete empty bucket #{b.name}?", :yellow)
|
218
|
-
else
|
219
|
-
puts "#{b.name} not empty"
|
220
|
-
end
|
221
|
-
else
|
222
|
-
puts b.name
|
216
|
+
s3.list_buckets.buckets.each do |bucket|
|
217
|
+
if (stack = get_stack_tag(bucket.name))
|
218
|
+
next if stack_exists?(stack)
|
219
|
+
puts bucket.name
|
220
|
+
s3.delete_bucket(bucket: bucket.name) if options[:delete]
|
223
221
|
end
|
224
222
|
end
|
225
223
|
end
|
data/lib/awful/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: awful
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.185
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ric Lister
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|