kumogata-template 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -1
- data/.travis.yml +1 -1
- data/Gemfile.lock +44 -21
- data/README.md +10 -1
- data/bin/kumogata-template +2 -2
- data/kumogata-template.gemspec +5 -6
- data/lib/kumogata/template.rb +3 -0
- data/lib/kumogata/template/codebuild.rb +86 -0
- data/lib/kumogata/template/codecommit.rb +20 -0
- data/lib/kumogata/template/ec2.rb +1 -1
- data/lib/kumogata/template/elb.rb +4 -1
- data/lib/kumogata/template/ext/argument_parser.rb +8 -0
- data/lib/kumogata/template/ext/kumogata.rb +41 -40
- data/lib/kumogata/template/ext/option_parser.rb +6 -0
- data/lib/kumogata/template/helper.rb +17 -11
- data/lib/kumogata/template/iam.rb +3 -0
- data/lib/kumogata/template/lambda.rb +5 -0
- data/lib/kumogata/template/logs.rb +18 -0
- data/lib/kumogata/template/sns.rb +21 -12
- data/lib/kumogata/template/version.rb +1 -1
- data/template/codebuild-project.rb +32 -0
- data/template/codecommit-repository.rb +20 -0
- data/template/ecs-cluster.rb +5 -1
- data/template/ecs-task-definition.rb +7 -1
- data/template/elasticache-replication-group.rb +2 -0
- data/template/elasticache-subnet-group.rb +2 -0
- data/template/kms-alias.rb +17 -0
- data/template/kms-key.rb +25 -0
- data/template/lambda-function.rb +2 -0
- data/template/logs-destination.rb +26 -0
- data/template/logs-log-group.rb +18 -0
- data/template/logs-log-stream.rb +18 -0
- data/template/logs-metric-filter.rb +21 -0
- data/template/logs-subscription_filter.rb +24 -0
- data/template/rds-db-instance.rb +6 -0
- data/template/s3-bucket-policy.rb +3 -2
- data/template/s3-bucket.rb +1 -1
- data/template/sns-subscription.rb +20 -0
- data/template/sns-topic.rb +1 -1
- data/test/abstract_unit.rb +8 -26
- data/test/codebuild_test.rb +76 -0
- data/test/elb_test.rb +44 -0
- data/test/logs_test.rb +23 -0
- data/test/s3_test.rb +0 -1
- data/test/sns_test.rb +1 -1
- data/test/template/codebuild-project_test.rb +72 -0
- data/test/template/codecommit-repository_test.rb +21 -0
- data/test/template/codedeploy-application_test.rb +1 -1
- data/test/template/ec2-network-acl-entry_test.rb +2 -2
- data/test/template/ecs-cluster_test.rb +5 -2
- data/test/template/elasticache-replication-group_test.rb +29 -1
- data/test/template/emr-cluster_test.rb +1 -1
- data/test/template/iam-managed-policy_test.rb +1 -1
- data/test/template/iam-policy_test.rb +1 -1
- data/test/template/kms-alias_test.rb +22 -0
- data/test/template/kms-key_test.rb +36 -0
- data/test/template/logs-destination_test.rb +37 -0
- data/test/template/logs-log-group_test.rb +34 -0
- data/test/template/logs-log-stream_test.rb +46 -0
- data/test/template/logs-metric-filter_test.rb +41 -0
- data/test/template/logs-subscription-filter_test.rb +36 -0
- data/test/template/rds-event-subscription_test.rb +1 -1
- data/test/template/sns-subscription_test.rb +28 -0
- metadata +52 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e864c2a60e72840e4dbd4654d206ad26a537f6a
|
4
|
+
data.tar.gz: 42092ee39c37f1ece34f4df417bc8bc9808c1fb2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 20b12e59103fdd77b860bdf4b5d45c5481140a50abc191662662e8ae3c588376b1939d046d009ea0885d08e16cc2cfaac0b8e427d3bc703065795787f96ee88d
|
7
|
+
data.tar.gz: e0e8c9b6be839f6675901e136a84458b2c996338f0db834c045c3a2600ba8b7410564a79cb8a055925651689f680501fcce9a95b141bd907fae499b7173b650d
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,54 +1,77 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
kumogata-template (0.0.
|
5
|
-
aws-sdk (~> 2)
|
6
|
-
|
7
|
-
kumogata2-plugin-yaml (= 0.0.1)
|
4
|
+
kumogata-template (0.0.13)
|
5
|
+
aws-sdk (~> 2.3)
|
6
|
+
kumogata (= 0.5.10)
|
8
7
|
|
9
8
|
GEM
|
10
9
|
remote: https://rubygems.org/
|
11
10
|
specs:
|
12
|
-
aws-sdk (2.
|
13
|
-
aws-sdk-resources (= 2.
|
14
|
-
aws-sdk-core (2.
|
11
|
+
aws-sdk (2.6.44)
|
12
|
+
aws-sdk-resources (= 2.6.44)
|
13
|
+
aws-sdk-core (2.6.44)
|
15
14
|
aws-sigv4 (~> 1.0)
|
16
15
|
jmespath (~> 1.0)
|
17
|
-
aws-sdk-resources (2.
|
18
|
-
aws-sdk-core (= 2.
|
16
|
+
aws-sdk-resources (2.6.44)
|
17
|
+
aws-sdk-core (= 2.6.44)
|
18
|
+
aws-sdk-v1 (1.66.0)
|
19
|
+
json (~> 1.4)
|
20
|
+
nokogiri (>= 1.4.4)
|
19
21
|
aws-sigv4 (1.0.0)
|
20
22
|
coderay (1.1.1)
|
23
|
+
coffee-script (2.4.1)
|
24
|
+
coffee-script-source
|
25
|
+
execjs
|
26
|
+
coffee-script-source (1.12.2)
|
21
27
|
diffy (3.1.0)
|
22
|
-
dslh (0.
|
28
|
+
dslh (0.2.7)
|
29
|
+
execjs (2.7.0)
|
23
30
|
hashie (3.4.6)
|
24
31
|
highline (1.7.8)
|
25
32
|
jmespath (1.3.1)
|
26
|
-
|
27
|
-
|
33
|
+
json (1.8.5)
|
34
|
+
json5 (0.0.1)
|
35
|
+
kumogata (0.5.10)
|
36
|
+
aws-sdk-v1
|
28
37
|
coderay
|
38
|
+
coffee-script
|
29
39
|
diffy
|
40
|
+
dslh (>= 0.2.7, < 0.3)
|
30
41
|
hashie
|
31
42
|
highline
|
43
|
+
json
|
44
|
+
json5
|
45
|
+
net-ssh
|
46
|
+
retryable (~> 2.0.0)
|
32
47
|
term-ansicolor
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
kumogata2
|
48
|
+
therubyracer
|
49
|
+
uuidtools
|
50
|
+
libv8 (3.16.14.17)
|
51
|
+
mini_portile2 (2.1.0)
|
38
52
|
minitest (5.10.1)
|
39
|
-
|
53
|
+
net-ssh (4.0.1)
|
54
|
+
nokogiri (1.7.0.1)
|
55
|
+
mini_portile2 (~> 2.1.0)
|
56
|
+
rake (11.3.0)
|
57
|
+
ref (2.0.0)
|
58
|
+
retryable (2.0.4)
|
40
59
|
term-ansicolor (1.4.0)
|
41
60
|
tins (~> 1.0)
|
61
|
+
therubyracer (0.12.3)
|
62
|
+
libv8 (~> 3.16.14.15)
|
63
|
+
ref
|
42
64
|
tins (1.13.0)
|
65
|
+
uuidtools (2.1.5)
|
43
66
|
|
44
67
|
PLATFORMS
|
45
68
|
ruby
|
46
69
|
|
47
70
|
DEPENDENCIES
|
48
|
-
bundler (~> 1.
|
71
|
+
bundler (~> 1.11)
|
49
72
|
kumogata-template!
|
50
|
-
minitest (~> 5.
|
51
|
-
rake (~>
|
73
|
+
minitest (~> 5.8)
|
74
|
+
rake (~> 11.1)
|
52
75
|
|
53
76
|
BUNDLED WITH
|
54
77
|
1.13.7
|
data/README.md
CHANGED
@@ -4,10 +4,13 @@
|
|
4
4
|
|
5
5
|
## About
|
6
6
|
|
7
|
-
- `kumogate-template` is a template sets for [
|
7
|
+
- `kumogate-template` is a template sets for [kumogata](https://github.com/winebarrel/kumogata).
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
11
|
+
Add
|
12
|
+
|
13
|
+
|
11
14
|
Add this line to your application's Gemfile:
|
12
15
|
|
13
16
|
```ruby
|
@@ -193,3 +196,9 @@ EOS
|
|
193
196
|
- AWS::S3::Bucket
|
194
197
|
- AWS::SNS::Topic
|
195
198
|
- AWS::SQS::Queue
|
199
|
+
|
200
|
+
|
201
|
+
## TODO
|
202
|
+
|
203
|
+
- Support [Kumogata2](https://github.com/winebarrel/kumogata2)
|
204
|
+
- Useful kumogate-template snippets
|
data/bin/kumogata-template
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
$: << File.expand_path("#{File.dirname __FILE__}/../lib")
|
3
3
|
require 'rubygems'
|
4
4
|
require 'kumogata/template/ext/kumogata'
|
5
|
-
require 'kumogata/template/ext/
|
5
|
+
require 'kumogata/template/ext/argument_parser'
|
6
6
|
require 'kumogata/template'
|
7
7
|
|
8
8
|
|
9
|
-
load Gem.bin_path('
|
9
|
+
load Gem.bin_path('kumogata', 'kumogata')
|
data/kumogata-template.gemspec
CHANGED
@@ -18,10 +18,9 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_dependency 'aws-sdk', '~> 2'
|
22
|
-
spec.add_dependency '
|
23
|
-
spec.
|
24
|
-
spec.add_development_dependency '
|
25
|
-
spec.add_development_dependency '
|
26
|
-
spec.add_development_dependency 'minitest', '~> 5.10'
|
21
|
+
spec.add_dependency 'aws-sdk', '~> 2.3'
|
22
|
+
spec.add_dependency 'kumogata', '0.5.10'
|
23
|
+
spec.add_development_dependency 'bundler', '~> 1.11'
|
24
|
+
spec.add_development_dependency 'rake', '~> 11.1'
|
25
|
+
spec.add_development_dependency 'minitest', '~> 5.8'
|
27
26
|
end
|
data/lib/kumogata/template.rb
CHANGED
@@ -3,6 +3,8 @@ require 'kumogata/template/autoscaling'
|
|
3
3
|
require 'kumogata/template/certificate'
|
4
4
|
require 'kumogata/template/cloudfront'
|
5
5
|
require 'kumogata/template/cloudwatch'
|
6
|
+
require 'kumogata/template/codebuild'
|
7
|
+
require 'kumogata/template/codecommit'
|
6
8
|
require 'kumogata/template/codedeploy'
|
7
9
|
require 'kumogata/template/const'
|
8
10
|
require 'kumogata/template/datapipeline'
|
@@ -15,6 +17,7 @@ require 'kumogata/template/emr'
|
|
15
17
|
require 'kumogata/template/helper'
|
16
18
|
require 'kumogata/template/iam'
|
17
19
|
require 'kumogata/template/lambda'
|
20
|
+
require 'kumogata/template/logs'
|
18
21
|
require 'kumogata/template/s3'
|
19
22
|
require 'kumogata/template/sns'
|
20
23
|
require 'kumogata/template/version'
|
@@ -0,0 +1,86 @@
|
|
1
|
+
#
|
2
|
+
# Helper - CodeBuild
|
3
|
+
#
|
4
|
+
require 'kumogata/template/helper'
|
5
|
+
|
6
|
+
def _codebuild_to_compute(value)
|
7
|
+
case value
|
8
|
+
when "small"
|
9
|
+
"BUILD_GENERAL1_SMALL"
|
10
|
+
when "medium"
|
11
|
+
"BUILD_GENERAL1_MEDIUM"
|
12
|
+
when "large"
|
13
|
+
"BUILD_GENERAL1_LARGE"
|
14
|
+
else
|
15
|
+
"BUILD_GENERAL1_MEDIUM"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def _codebuild_source_type(value)
|
20
|
+
case value
|
21
|
+
when "codecommit", "commit"
|
22
|
+
"CODECOMMIT"
|
23
|
+
when "codepipeline", "pipeline"
|
24
|
+
"CODEPIPELINE"
|
25
|
+
when "github", "gh"
|
26
|
+
"GITHUB"
|
27
|
+
when "s3"
|
28
|
+
"S3"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
def _codebuild_artifacts(args)
|
34
|
+
name = args[:name] || ""
|
35
|
+
ns = args[:ns] || ""
|
36
|
+
packaging = args[:packaging] || ""
|
37
|
+
path = args[:path] || ""
|
38
|
+
type = _valid_values(args[:type], %w( codepipeline no_artifacts s3 ), "no_artifacts")
|
39
|
+
|
40
|
+
_{
|
41
|
+
Location location if type != "codepipeline" and type != "no_artifacts"
|
42
|
+
Name name if type != "codepipeline" and type != "no_artifacts"
|
43
|
+
NamespaceType ns if type != "codepipeline" and type != "no_artifacts"
|
44
|
+
Packaging packaging if type != "codepipeline" and type != "no_artifacts"
|
45
|
+
Path path unless path.empty?
|
46
|
+
Type type
|
47
|
+
}
|
48
|
+
end
|
49
|
+
|
50
|
+
def _codebuild_environement(args)
|
51
|
+
compute = _codebuild_to_compute(args[:compute])
|
52
|
+
env_hash = _codebuild_environement_hash(args[:env])
|
53
|
+
image = args[:image]
|
54
|
+
|
55
|
+
_{
|
56
|
+
ComputeType compute
|
57
|
+
EnvironmentVariables env_hash
|
58
|
+
Image image
|
59
|
+
Type "LINUX_CONTAINER"
|
60
|
+
}
|
61
|
+
end
|
62
|
+
|
63
|
+
def _codebuild_environement_hash(args)
|
64
|
+
hash = args || {}
|
65
|
+
|
66
|
+
array = []
|
67
|
+
hash.each_pair do |k, v|
|
68
|
+
array << _{
|
69
|
+
Name k
|
70
|
+
Value v
|
71
|
+
}
|
72
|
+
end
|
73
|
+
array
|
74
|
+
end
|
75
|
+
|
76
|
+
def _codebuild_source(args)
|
77
|
+
build = args[:build] || ""
|
78
|
+
location = args[:location] || ""
|
79
|
+
type = _codebuild_source_type(args[:type])
|
80
|
+
|
81
|
+
_{
|
82
|
+
BuildSpec build unless build.empty?
|
83
|
+
Location location unless type == "CODEPIPELINE"
|
84
|
+
Type type
|
85
|
+
}
|
86
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#
|
2
|
+
# Helper - CodeCommit
|
3
|
+
#
|
4
|
+
require 'kumogata/template/helper'
|
5
|
+
|
6
|
+
def _codecommit_triggers(args)
|
7
|
+
triggers = args[:trigger] || []
|
8
|
+
|
9
|
+
array = []
|
10
|
+
triggers.each do |trigger|
|
11
|
+
array << _{
|
12
|
+
Branches trigger[:branchs] || []
|
13
|
+
CustomData trigger[:custom] || ""
|
14
|
+
DestinationArn trigger[:dest] || ""
|
15
|
+
Events trigger[:events] || []
|
16
|
+
Name trigger[:name] || ""
|
17
|
+
}
|
18
|
+
end
|
19
|
+
array
|
20
|
+
end
|
@@ -102,7 +102,10 @@ def _elb_listeners(args)
|
|
102
102
|
443
|
103
103
|
end
|
104
104
|
policies = []
|
105
|
-
|
105
|
+
if protocol == "https" or protocol == "ssl"
|
106
|
+
policy = listener[:policy] || "2016-08"
|
107
|
+
policies << "ELBSecurityPolicy-#{policy}"
|
108
|
+
end
|
106
109
|
ssl = _ref_string("ssl", listener)
|
107
110
|
|
108
111
|
array << _{
|
@@ -1,9 +1,7 @@
|
|
1
|
-
require '
|
2
|
-
require '
|
3
|
-
require 'kumogata2/logger'
|
4
|
-
require 'kumogata2/plugin/ruby'
|
1
|
+
require 'kumogata'
|
2
|
+
require 'kumogata/argument_parser'
|
5
3
|
|
6
|
-
class
|
4
|
+
class Kumogata::Client
|
7
5
|
def init(stack_name)
|
8
6
|
begin
|
9
7
|
base_template = ''
|
@@ -23,29 +21,13 @@ class Kumogata2::Client
|
|
23
21
|
template = base_template.gsub('#{NAME}', stack_name)
|
24
22
|
f.write(template)
|
25
23
|
}
|
26
|
-
|
24
|
+
Kumogata.logger.info("Saved template to #{stack_name}.rb".green)
|
27
25
|
rescue => e
|
28
|
-
|
26
|
+
Kumogata.logger.info("Failed to template #{stack_name} - #{e}".red)
|
29
27
|
end
|
30
28
|
nil
|
31
29
|
end
|
32
|
-
end
|
33
|
-
|
34
|
-
class Kumogata2::Plugin::Ruby
|
35
|
-
def parse(str)
|
36
|
-
str = <<EOS
|
37
|
-
template do
|
38
|
-
#{str}
|
39
|
-
end
|
40
|
-
EOS
|
41
|
-
context = Kumogata2::Plugin::Ruby::Context.new(@options)
|
42
|
-
context.instance_eval(str, @options.path_or_url)
|
43
|
-
@post = context.instance_variable_get(:@_post)
|
44
|
-
context.instance_variable_get(:@_template)
|
45
|
-
end
|
46
|
-
end
|
47
30
|
|
48
|
-
class Kumogata2::Plugin::Ruby::Context
|
49
31
|
def define_template_func(scope, path_or_url)
|
50
32
|
functions = ''
|
51
33
|
Dir.glob(File.join(get_template_path, '*.rb')).all? do |file|
|
@@ -118,6 +100,40 @@ class Kumogata2::Plugin::Ruby::Context
|
|
118
100
|
template_path
|
119
101
|
end
|
120
102
|
|
103
|
+
def evaluate_template(template, path_or_url)
|
104
|
+
key_converter = proc do |key|
|
105
|
+
key = key.to_s
|
106
|
+
unless @options.skip_replace_underscore?
|
107
|
+
key.gsub!('_', ':')
|
108
|
+
key.gsub!('__', '::')
|
109
|
+
end
|
110
|
+
key
|
111
|
+
end
|
112
|
+
|
113
|
+
value_converter = proc do |v|
|
114
|
+
case v
|
115
|
+
when Hash, Array
|
116
|
+
v
|
117
|
+
else
|
118
|
+
v.to_s
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
template = Dslh.eval(template.read, {
|
123
|
+
:key_conv => key_converter,
|
124
|
+
:value_conv => value_converter,
|
125
|
+
:scope_hook => proc {|scope|
|
126
|
+
define_template_func(scope, path_or_url)
|
127
|
+
},
|
128
|
+
:filename => path_or_url,
|
129
|
+
})
|
130
|
+
|
131
|
+
@outputs_filter.fetch!(template)
|
132
|
+
@post_processing.fetch!(template)
|
133
|
+
|
134
|
+
return template
|
135
|
+
end
|
136
|
+
|
121
137
|
def devaluate_template(template)
|
122
138
|
exclude_key = proc do |k|
|
123
139
|
k = k.to_s.gsub('::', '__')
|
@@ -136,6 +152,7 @@ class Kumogata2::Plugin::Ruby::Context
|
|
136
152
|
end
|
137
153
|
end
|
138
154
|
else
|
155
|
+
k.gsub(':', '_')
|
139
156
|
k.gsub('::', '__')
|
140
157
|
end
|
141
158
|
end
|
@@ -148,22 +165,6 @@ class Kumogata2::Plugin::Ruby::Context
|
|
148
165
|
end
|
149
166
|
end
|
150
167
|
|
151
|
-
|
152
|
-
key_conv: key_conv,
|
153
|
-
value_conv: value_conv,
|
154
|
-
exclude_key: exclude_key,
|
155
|
-
initial_depth: 1,
|
156
|
-
}
|
157
|
-
|
158
|
-
if ENV['EXPORT_RUBY_USE_BRACES'] == '1'
|
159
|
-
dslh_opts[:use_braces_instead_of_do_end] = true
|
160
|
-
end
|
161
|
-
|
162
|
-
if ENV['EXPORT_RUBY_OLD_FORMAT'] == '1'
|
163
|
-
dslh_opts[:dump_old_hash_array_format] = true
|
164
|
-
end
|
165
|
-
|
166
|
-
dsl = Dslh.deval(template, dslh_opts)
|
167
|
-
dsl.strip
|
168
|
+
Dslh.deval(template, :key_conv => key_conv, :value_conv => value_conv, :exclude_key => exclude_key)
|
168
169
|
end
|
169
170
|
end
|