miam 0.1.3 → 0.1.4
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 +4 -4
- data/README.md +1 -0
- data/bin/miam +1 -0
- data/lib/miam/client.rb +24 -0
- data/lib/miam/dsl/converter.rb +16 -4
- data/lib/miam/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: a2f7fbc6d8f30d94ddf30434144c507f90a08a92
|
4
|
+
data.tar.gz: f4bec97bf208b21f044bb4089f29453e8236ee15
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 79ab922dc36aaa76e8ed5cec329daad942ea06deda43fa80cc657547d056d341320871a97e9ffc7103a61f180b7d357f7265e64963f13b0c05869a809c219ed2
|
7
|
+
data.tar.gz: b98f1198e7c93184c5eedcebf1bb20dc45543e8d5800e58169eabffd065545db6a3c587447c93ec0e781ca1dad3afa8c1b6a29448baa5ae3da62d57f5ed3ebc2
|
data/README.md
CHANGED
data/bin/miam
CHANGED
@@ -44,6 +44,7 @@ ARGV.options do |opt|
|
|
44
44
|
opt.on('' , '--split') { split = true }
|
45
45
|
opt.on('' , '--split-more') { split = :more }
|
46
46
|
opt.on('' , '--export-concurrency N', Integer) {|v| options[:export_concurrency] = v }
|
47
|
+
opt.on('' , '--target REGEXP') {|v| options[:target] = Regexp.new(v) }
|
47
48
|
opt.on('' , '--no-color') { options[:color] = false }
|
48
49
|
opt.on('' , '--no-progress') { options[:no_progress] = true }
|
49
50
|
opt.on('' , '--debug') { options[:debug] = true }
|
data/lib/miam/client.rb
CHANGED
@@ -59,6 +59,8 @@ class Miam::Client
|
|
59
59
|
updated = scan_rename(:user, expected, actual, group_users)
|
60
60
|
|
61
61
|
expected.each do |user_name, expected_attrs|
|
62
|
+
next unless target_matched?(user_name)
|
63
|
+
|
62
64
|
actual_attrs = actual.delete(user_name)
|
63
65
|
|
64
66
|
if actual_attrs
|
@@ -78,6 +80,8 @@ class Miam::Client
|
|
78
80
|
end
|
79
81
|
|
80
82
|
actual.each do |user_name, attrs|
|
83
|
+
next unless target_matched?(user_name)
|
84
|
+
|
81
85
|
@driver.delete_user(user_name, attrs)
|
82
86
|
|
83
87
|
group_users.each do |group_name, users|
|
@@ -147,6 +151,8 @@ class Miam::Client
|
|
147
151
|
updated = scan_rename(:group, expected, actual, group_users)
|
148
152
|
|
149
153
|
expected.each do |group_name, expected_attrs|
|
154
|
+
next unless target_matched?(group_name)
|
155
|
+
|
150
156
|
actual_attrs = actual.delete(group_name)
|
151
157
|
|
152
158
|
if actual_attrs
|
@@ -160,6 +166,8 @@ class Miam::Client
|
|
160
166
|
end
|
161
167
|
|
162
168
|
actual.each do |group_name, attrs|
|
169
|
+
next unless target_matched?(group_name)
|
170
|
+
|
163
171
|
users_in_group = group_users.delete(group_name) || []
|
164
172
|
@driver.delete_group(group_name, attrs, users_in_group)
|
165
173
|
|
@@ -181,6 +189,8 @@ class Miam::Client
|
|
181
189
|
updated = false
|
182
190
|
|
183
191
|
expected.each do |role_name, expected_attrs|
|
192
|
+
next unless target_matched?(role_name)
|
193
|
+
|
184
194
|
actual_attrs = actual.delete(role_name)
|
185
195
|
|
186
196
|
if actual_attrs
|
@@ -193,6 +203,8 @@ class Miam::Client
|
|
193
203
|
end
|
194
204
|
|
195
205
|
actual.each do |role_name, attrs|
|
206
|
+
next unless target_matched?(role_name)
|
207
|
+
|
196
208
|
instance_profile_names = []
|
197
209
|
|
198
210
|
instance_profile_roles.each do |instance_profile_name, roles|
|
@@ -261,6 +273,8 @@ class Miam::Client
|
|
261
273
|
updated = false
|
262
274
|
|
263
275
|
expected.each do |instance_profile_name, expected_attrs|
|
276
|
+
next unless target_matched?(instance_profile_name)
|
277
|
+
|
264
278
|
actual_attrs = actual.delete(instance_profile_name)
|
265
279
|
|
266
280
|
if actual_attrs
|
@@ -273,6 +287,8 @@ class Miam::Client
|
|
273
287
|
end
|
274
288
|
|
275
289
|
actual.each do |instance_profile_name, attrs|
|
290
|
+
next unless target_matched?(instance_profile_name)
|
291
|
+
|
276
292
|
roles_in_instance_profile = instance_profile_roles.delete(instance_profile_name) || []
|
277
293
|
@driver.delete_instance_profile(instance_profile_name, attrs, roles_in_instance_profile)
|
278
294
|
|
@@ -384,4 +400,12 @@ class Miam::Client
|
|
384
400
|
raise TypeError, "can't convert #{file} into File"
|
385
401
|
end
|
386
402
|
end
|
403
|
+
|
404
|
+
def target_matched?(name)
|
405
|
+
if @options[:target]
|
406
|
+
name =~ @options[:target]
|
407
|
+
else
|
408
|
+
true
|
409
|
+
end
|
410
|
+
end
|
387
411
|
end
|
data/lib/miam/dsl/converter.rb
CHANGED
@@ -21,8 +21,9 @@ class Miam::DSL::Converter
|
|
21
21
|
|
22
22
|
def output_users(users)
|
23
23
|
users.each.sort_by {|k, v| k }.map {|user_name, attrs|
|
24
|
+
next unless target_matched?(user_name)
|
24
25
|
output_user(user_name, attrs)
|
25
|
-
}.join("\n")
|
26
|
+
}.select {|i| i }.join("\n")
|
26
27
|
end
|
27
28
|
|
28
29
|
def output_user(user_name, attrs)
|
@@ -60,8 +61,9 @@ end
|
|
60
61
|
|
61
62
|
def output_groups(groups)
|
62
63
|
groups.each.sort_by {|k, v| k }.map {|group_name, attrs|
|
64
|
+
next unless target_matched?(group_name)
|
63
65
|
output_group(group_name, attrs)
|
64
|
-
}.join("\n")
|
66
|
+
}.select {|i| i }.join("\n")
|
65
67
|
end
|
66
68
|
|
67
69
|
def output_group(group_name, attrs)
|
@@ -76,8 +78,9 @@ end
|
|
76
78
|
|
77
79
|
def output_roles(roles)
|
78
80
|
roles.each.sort_by {|k, v| k }.map {|role_name, attrs|
|
81
|
+
next unless target_matched?(role_name)
|
79
82
|
output_role(role_name, attrs)
|
80
|
-
}.join("\n")
|
83
|
+
}.select {|i| i }.join("\n")
|
81
84
|
end
|
82
85
|
|
83
86
|
def output_role(role_name, attrs)
|
@@ -107,8 +110,9 @@ end
|
|
107
110
|
|
108
111
|
def output_instance_profiles(instance_profiles)
|
109
112
|
instance_profiles.each.sort_by {|k, v| k }.map {|instance_profile_name, attrs|
|
113
|
+
next unless target_matched?(instance_profile_name)
|
110
114
|
output_instance_profile(instance_profile_name, attrs)
|
111
|
-
}.join("\n")
|
115
|
+
}.select {|i| i }.join("\n")
|
112
116
|
end
|
113
117
|
|
114
118
|
def output_assume_role_policy_document(assume_role_policy_document)
|
@@ -150,4 +154,12 @@ instance_profile #{instance_profile_name.inspect}, #{Miam::Utils.unbrace(instanc
|
|
150
154
|
end
|
151
155
|
EOS
|
152
156
|
end
|
157
|
+
|
158
|
+
def target_matched?(name)
|
159
|
+
if @options[:target]
|
160
|
+
name =~ @options[:target]
|
161
|
+
else
|
162
|
+
true
|
163
|
+
end
|
164
|
+
end
|
153
165
|
end
|
data/lib/miam/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: miam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Genki Sugawara
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-10-
|
11
|
+
date: 2014-10-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|