awful 0.0.52 → 0.0.53

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: 250b30414e77e87830cc9ec2422af351a073a28a
4
- data.tar.gz: 52d5c1cad70199c2bc205dd8c8d863ab7659261d
3
+ metadata.gz: 36753e59ef159b9d7324d78ecba2678a44c231ee
4
+ data.tar.gz: 1d9fa838a6078bafb5b926a6c4be5c74c17b7a59
5
5
  SHA512:
6
- metadata.gz: d0bd67f11073df6f92d6ce1933b98df9c6867e376afe200ad0fc75bcfb17ba24eac88189e700fa995a38882f51750c12c58d96bc039f5eacbcef4f69696a06f0
7
- data.tar.gz: 60c43fc00df65857509f6ec8bc5c946c42fc449318453b8516ea2410a772df75dc79cea0b21b56cf1464b9160086a6c4c10d18fd4ef4ff0cb0d9f6a484f92870
6
+ metadata.gz: a58985a2a470ffe7bffccdf01f167264c6736cb9d2562191fccd02f6bb4ef0b691ff2d5bb3603a655e6ce8ce7070326a100296599e767c083383e221c0759d78
7
+ data.tar.gz: 9bf66255c04821000a9d6dd7964f6acad4d901ccf42ac99b7e923f08ff0d3151d05e056dd4a4626df38458a35d918d0430e538f796e01b7194e29c00725188b3
@@ -6,7 +6,7 @@ module Awful
6
6
  method_option :long, aliases: '-l', default: false, desc: 'Long listing'
7
7
  def ls(name = /./)
8
8
  fields = options[:long] ?
9
- ->(s) { [tag_name(s), s.group_id, s.group_name, s.vpc_id, s.description] } :
9
+ ->(s) { [tag_name(s), s.group_id, s.group_name[0..50], s.vpc_id, s.description] } :
10
10
  ->(s) { [s.group_name] }
11
11
 
12
12
  ec2.describe_security_groups.map(&:security_groups).flatten.select do |sg|
@@ -18,11 +18,21 @@ module Awful
18
18
  end
19
19
  end
20
20
 
21
- desc 'dump NAME', 'dump security group with NAME as yaml'
21
+ no_commands do
22
+
23
+ ## return first SG that matches name to id, group_name, or Name tag
24
+ def first_matching_sg(name)
25
+ field = name.match(/^sg-[\d[a-f]]{8}$/) ? :group_id : :group_name
26
+ ec2.describe_security_groups.map(&:security_groups).flatten.find do |sg|
27
+ sg.send(field).match(name) or (tag_name(sg)||'').match(name)
28
+ end
29
+ end
30
+
31
+ end
32
+
33
+ desc 'dump NAME', 'dump security group with NAME [or ID] as yaml'
22
34
  def dump(name)
23
- ec2.describe_security_groups.map(&:security_groups).flatten.find do |sg|
24
- sg.group_name == name
25
- end.tap do |sg|
35
+ first_matching_sg(name).tap do |sg|
26
36
  puts YAML.dump(stringify_keys(sg.to_hash))
27
37
  end
28
38
  end
@@ -30,9 +40,7 @@ module Awful
30
40
  desc 'inbound NAME', 'show inbound rules for named security group'
31
41
  method_option :long, aliases: '-l', default: false, desc: 'Long listing'
32
42
  def inbound(name)
33
- ec2.describe_security_groups.map(&:security_groups).flatten.find do |sg|
34
- sg.group_name == name
35
- end.ip_permissions.tap do |perms|
43
+ first_matching_sg(name).ip_permissions.tap do |perms|
36
44
  sources = ->(perm) { perm.ip_ranges.map(&:cidr_ip) + perm.user_id_group_pairs.map(&:group_id) }
37
45
  if options[:long]
38
46
  perms.map do |p|
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = "0.0.52"
2
+ VERSION = "0.0.53"
3
3
  end
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.52
4
+ version: 0.0.53
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ric Lister
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-27 00:00:00.000000000 Z
11
+ date: 2015-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler