sumomo 0.8.4 → 0.8.6
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 +5 -5
- data/.rubocop.yml +1 -0
- data/.rubocop_todo.yml +169 -0
- data/Gemfile +2 -0
- data/Rakefile +5 -3
- data/bin/console +4 -3
- data/data/sumomo/api_modules/node_modules/.bin/uuid +1 -1
- data/data/sumomo/custom_resources/TempS3Bucket.js +208 -0
- data/exe/sumomo +42 -41
- data/lib/sumomo.rb +235 -233
- data/lib/sumomo/api.rb +148 -151
- data/lib/sumomo/cdn.rb +119 -113
- data/lib/sumomo/dns.rb +20 -20
- data/lib/sumomo/ec2.rb +490 -491
- data/lib/sumomo/ecs.rb +256 -262
- data/lib/sumomo/irregular.rb +9 -0
- data/lib/sumomo/momo_extensions/resource.rb +8 -7
- data/lib/sumomo/momo_extensions/stack.rb +4 -3
- data/lib/sumomo/network.rb +109 -106
- data/lib/sumomo/stack.rb +191 -189
- data/lib/sumomo/version.rb +3 -1
- data/sumomo.gemspec +23 -22
- metadata +25 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c26b0a3b7272251c44640055c93cd3e985c47d60abb14a14f50584eda5b65184
|
4
|
+
data.tar.gz: c08fc6ccc59a029ab43ef96c4e2a5e687189300998aaa34b9fd417c276339488
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '08aa5eda9cc8144d2c5df4ba8622f65bef1f2f66ae54e30538afe8e943325ffcbd1e151bef541d58e47637e64fa759e405e9b4b3011038340ccc720b595cd301'
|
7
|
+
data.tar.gz: b74848ddce1200d78c020e56ff0fcff3625fe22b6195b8167ad6338bc66449e5fb1613f96042a4497f962e6e764a4b68a61eb2703610c1844e0da2df3897bed4
|
data/.rubocop.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2019-11-05 10:31:48 +0900 using RuboCop version 0.76.0.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 4
|
10
|
+
# Cop supports --auto-correct.
|
11
|
+
# Configuration parameters: EnforcedStyleAlignWith, AutoCorrect, Severity.
|
12
|
+
# SupportedStylesAlignWith: keyword, variable, start_of_line
|
13
|
+
Layout/EndAlignment:
|
14
|
+
Exclude:
|
15
|
+
- 'exe/sumomo'
|
16
|
+
- 'lib/sumomo/ec2.rb'
|
17
|
+
- 'lib/sumomo/ecs.rb'
|
18
|
+
|
19
|
+
# Offense count: 3
|
20
|
+
Lint/AmbiguousBlockAssociation:
|
21
|
+
Exclude:
|
22
|
+
- 'lib/sumomo/ec2.rb'
|
23
|
+
- 'lib/sumomo/ecs.rb'
|
24
|
+
|
25
|
+
# Offense count: 2
|
26
|
+
Lint/ParenthesesAsGroupedExpression:
|
27
|
+
Exclude:
|
28
|
+
- 'lib/sumomo/api.rb'
|
29
|
+
|
30
|
+
# Offense count: 11
|
31
|
+
# Cop supports --auto-correct.
|
32
|
+
# Configuration parameters: AllowUnusedKeywordArguments, IgnoreEmptyMethods.
|
33
|
+
Lint/UnusedMethodArgument:
|
34
|
+
Exclude:
|
35
|
+
- 'lib/sumomo.rb'
|
36
|
+
- 'lib/sumomo/ec2.rb'
|
37
|
+
|
38
|
+
# Offense count: 3
|
39
|
+
Lint/UselessAssignment:
|
40
|
+
Exclude:
|
41
|
+
- 'exe/sumomo'
|
42
|
+
- 'lib/sumomo/ecs.rb'
|
43
|
+
- 'lib/sumomo/stack.rb'
|
44
|
+
|
45
|
+
# Offense count: 15
|
46
|
+
Metrics/AbcSize:
|
47
|
+
Max: 137
|
48
|
+
|
49
|
+
# Offense count: 10
|
50
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
51
|
+
# ExcludedMethods: refine
|
52
|
+
Metrics/BlockLength:
|
53
|
+
Max: 146
|
54
|
+
|
55
|
+
# Offense count: 1
|
56
|
+
# Configuration parameters: CountComments.
|
57
|
+
Metrics/ClassLength:
|
58
|
+
Max: 101
|
59
|
+
|
60
|
+
# Offense count: 5
|
61
|
+
Metrics/CyclomaticComplexity:
|
62
|
+
Max: 19
|
63
|
+
|
64
|
+
# Offense count: 19
|
65
|
+
# Configuration parameters: CountComments, ExcludedMethods.
|
66
|
+
Metrics/MethodLength:
|
67
|
+
Max: 213
|
68
|
+
|
69
|
+
# Offense count: 6
|
70
|
+
# Configuration parameters: CountComments.
|
71
|
+
Metrics/ModuleLength:
|
72
|
+
Max: 423
|
73
|
+
|
74
|
+
# Offense count: 9
|
75
|
+
# Configuration parameters: CountKeywordArgs.
|
76
|
+
Metrics/ParameterLists:
|
77
|
+
Max: 27
|
78
|
+
|
79
|
+
# Offense count: 6
|
80
|
+
Metrics/PerceivedComplexity:
|
81
|
+
Max: 19
|
82
|
+
|
83
|
+
# Offense count: 1
|
84
|
+
Naming/AccessorMethodName:
|
85
|
+
Exclude:
|
86
|
+
- 'lib/sumomo/ec2.rb'
|
87
|
+
|
88
|
+
# Offense count: 2
|
89
|
+
# Configuration parameters: EnforcedStyle.
|
90
|
+
# SupportedStyles: snake_case, normalcase, non_integer
|
91
|
+
Naming/VariableNumber:
|
92
|
+
Exclude:
|
93
|
+
- 'lib/sumomo/ec2.rb'
|
94
|
+
|
95
|
+
# Offense count: 2
|
96
|
+
Security/Eval:
|
97
|
+
Exclude:
|
98
|
+
- 'exe/sumomo'
|
99
|
+
|
100
|
+
# Offense count: 1
|
101
|
+
Style/CommentedKeyword:
|
102
|
+
Exclude:
|
103
|
+
- 'lib/sumomo/ecs.rb'
|
104
|
+
|
105
|
+
# Offense count: 1
|
106
|
+
# Cop supports --auto-correct.
|
107
|
+
# Configuration parameters: EnforcedStyle, SingleLineConditionsOnly, IncludeTernaryExpressions.
|
108
|
+
# SupportedStyles: assign_to_condition, assign_inside_condition
|
109
|
+
Style/ConditionalAssignment:
|
110
|
+
Exclude:
|
111
|
+
- 'lib/sumomo/ecs.rb'
|
112
|
+
|
113
|
+
# Offense count: 14
|
114
|
+
Style/Documentation:
|
115
|
+
Exclude:
|
116
|
+
- 'spec/**/*'
|
117
|
+
- 'test/**/*'
|
118
|
+
- 'lib/sumomo.rb'
|
119
|
+
- 'lib/sumomo/api.rb'
|
120
|
+
- 'lib/sumomo/cdn.rb'
|
121
|
+
- 'lib/sumomo/dns.rb'
|
122
|
+
- 'lib/sumomo/ec2.rb'
|
123
|
+
- 'lib/sumomo/ecs.rb'
|
124
|
+
- 'lib/sumomo/momo_extensions/resource.rb'
|
125
|
+
- 'lib/sumomo/momo_extensions/stack.rb'
|
126
|
+
- 'lib/sumomo/network.rb'
|
127
|
+
- 'lib/sumomo/stack.rb'
|
128
|
+
|
129
|
+
# Offense count: 3
|
130
|
+
# Configuration parameters: MinBodyLength.
|
131
|
+
Style/GuardClause:
|
132
|
+
Exclude:
|
133
|
+
- 'lib/sumomo.rb'
|
134
|
+
- 'sumomo.gemspec'
|
135
|
+
|
136
|
+
# Offense count: 5
|
137
|
+
# Cop supports --auto-correct.
|
138
|
+
Style/IfUnlessModifier:
|
139
|
+
Exclude:
|
140
|
+
- 'lib/sumomo/ec2.rb'
|
141
|
+
- 'lib/sumomo/ecs.rb'
|
142
|
+
- 'lib/sumomo/network.rb'
|
143
|
+
|
144
|
+
# Offense count: 1
|
145
|
+
Style/MethodMissingSuper:
|
146
|
+
Exclude:
|
147
|
+
- 'lib/sumomo.rb'
|
148
|
+
|
149
|
+
# Offense count: 2
|
150
|
+
Style/MissingRespondToMissing:
|
151
|
+
Exclude:
|
152
|
+
- 'lib/sumomo.rb'
|
153
|
+
- 'lib/sumomo/api.rb'
|
154
|
+
|
155
|
+
# Offense count: 1
|
156
|
+
# Cop supports --auto-correct.
|
157
|
+
# Configuration parameters: AutoCorrect, EnforcedStyle, IgnoredMethods.
|
158
|
+
# SupportedStyles: predicate, comparison
|
159
|
+
Style/NumericPredicate:
|
160
|
+
Exclude:
|
161
|
+
- 'spec/**/*'
|
162
|
+
- 'lib/sumomo/ec2.rb'
|
163
|
+
|
164
|
+
# Offense count: 71
|
165
|
+
# Cop supports --auto-correct.
|
166
|
+
# Configuration parameters: AutoCorrect, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, IgnoredPatterns.
|
167
|
+
# URISchemes: http, https
|
168
|
+
Metrics/LineLength:
|
169
|
+
Max: 153
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
data/bin/console
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
4
|
+
require 'bundler/setup'
|
5
|
+
require 'sumomo'
|
5
6
|
|
6
7
|
# You can add fixtures and/or initialization code here to make experimenting
|
7
8
|
# with your gem easier. You can also use a different console, if you like.
|
@@ -10,5 +11,5 @@ require "sumomo"
|
|
10
11
|
# require "pry"
|
11
12
|
# Pry.start
|
12
13
|
|
13
|
-
require
|
14
|
+
require 'irb'
|
14
15
|
IRB.start
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
../uuid/bin/uuid
|
@@ -0,0 +1,208 @@
|
|
1
|
+
var s3 = new aws.S3();
|
2
|
+
var name = request.ResourceProperties.BucketName;
|
3
|
+
var copy_from_dir = request.ResourceProperties.CopyFromDirectory;
|
4
|
+
var copy_from_bucket = request.ResourceProperties.CopyFromBucket;
|
5
|
+
var success_obj = {
|
6
|
+
Arn: "arn:aws:s3:::" + name,
|
7
|
+
DomainName: name + ".s3.amazonaws.com"
|
8
|
+
}
|
9
|
+
var error_extra = "";
|
10
|
+
|
11
|
+
function copy_file(from, from_bucket, to, to_bucket, success, fail)
|
12
|
+
{
|
13
|
+
s3.copyObject(
|
14
|
+
{
|
15
|
+
CopySource: "/" + from_bucket + "/" + from,
|
16
|
+
Bucket: to_bucket,
|
17
|
+
Key: to
|
18
|
+
}, function(err, data)
|
19
|
+
{
|
20
|
+
if (err)
|
21
|
+
{
|
22
|
+
error_extra = "\nCopyobject: " + from + " " + from_bucket + " " + to + " " + to_bucket
|
23
|
+
fail(err);
|
24
|
+
}
|
25
|
+
else
|
26
|
+
{
|
27
|
+
success(data);
|
28
|
+
}
|
29
|
+
}
|
30
|
+
);
|
31
|
+
}
|
32
|
+
|
33
|
+
function actually_copy_files(files_left, success, fail)
|
34
|
+
{
|
35
|
+
if (files_left.length == 0) { return success(); }
|
36
|
+
|
37
|
+
var filename = files_left.shift();
|
38
|
+
|
39
|
+
copy_file(
|
40
|
+
filename,
|
41
|
+
copy_from_bucket,
|
42
|
+
filename.replace(copy_from_dir + '/', ''),
|
43
|
+
name,
|
44
|
+
function()
|
45
|
+
{
|
46
|
+
actually_copy_files(files_left, success, fail);
|
47
|
+
},
|
48
|
+
fail
|
49
|
+
)
|
50
|
+
}
|
51
|
+
|
52
|
+
function copy_files(success, fail)
|
53
|
+
{
|
54
|
+
if (!copy_from_dir || !copy_from_bucket) { return success(); }
|
55
|
+
|
56
|
+
var files_to_copy = [];
|
57
|
+
|
58
|
+
foreach_file(
|
59
|
+
copy_from_bucket,
|
60
|
+
function(file)
|
61
|
+
{
|
62
|
+
if (file.Key.indexOf(copy_from_dir) == 0)
|
63
|
+
{
|
64
|
+
files_to_copy.push(file.Key);
|
65
|
+
}
|
66
|
+
},
|
67
|
+
function()
|
68
|
+
{
|
69
|
+
actually_copy_files(files_to_copy, success, fail);
|
70
|
+
},
|
71
|
+
fail
|
72
|
+
);
|
73
|
+
}
|
74
|
+
|
75
|
+
function create_bucket(name, success, fail)
|
76
|
+
{
|
77
|
+
var create_params = { Bucket: name };
|
78
|
+
|
79
|
+
s3.createBucket(create_params, function(err, data)
|
80
|
+
{
|
81
|
+
if (err)
|
82
|
+
{
|
83
|
+
fail(err);
|
84
|
+
}
|
85
|
+
else
|
86
|
+
{
|
87
|
+
copy_files(success, fail);
|
88
|
+
}
|
89
|
+
});
|
90
|
+
}
|
91
|
+
|
92
|
+
function foreach_file(name, func, success, fail)
|
93
|
+
{
|
94
|
+
var foreach_params = { Bucket: name };
|
95
|
+
|
96
|
+
s3.listObjects(foreach_params, function (err, data)
|
97
|
+
{
|
98
|
+
if (err)
|
99
|
+
{
|
100
|
+
fail(err);
|
101
|
+
return;
|
102
|
+
}
|
103
|
+
|
104
|
+
var items = data.Contents;
|
105
|
+
|
106
|
+
for (var i = 0; i < items.length; i += 1)
|
107
|
+
{
|
108
|
+
func(items[i])
|
109
|
+
}
|
110
|
+
|
111
|
+
success();
|
112
|
+
});
|
113
|
+
}
|
114
|
+
|
115
|
+
function delete_files(name, files, success, fail)
|
116
|
+
{
|
117
|
+
var delete_files_params = {
|
118
|
+
Bucket: name,
|
119
|
+
Delete: {
|
120
|
+
Objects: files,
|
121
|
+
Quiet: false
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
if (files.length == 0)
|
126
|
+
{
|
127
|
+
// If the array has zero size, AWS throws a malformed
|
128
|
+
// XML error, which makes no sense but that is what
|
129
|
+
// happens.
|
130
|
+
return success();
|
131
|
+
}
|
132
|
+
|
133
|
+
s3.deleteObjects(delete_files_params, function(err, data)
|
134
|
+
{
|
135
|
+
if (err)
|
136
|
+
{
|
137
|
+
fail("DELETE FILES FAILED:" + err + "\n" + JSON.stringify(delete_files_params) + "\n");
|
138
|
+
return;
|
139
|
+
}
|
140
|
+
|
141
|
+
success();
|
142
|
+
});
|
143
|
+
}
|
144
|
+
|
145
|
+
function delete_bucket(name, success, fail)
|
146
|
+
{
|
147
|
+
var delete_bucket_params = { Bucket: name };
|
148
|
+
|
149
|
+
s3.deleteBucket(delete_bucket_params, function(err, data)
|
150
|
+
{
|
151
|
+
if (err)
|
152
|
+
{
|
153
|
+
fail("DELETE BUCKET FAILED:" + err + "\n" + JSON.stringify(delete_bucket_params) + "\n");
|
154
|
+
}
|
155
|
+
else
|
156
|
+
{
|
157
|
+
success(data);
|
158
|
+
}
|
159
|
+
});
|
160
|
+
}
|
161
|
+
|
162
|
+
function send_success()
|
163
|
+
{
|
164
|
+
Cloudformation.send(request, context, Cloudformation.SUCCESS, success_obj, "Success", name);
|
165
|
+
}
|
166
|
+
|
167
|
+
function send_fail(err)
|
168
|
+
{
|
169
|
+
Cloudformation.send(request, context, Cloudformation.FAILED, {}, JSON.stringify(err) + "\n" + error_extra);
|
170
|
+
}
|
171
|
+
|
172
|
+
function delete_all_files(success, fail)
|
173
|
+
{
|
174
|
+
var objects = [];
|
175
|
+
foreach_file(
|
176
|
+
name,
|
177
|
+
function(file)
|
178
|
+
{
|
179
|
+
objects.push({ Key: file.Key });
|
180
|
+
},
|
181
|
+
function()
|
182
|
+
{
|
183
|
+
delete_files(name, objects,
|
184
|
+
function()
|
185
|
+
{
|
186
|
+
delete_bucket(name, success, fail);
|
187
|
+
},
|
188
|
+
fail
|
189
|
+
);
|
190
|
+
},
|
191
|
+
fail
|
192
|
+
)
|
193
|
+
}
|
194
|
+
|
195
|
+
if (request.RequestType == "Create")
|
196
|
+
{
|
197
|
+
create_bucket(name, send_success, send_fail);
|
198
|
+
}
|
199
|
+
|
200
|
+
if (request.RequestType == "Update")
|
201
|
+
{
|
202
|
+
send_success();
|
203
|
+
}
|
204
|
+
|
205
|
+
if (request.RequestType == "Delete")
|
206
|
+
{
|
207
|
+
delete_all_files(send_success, send_fail);
|
208
|
+
}
|
data/exe/sumomo
CHANGED
@@ -1,61 +1,62 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
4
|
+
require 'trollop'
|
5
|
+
require 'sumomo'
|
6
|
+
require 'yaml'
|
6
7
|
|
7
|
-
SUB_COMMANDS = %w
|
8
|
-
global_opts = Trollop
|
8
|
+
SUB_COMMANDS = %w[delete create update outputs testapi].freeze
|
9
|
+
global_opts = Trollop.options do
|
9
10
|
banner <<-USAGE
|
10
11
|
Sumomo v#{Sumomo::VERSION}
|
11
12
|
|
12
13
|
Usage: sumomo [options] <create|update|delete|outputs> <stackname>
|
13
14
|
USAGE
|
14
15
|
|
15
|
-
opt :region,
|
16
|
-
opt :profile,
|
16
|
+
opt :region, 'AWS region to use', type: :string, default: 'ap-northeast-1'
|
17
|
+
opt :profile, 'AWS credential profile to use', type: :string, default: 'default'
|
17
18
|
|
18
19
|
stop_on SUB_COMMANDS
|
19
20
|
end
|
20
21
|
|
21
|
-
ENV[
|
22
|
+
ENV['AWS_PROFILE'] = global_opts[:profile]
|
22
23
|
|
23
|
-
puts
|
24
|
-
p ENV[
|
24
|
+
puts 'Using profile:'
|
25
|
+
p ENV['AWS_PROFILE']
|
25
26
|
|
26
27
|
cmd = ARGV.shift # get the subcommand
|
27
28
|
|
28
29
|
cmd_opts = case cmd
|
29
|
-
when
|
30
|
-
|
31
|
-
|
32
|
-
when
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
when
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
when
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
else
|
58
|
-
|
30
|
+
when 'delete'
|
31
|
+
Sumomo.delete_stack(name: ARGV[0], region: global_opts[:region])
|
32
|
+
|
33
|
+
when 'create', 'update'
|
34
|
+
local_opts = Trollop.options do
|
35
|
+
opt :filename, 'File that describes the stack', type: :string, default: 'Sumomofile'
|
36
|
+
end
|
37
|
+
Sumomo.create_stack(name: ARGV[0], region: global_opts[:region]) do
|
38
|
+
proc = proc {}
|
39
|
+
eval File.read(local_opts[:filename]), proc.binding, local_opts[:filename]
|
40
|
+
end
|
41
|
+
|
42
|
+
when 'outputs'
|
43
|
+
puts "Outputs for stack #{ARGV[0]}"
|
44
|
+
puts Sumomo.get_stack_outputs(name: ARGV[0], region: global_opts[:region]).to_yaml
|
45
|
+
|
46
|
+
when 'testapi'
|
47
|
+
local_opts = Trollop.options do
|
48
|
+
opt :filename, 'File that describes the stack', type: :string, default: 'Sumomofile'
|
49
|
+
opt :apiname, 'Name of the API you want to test', type: :string
|
50
|
+
opt :prettyprint, 'Test API outputs JSON with nice indentation', type: :boolean, default: true
|
51
|
+
end
|
52
|
+
puts 'API Test Mode'
|
53
|
+
Sumomo.test_api(local_opts[:apiname], local_opts[:prettyprint]) do
|
54
|
+
proc = proc {}
|
55
|
+
eval File.read(local_opts[:filename]), proc.binding, local_opts[:filename]
|
56
|
+
end
|
57
|
+
exit(0)
|
58
|
+
else
|
59
|
+
Trollop.die "Unknown subcommand #{cmd.inspect}"
|
59
60
|
end
|
60
61
|
|
61
|
-
Sumomo
|
62
|
+
Sumomo.wait_for_stack(name: ARGV[0], region: global_opts[:region])
|