awful 0.0.161 → 0.0.162

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/lib/awful/ami.rb +18 -21
  3. data/lib/awful/version.rb +1 -1
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 468c76dd67311ec96f097e6d05ecf53287800b64
4
- data.tar.gz: f3a59e49c7c61e4d05941b18368a09292450f7a3
3
+ metadata.gz: 5c108b1b219d5b3b1f34c50c775a06e12070a5e8
4
+ data.tar.gz: 98a86eee58b229adc6ca819d1882ae29feccbdb3
5
5
  SHA512:
6
- metadata.gz: 06d367fe21ee33f8c58ea6308e4160caa937209f8f8238afffbbb8b40b0033a2be48df59bc1e3182284fcde9f88891b804ebce43ebd26c13fc5ca0829688c12f
7
- data.tar.gz: 5dfa3f87196eff10c0df6565561b9694d73ecec663e8fd264041bcbb15933cb32376cc2ff7cb5a02d8c7acdb705a2bf0e7b084f2f307c6cce49a0f750cfa0fcc
6
+ metadata.gz: 0777d9f98e288504f35f990422d7dec9d8911061b2825a577a4b27cf4adba37607ca70da86894953fe14274ed49a894d8378cbb5f0da160373a9421c68027490
7
+ data.tar.gz: 60db36d4cf8a4dade79edb173fe7738b1ee6a9bc848ba428111d37ab14ceb229036254276b387d530facee916b5bd90cb35e5fc94339815301f5e7f8485c1a15
data/lib/awful/ami.rb CHANGED
@@ -6,8 +6,8 @@ module Awful
6
6
  end
7
7
 
8
8
  class Ami < Cli
9
- class_option :owners, aliases: '-o', type: :string, default: 'self', desc: 'List images with this owner'
10
- class_option :filters, aliases: '-f', type: :array, default: [], desc: 'Filter using name=value, eg tag:Foo=bar, multiples are ANDed'
9
+ class_option :owners, aliases: '-o', type: :array, default: %w[self], desc: 'List images with this owner'
10
+ class_option :filters, aliases: '-f', type: :array, default: [], desc: 'Filter using name=value, eg tag:Foo=bar, multiples are ANDed'
11
11
 
12
12
  COLORS = {
13
13
  available: :green,
@@ -16,15 +16,17 @@ module Awful
16
16
  }
17
17
 
18
18
  no_commands do
19
- def images(options)
19
+ def images(*image_ids)
20
20
  params = {
21
- owners: options[:owners].split(','),
21
+ image_ids: Array(image_ids),
22
+ owners: options[:owners],
22
23
  filters: options[:filters].map do |tag|
23
24
  k, v = tag.split('=')
24
25
  {name: k, values: v.split(',')}
25
26
  end
26
27
  }.reject { |k,v| v.empty? }
27
- ec2.describe_images(params).map(&:images).flatten
28
+
29
+ ec2.describe_images(params).images
28
30
  end
29
31
 
30
32
  def color(string)
@@ -32,12 +34,10 @@ module Awful
32
34
  end
33
35
  end
34
36
 
35
- desc 'ls [PATTERN]', 'list AMIs'
37
+ desc 'ls [IDS]', 'list AMIs'
36
38
  method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'Long listing'
37
- def ls(name = /./)
38
- images(options).select do |image|
39
- image.name.match(name)
40
- end.output do |list|
39
+ def ls(*ids)
40
+ images(*ids).output do |list|
41
41
  if options[:long]
42
42
  print_table list.map { |i|
43
43
  [ i.name, i.image_id, i.root_device_type, color(i.state), i.creation_date, i.tags.map{ |t| "#{t.key}=#{t.value}" }.sort.join(',') ]
@@ -48,20 +48,17 @@ module Awful
48
48
  end
49
49
  end
50
50
 
51
- desc 'delete NAME', 'delete AMI'
51
+ desc 'delete ID', 'delete AMI'
52
52
  def delete(id)
53
- images(options).find do |image|
54
- image.image_id.match(id)
55
- end.output do |ami|
56
- if yes? "Really deregister image #{ami.name} (#{ami.image_id})?", :yellow
57
- ec2.deregister_image(image_id: ami.image_id)
58
- end
53
+ ami = images(id).first
54
+ if yes? "Really deregister image #{ami.name} (#{ami.image_id})?", :yellow
55
+ ec2.deregister_image(image_id: ami.image_id)
59
56
  end
60
57
  end
61
58
 
62
59
  desc 'dump IDS', 'describe images'
63
60
  def dump(*ids)
64
- ec2.describe_images(image_ids: ids).images.output do |images|
61
+ images(*ids).output do |images|
65
62
  images.each do |image|
66
63
  puts YAML.dump(stringify_keys(image.to_hash))
67
64
  end
@@ -71,8 +68,8 @@ module Awful
71
68
  desc 'tags ID [TAGS]', 'get tags for AMI, or set multiple tags as key:value'
72
69
  def tags(id, *tags)
73
70
  if tags.empty?
74
- ec2.describe_images(image_ids: [id]).images.first.tags.output do |list|
75
- print_table list.map { |t| [t.key, t.value] }
71
+ images(id).first.tags.output do |tags|
72
+ print_table tags.map { |t| [t.key, t.value] }
76
73
  end
77
74
  else
78
75
  ec2.create_tags(
@@ -100,7 +97,7 @@ module Awful
100
97
  desc 'last NAME', 'get ids of last (by creation date) AMIs [matching NAME]'
101
98
  method_option :count, aliases: '-n', type: :numeric, default: 1, desc: 'Return N results'
102
99
  def last(name = /./)
103
- images(options).select do |image|
100
+ images.select do |image|
104
101
  image.name.match(name)
105
102
  end.sort_by(&:creation_date).last(options[:count]).map do |image|
106
103
  image.image_id
data/lib/awful/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = '0.0.161'
2
+ VERSION = '0.0.162'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: awful
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.161
4
+ version: 0.0.162
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ric Lister