awspec 0.10.1 → 0.10.2
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 +3 -1
- data/awspec.gemspec +1 -0
- data/lib/awspec.rb +1 -0
- data/lib/awspec/command/generate.rb +1 -1
- data/lib/awspec/ext.rb +0 -1
- data/lib/awspec/generator/doc/type.rb +1 -1
- data/lib/awspec/generator/doc/type/base.rb +3 -3
- data/lib/awspec/generator/template.rb +12 -12
- data/lib/awspec/helper/finder/iam.rb +13 -51
- data/lib/awspec/helper/type.rb +1 -1
- data/lib/awspec/version.rb +1 -1
- metadata +16 -3
- data/lib/awspec/ext/string.rb +0 -14
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 735ac3ea11197e0d21958bd387af953a77720760
|
|
4
|
+
data.tar.gz: 177f17845d8acacc5fc45e541dad53f4333109b0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e8506223f8805c9daa7001cc9d5c2ffeb57fca18c02df41e4af06bfe88b305c8f7ea66bb7f20058c272e0749507297cff3ef7b0fb7612958a16dcc0f37587c88
|
|
7
|
+
data.tar.gz: 69f5c5c2289aab357c3479f0a08b4f48721dea1eb3c41f136d503c7d866cb2ef240beaf8eba68badc5467c21090cbf6aacec3cb172c9f32f3ccb6ceb3c45b49e
|
data/README.md
CHANGED
data/awspec.gemspec
CHANGED
|
@@ -23,6 +23,7 @@ Gem::Specification.new do |spec|
|
|
|
23
23
|
spec.add_runtime_dependency 'rspec-its'
|
|
24
24
|
spec.add_runtime_dependency 'aws-sdk', '~> 2'
|
|
25
25
|
spec.add_runtime_dependency 'thor'
|
|
26
|
+
spec.add_runtime_dependency 'activesupport'
|
|
26
27
|
spec.add_development_dependency 'bundler', '~> 1.9'
|
|
27
28
|
spec.add_development_dependency 'rake', '~> 10.0'
|
|
28
29
|
spec.add_development_dependency 'rubocop'
|
data/lib/awspec.rb
CHANGED
|
@@ -12,7 +12,7 @@ module Awspec
|
|
|
12
12
|
define_method type do |*args|
|
|
13
13
|
load_secrets
|
|
14
14
|
vpc_id = args.first
|
|
15
|
-
eval "puts Awspec::Generator::Spec::#{type.
|
|
15
|
+
eval "puts Awspec::Generator::Spec::#{type.camelize}.new.generate_by_vpc_id(vpc_id)"
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
data/lib/awspec/ext.rb
CHANGED
|
@@ -17,7 +17,7 @@ EOF
|
|
|
17
17
|
doc = ERB.new(header, nil, '-').result(binding)
|
|
18
18
|
|
|
19
19
|
types.map do |type|
|
|
20
|
-
doc += eval "Awspec::Generator::Doc::Type::#{type.
|
|
20
|
+
doc += eval "Awspec::Generator::Doc::Type::#{type.camelize}.new.generate_doc"
|
|
21
21
|
end
|
|
22
22
|
doc
|
|
23
23
|
end
|
|
@@ -3,7 +3,7 @@ module Awspec::Generator
|
|
|
3
3
|
module Type
|
|
4
4
|
class Base
|
|
5
5
|
def initialize
|
|
6
|
-
Awspec::Stub.load type_name.
|
|
6
|
+
Awspec::Stub.load type_name.underscore
|
|
7
7
|
@type_name = type_name
|
|
8
8
|
end
|
|
9
9
|
|
|
@@ -26,7 +26,7 @@ module Awspec::Generator
|
|
|
26
26
|
end
|
|
27
27
|
|
|
28
28
|
@descriptions = {}
|
|
29
|
-
merge_file = File.dirname(__FILE__) + '/../../../../../doc/_resource_types/' + type_name.
|
|
29
|
+
merge_file = File.dirname(__FILE__) + '/../../../../../doc/_resource_types/' + type_name.underscore + '.md'
|
|
30
30
|
if File.exist?(merge_file)
|
|
31
31
|
matcher = nil
|
|
32
32
|
File.foreach(merge_file) do |line|
|
|
@@ -56,7 +56,7 @@ module Awspec::Generator
|
|
|
56
56
|
|
|
57
57
|
def doc_template
|
|
58
58
|
template = <<-'EOF'
|
|
59
|
-
## <a name="<%= @type_name.
|
|
59
|
+
## <a name="<%= @type_name.underscore %>"><%= @type_name.underscore %></a>
|
|
60
60
|
|
|
61
61
|
<%= @type_name %> resource type.
|
|
62
62
|
<%- if @descriptions.include?('first') -%><%= @descriptions['first'] %><%- end -%>
|
|
@@ -11,11 +11,11 @@ module Awspec::Generator
|
|
|
11
11
|
end
|
|
12
12
|
|
|
13
13
|
def self.generate_type
|
|
14
|
-
path = 'lib/awspec/type/' + @type.
|
|
14
|
+
path = 'lib/awspec/type/' + @type.underscore + '.rb'
|
|
15
15
|
full_path = @root_path + path
|
|
16
16
|
content = <<-"EOF"
|
|
17
17
|
module Awspec::Type
|
|
18
|
-
class #{@type.
|
|
18
|
+
class #{@type.camelize} < Base
|
|
19
19
|
def initialize(id)
|
|
20
20
|
super
|
|
21
21
|
# @id = # @FIXME
|
|
@@ -27,7 +27,7 @@ EOF
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def self.generate_stub
|
|
30
|
-
path = 'lib/awspec/stub/' + @type.
|
|
30
|
+
path = 'lib/awspec/stub/' + @type.underscore + '.rb'
|
|
31
31
|
full_path = @root_path + path
|
|
32
32
|
content = <<-"EOF"
|
|
33
33
|
# Aws.config[:ec2] = {
|
|
@@ -38,13 +38,13 @@ EOF
|
|
|
38
38
|
end
|
|
39
39
|
|
|
40
40
|
def self.generate_type_spec
|
|
41
|
-
path = 'spec/type/' + @type.
|
|
41
|
+
path = 'spec/type/' + @type.underscore + '_spec.rb'
|
|
42
42
|
full_path = @root_path + path
|
|
43
43
|
content = <<-"EOF"
|
|
44
44
|
require 'spec_helper'
|
|
45
|
-
Awspec::Stub.load '#{@type.
|
|
45
|
+
Awspec::Stub.load '#{@type.underscore}'
|
|
46
46
|
|
|
47
|
-
describe #{@type.
|
|
47
|
+
describe #{@type.underscore}('my-#{@type.underscore.tr('_', '-')}') do
|
|
48
48
|
it { should exist }
|
|
49
49
|
end
|
|
50
50
|
EOF
|
|
@@ -52,17 +52,17 @@ EOF
|
|
|
52
52
|
end
|
|
53
53
|
|
|
54
54
|
def self.generate_generator_doc
|
|
55
|
-
path = 'lib/awspec/generator/doc/type/' + @type.
|
|
55
|
+
path = 'lib/awspec/generator/doc/type/' + @type.underscore + '.rb'
|
|
56
56
|
full_path = @root_path + path
|
|
57
57
|
content = <<-"EOF"
|
|
58
58
|
module Awspec::Generator
|
|
59
59
|
module Doc
|
|
60
60
|
module Type
|
|
61
|
-
class #{@type.
|
|
61
|
+
class #{@type.camelize} < Base
|
|
62
62
|
def initialize
|
|
63
63
|
super
|
|
64
|
-
@type_name = '#{@type.
|
|
65
|
-
@type = Awspec::Type::#{@type.
|
|
64
|
+
@type_name = '#{@type.camelize}'
|
|
65
|
+
@type = Awspec::Type::#{@type.camelize}.new('my-#{@type.underscore.tr('_', '-')}')
|
|
66
66
|
@ret = @type.resource
|
|
67
67
|
@matchers = []
|
|
68
68
|
@ignore_matchers = []
|
|
@@ -79,9 +79,9 @@ EOF
|
|
|
79
79
|
def self.put_message
|
|
80
80
|
content = <<-"EOF"
|
|
81
81
|
|
|
82
|
-
Genarate #{@type.
|
|
82
|
+
Genarate #{@type.camelize} template files.
|
|
83
83
|
|
|
84
|
-
* !! AND add '#{@type.
|
|
84
|
+
* !! AND add '#{@type.underscore}' to Awspec::Helper::Type::TYPES in awspec/lib/helper/type.rb *
|
|
85
85
|
|
|
86
86
|
EOF
|
|
87
87
|
end
|
|
@@ -1,60 +1,22 @@
|
|
|
1
1
|
module Awspec::Helper
|
|
2
2
|
module Finder
|
|
3
3
|
module Iam
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
selected
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def find_iam_group(id)
|
|
19
|
-
selected = []
|
|
20
|
-
res = @iam_client.list_groups
|
|
21
|
-
|
|
22
|
-
loop do
|
|
23
|
-
selected += res.groups.select do |g|
|
|
24
|
-
g.group_name == id || g.group_id == id || g.arn == id
|
|
25
|
-
end
|
|
26
|
-
(res.next_page? && res = res.next_page) || break
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
selected.first if selected.count == 1
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def find_iam_role(id)
|
|
33
|
-
selected = []
|
|
34
|
-
res = @iam_client.list_roles
|
|
35
|
-
|
|
36
|
-
loop do
|
|
37
|
-
selected += res.roles.select do |r|
|
|
38
|
-
r.role_name == id || r.role_id == id || r.arn == id
|
|
4
|
+
# find_iam_user, find_iam_group find_iam_role find_iam_policy
|
|
5
|
+
role_types = %w(user group role policy)
|
|
6
|
+
role_types.each do |type|
|
|
7
|
+
define_method 'find_iam_' + type do |*args|
|
|
8
|
+
id = args.first
|
|
9
|
+
selected = []
|
|
10
|
+
res = @iam_client.method('list_' + type.pluralize).call
|
|
11
|
+
loop do
|
|
12
|
+
selected += res[type.pluralize].select do |u|
|
|
13
|
+
u[type + '_name'] == id || u[type + '_id'] == id || u.arn == id
|
|
14
|
+
end
|
|
15
|
+
(res.next_page? && res = res.next_page) || break
|
|
39
16
|
end
|
|
40
|
-
(res.next_page? && res = res.next_page) || break
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
selected.first if selected.count == 1
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def find_iam_policy(id)
|
|
47
|
-
selected = []
|
|
48
|
-
res = @iam_client.list_policies
|
|
49
17
|
|
|
50
|
-
|
|
51
|
-
selected += res.policies.select do |p|
|
|
52
|
-
p.policy_name == id || p.policy_id == id || p.arn == id
|
|
53
|
-
end
|
|
54
|
-
(res.next_page? && res = res.next_page) || break
|
|
18
|
+
selected.first if selected.count == 1
|
|
55
19
|
end
|
|
56
|
-
|
|
57
|
-
selected.first if selected.count == 1
|
|
58
20
|
end
|
|
59
21
|
|
|
60
22
|
def select_iam_group_by_user_name(user_name)
|
data/lib/awspec/helper/type.rb
CHANGED
data/lib/awspec/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: awspec
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.10.
|
|
4
|
+
version: 0.10.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- k1LoW
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2015-09-
|
|
11
|
+
date: 2015-09-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: rspec
|
|
@@ -66,6 +66,20 @@ dependencies:
|
|
|
66
66
|
- - ">="
|
|
67
67
|
- !ruby/object:Gem::Version
|
|
68
68
|
version: '0'
|
|
69
|
+
- !ruby/object:Gem::Dependency
|
|
70
|
+
name: activesupport
|
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
|
72
|
+
requirements:
|
|
73
|
+
- - ">="
|
|
74
|
+
- !ruby/object:Gem::Version
|
|
75
|
+
version: '0'
|
|
76
|
+
type: :runtime
|
|
77
|
+
prerelease: false
|
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
79
|
+
requirements:
|
|
80
|
+
- - ">="
|
|
81
|
+
- !ruby/object:Gem::Version
|
|
82
|
+
version: '0'
|
|
69
83
|
- !ruby/object:Gem::Dependency
|
|
70
84
|
name: bundler
|
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -152,7 +166,6 @@ files:
|
|
|
152
166
|
- lib/awspec/cli.rb
|
|
153
167
|
- lib/awspec/command/generate.rb
|
|
154
168
|
- lib/awspec/ext.rb
|
|
155
|
-
- lib/awspec/ext/string.rb
|
|
156
169
|
- lib/awspec/ext/struct.rb
|
|
157
170
|
- lib/awspec/generator.rb
|
|
158
171
|
- lib/awspec/generator/doc/type.rb
|
data/lib/awspec/ext/string.rb
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
class String
|
|
2
|
-
def to_snake_case
|
|
3
|
-
self.gsub(/::/, '/')
|
|
4
|
-
.gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2')
|
|
5
|
-
.gsub(/([a-z\d])([A-Z])/, '\1_\2')
|
|
6
|
-
.tr('-', '_')
|
|
7
|
-
.downcase
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
def to_camel_case
|
|
11
|
-
return self if self !~ /_/ && self =~ /[A-Z]+.*/
|
|
12
|
-
split('_').map { |e| e.capitalize }.join
|
|
13
|
-
end
|
|
14
|
-
end
|