awful 0.0.133 → 0.0.134

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f20fa5e02041068d58d0a6eb5303dccf56af9bf4
4
- data.tar.gz: ac99595963ec8e583cf7e80fa96866f15e884b56
3
+ metadata.gz: e03a6a7b0b1b46bd9ea30ba88401a20c07363e1d
4
+ data.tar.gz: b44afdc965fd132abb21165c08b3c501f01bc73c
5
5
  SHA512:
6
- metadata.gz: 2a87db67e4ddea50a875c5f2b38d149921536227585b7abcaf0e79470b817ed47fc17788057ccb54b6a9c54992529fdf05c4945c705887738e52ec5f2481cb67
7
- data.tar.gz: 924d74990c82d76e26acd21317557df931d96f14f80439680af6cf1573840038e3873068e12cb8aced59cf644def20e2d6b8ac6909fced12aee4e510a417e7f7
6
+ metadata.gz: 29893181e85f861b0162c44434e2109cd45a1e44b6d3dc830b998620a8e4bcf2eac07d3e389f2a1358589c0834a67fae0976b4c2191dd3106cac6c692c117f8e
7
+ data.tar.gz: bc4a04e79deb969f90e626685da4a4cc8f78eed7d071e7ded5b540e2758605449c1f452fb656975cb28ff1206c31e32a2fab6c12a60e08e04cfad7c7f14917b3
@@ -102,7 +102,9 @@ module Awful
102
102
  if key
103
103
  output_hash[key.to_s].output(&method(:puts))
104
104
  else
105
- output_hash.output(&method(:print_table))
105
+ output_hash.output do |hash|
106
+ print_table hash.sort
107
+ end
106
108
  end
107
109
  end
108
110
 
data/lib/awful/iam.rb CHANGED
@@ -8,12 +8,46 @@ module Awful
8
8
  end
9
9
  end
10
10
 
11
+ desc 'users', 'list users'
12
+ method_option :long, aliases: '-l', type: :boolean, default: false, desc: 'Long listing'
13
+ method_option :mfa, aliases: '-m', type: :boolean, default: false, desc: 'Show MFA status'
14
+ def users
15
+ iam.list_users.users.output do |users|
16
+ if options[:long]
17
+ print_table users.map { |u| [u.user_name, u.user_id, u.create_date, u.password_last_used] }
18
+ elsif options[:mfa]
19
+ mfa = iam.list_virtual_mfa_devices.virtual_mfa_devices.each_with_object({}) do |m,h|
20
+ next unless m.user
21
+ h[m.user.user_name] = m.enable_date
22
+ end
23
+ print_table users.map { |u| [u.user_name, mfa.fetch(u.user_name, '-')] }
24
+ else
25
+ puts users.map(&:user_name)
26
+ end
27
+ end
28
+ end
29
+
30
+ desc 'mfa', 'list MFA devices'
31
+ method_option :long, aliases: '-l', default: false, desc: 'Long listing'
32
+ def mfa
33
+ iam.list_virtual_mfa_devices.virtual_mfa_devices.output do |devices|
34
+ if options[:long]
35
+ print_table devices.map { |d|
36
+ user_name = d.user ? d.user.user_name : '-'
37
+ [user_name, d.serial_number, d.enable_date]
38
+ }
39
+ else
40
+ puts devices.map(&:serial_number)
41
+ end
42
+ end
43
+ end
44
+
11
45
  desc 'certificates [NAME]', 'list server certificates [matching NAME]'
12
46
  method_option :long, aliases: '-l', default: false, desc: 'Long listing'
13
47
  def certificates(name = /./)
14
48
  iam.list_server_certificates.server_certificate_metadata_list.select do |cert|
15
49
  cert.server_certificate_name.match(name)
16
- end.tap do |certs|
50
+ end.output do |certs|
17
51
  if options[:long]
18
52
  print_table certs.map { |c|
19
53
  [
@@ -36,7 +70,7 @@ module Awful
36
70
  def roles(name = /./)
37
71
  iam.list_roles.roles.select do |role|
38
72
  role.role_name.match(name)
39
- end.tap do |roles|
73
+ end.output do |roles|
40
74
  name_method = options[:arns] ? :arn : :role_name
41
75
  if options[:long]
42
76
  print_table roles.map { |r|
@@ -66,11 +100,11 @@ module Awful
66
100
  policies = iam.send("list_#{type}_policies", "#{type}_name".to_sym => thing_name).policy_names
67
101
 
68
102
  if policy.nil? # just list policies
69
- policies.tap(&method(:puts))
103
+ policies.output(&method(:puts))
70
104
  else # get policy document
71
105
  policy_name = policies.find { |p| p.match(/#{policy}/i) }
72
106
  doc = iam.send("get_#{type}_policy", "#{type}_name".to_sym => thing_name, policy_name: policy_name).policy_document
73
- URI.unescape(doc).tap do |str|
107
+ URI.unescape(doc).output do |str|
74
108
  if options[:pretty]
75
109
  puts JSON.pretty_generate(JSON.parse(str))
76
110
  else
data/lib/awful/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Awful
2
- VERSION = '0.0.133'
2
+ VERSION = '0.0.134'
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.133
4
+ version: 0.0.134
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ric Lister
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-22 00:00:00.000000000 Z
11
+ date: 2016-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler