hekate 0.1.0.pre20 → 0.1.0.pre21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +290 -0
- data/Gemfile +3 -1
- data/Gemfile.lock +10 -10
- data/Rakefile +4 -2
- data/hekate.gemspec +26 -25
- data/lib/hekate.rb +7 -5
- data/lib/hekate/aws.rb +40 -31
- data/lib/hekate/engine.rb +36 -37
- data/lib/hekate/railtie.rb +3 -1
- data/lib/hekate/version.rb +3 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c564b4599adcfbdf1638e1631ec621991b72f954
|
4
|
+
data.tar.gz: 79660fe38743d7829183ab19197e9be93cf5d5b5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cdb7a89dd31c9acfe542cf81bde6a05658455d5d4caa262432c8bc12999e037f85c6872fd38ea0e1a1894f44b7f7c2bbbd0c2d8e67b2dfe40b603b0b01efb2f
|
7
|
+
data.tar.gz: 094746ed8a4100deb3cc5ec064ed5739963b05303de1168474472f6765aacd0314f02dc28681fa1bd03727d46afe523450863e5a166679cbcef0a3ac63cb6d2c
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,290 @@
|
|
1
|
+
AllCops:
|
2
|
+
TargetRubyVersion: 2.3
|
3
|
+
Exclude:
|
4
|
+
- 'vendor/**/*'
|
5
|
+
- 'db/**/*'
|
6
|
+
- 'dashboard/**/*'
|
7
|
+
- 'script/**/*'
|
8
|
+
- 'Guardfile'
|
9
|
+
- 'config.ru'
|
10
|
+
- 'bin/**/*'
|
11
|
+
UseCache: false
|
12
|
+
|
13
|
+
Style/CollectionMethods:
|
14
|
+
Description: Preferred collection methods.
|
15
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size
|
16
|
+
Enabled: true
|
17
|
+
PreferredMethods:
|
18
|
+
collect: map
|
19
|
+
collect!: map!
|
20
|
+
find: detect
|
21
|
+
find_all: select
|
22
|
+
inject: reduce
|
23
|
+
Layout/DotPosition:
|
24
|
+
Description: Checks the position of the dot in multi-line method calls.
|
25
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains
|
26
|
+
Enabled: true
|
27
|
+
EnforcedStyle: trailing
|
28
|
+
SupportedStyles:
|
29
|
+
- leading
|
30
|
+
- trailing
|
31
|
+
Style/FileName:
|
32
|
+
Description: Use snake_case for source file names.
|
33
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#snake-case-files
|
34
|
+
Enabled: true
|
35
|
+
Exclude: []
|
36
|
+
Style/GuardClause:
|
37
|
+
Description: Check for conditionals that can be replaced with guard clauses
|
38
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals
|
39
|
+
Enabled: true
|
40
|
+
MinBodyLength: 1
|
41
|
+
Style/IfUnlessModifier:
|
42
|
+
Description: Favor modifier if/unless usage when you have a single-line body.
|
43
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier
|
44
|
+
Enabled: false
|
45
|
+
MaxLineLength: 80
|
46
|
+
Style/OptionHash:
|
47
|
+
Description: Don't use option hashes when you can use keyword arguments.
|
48
|
+
Enabled: false
|
49
|
+
Style/PredicateName:
|
50
|
+
Description: Check the names of predicate methods.
|
51
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark
|
52
|
+
Enabled: true
|
53
|
+
NamePrefix:
|
54
|
+
- is_
|
55
|
+
- has_
|
56
|
+
- have_
|
57
|
+
NamePrefixBlacklist:
|
58
|
+
- is_
|
59
|
+
Style/RaiseArgs:
|
60
|
+
Description: Checks the arguments passed to raise/fail.
|
61
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#exception-class-messages
|
62
|
+
Enabled: true
|
63
|
+
EnforcedStyle: exploded
|
64
|
+
SupportedStyles:
|
65
|
+
- compact
|
66
|
+
- exploded
|
67
|
+
Style/SignalException:
|
68
|
+
Description: Checks for proper usage of fail and raise.
|
69
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#fail-method
|
70
|
+
Enabled: false
|
71
|
+
EnforcedStyle: semantic
|
72
|
+
SupportedStyles:
|
73
|
+
- only_raise
|
74
|
+
- only_fail
|
75
|
+
- semantic
|
76
|
+
Style/SingleLineBlockParams:
|
77
|
+
Description: Enforces the names of some block params.
|
78
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#reduce-blocks
|
79
|
+
Enabled: false
|
80
|
+
Methods:
|
81
|
+
- reduce:
|
82
|
+
- a
|
83
|
+
- e
|
84
|
+
- inject:
|
85
|
+
- a
|
86
|
+
- e
|
87
|
+
Style/SingleLineMethods:
|
88
|
+
Description: Avoid single-line methods.
|
89
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-single-line-methods
|
90
|
+
Enabled: true
|
91
|
+
AllowIfMethodIsEmpty: true
|
92
|
+
Style/StringLiterals:
|
93
|
+
Description: Checks if uses of quotes match the configured preference.
|
94
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#consistent-string-literals
|
95
|
+
Enabled: true
|
96
|
+
EnforcedStyle: double_quotes
|
97
|
+
SupportedStyles:
|
98
|
+
- single_quotes
|
99
|
+
- double_quotes
|
100
|
+
Style/StringLiteralsInInterpolation:
|
101
|
+
Description: Checks if uses of quotes inside expressions in interpolated strings
|
102
|
+
match the configured preference.
|
103
|
+
Enabled: true
|
104
|
+
EnforcedStyle: double_quotes
|
105
|
+
SupportedStyles:
|
106
|
+
- single_quotes
|
107
|
+
- double_quotes
|
108
|
+
Style/TrailingCommaInArguments:
|
109
|
+
Description: 'Checks for trailing comma in argument lists.'
|
110
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
111
|
+
Enabled: true
|
112
|
+
EnforcedStyleForMultiline: no_comma
|
113
|
+
SupportedStylesForMultiline:
|
114
|
+
- comma
|
115
|
+
- consistent_comma
|
116
|
+
- no_comma
|
117
|
+
Style/TrailingCommaInLiteral:
|
118
|
+
Description: 'Checks for trailing comma in array and hash literals.'
|
119
|
+
StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas'
|
120
|
+
Enabled: true
|
121
|
+
EnforcedStyleForMultiline: no_comma
|
122
|
+
SupportedStylesForMultiline:
|
123
|
+
- comma
|
124
|
+
- consistent_comma
|
125
|
+
- no_comma
|
126
|
+
Metrics/AbcSize:
|
127
|
+
Description: A calculated magnitude based on number of assignments, branches, and
|
128
|
+
conditions.
|
129
|
+
Enabled: true
|
130
|
+
Max: 15
|
131
|
+
Metrics/ClassLength:
|
132
|
+
Description: Avoid classes longer than 100 lines of code.
|
133
|
+
Enabled: true
|
134
|
+
CountComments: false
|
135
|
+
Max: 150
|
136
|
+
Metrics/ModuleLength:
|
137
|
+
CountComments: false
|
138
|
+
Max: 100
|
139
|
+
Description: Avoid modules longer than 100 lines of code.
|
140
|
+
Enabled: false
|
141
|
+
Metrics/CyclomaticComplexity:
|
142
|
+
Description: A complexity metric that is strongly correlated to the number of test
|
143
|
+
cases needed to validate a method.
|
144
|
+
Enabled: true
|
145
|
+
Max: 8
|
146
|
+
Metrics/MethodLength:
|
147
|
+
Description: Avoid methods longer than 15 lines of code.
|
148
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#short-methods
|
149
|
+
Enabled: true
|
150
|
+
CountComments: false
|
151
|
+
Max: 15
|
152
|
+
Metrics/ParameterLists:
|
153
|
+
Description: Avoid parameter lists longer than three or four parameters.
|
154
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#too-many-params
|
155
|
+
Enabled: true
|
156
|
+
Max: 5
|
157
|
+
CountKeywordArgs: true
|
158
|
+
Metrics/PerceivedComplexity:
|
159
|
+
Description: A complexity metric geared towards measuring complexity for a human
|
160
|
+
reader.
|
161
|
+
Enabled: true
|
162
|
+
Max: 7
|
163
|
+
Lint/AssignmentInCondition:
|
164
|
+
Description: Don't use assignment in conditions.
|
165
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition
|
166
|
+
Enabled: true
|
167
|
+
AllowSafeAssignment: true
|
168
|
+
Layout/AlignParameters:
|
169
|
+
Description: Align the parameters of a method call if they span more than one line.
|
170
|
+
Enabled: true
|
171
|
+
EnforcedStyle: with_first_parameter
|
172
|
+
Style/InlineComment:
|
173
|
+
Description: Avoid inline comments.
|
174
|
+
Enabled: false
|
175
|
+
Style/AccessorMethodName:
|
176
|
+
Description: Check the naming of accessor methods for get_/set_.
|
177
|
+
Enabled: false
|
178
|
+
Style/Alias:
|
179
|
+
Description: Use alias_method instead of alias.
|
180
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#alias-method
|
181
|
+
Enabled: true
|
182
|
+
Style/Documentation:
|
183
|
+
Description: Document classes and non-namespace modules.
|
184
|
+
Enabled: false
|
185
|
+
Style/DoubleNegation:
|
186
|
+
Description: Checks for uses of double negation (!!).
|
187
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-bang-bang
|
188
|
+
Enabled: false
|
189
|
+
Style/EachWithObject:
|
190
|
+
Description: Prefer `each_with_object` over `inject` or `reduce`.
|
191
|
+
Enabled: false
|
192
|
+
Style/EmptyLiteral:
|
193
|
+
Description: Prefer literals to Array.new/Hash.new/String.new.
|
194
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#literal-array-hash
|
195
|
+
Enabled: true
|
196
|
+
Style/ModuleFunction:
|
197
|
+
Description: Checks for usage of `extend self` in modules.
|
198
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#module-function
|
199
|
+
Enabled: false
|
200
|
+
Style/OneLineConditional:
|
201
|
+
Description: Favor the ternary operator(?:) over if/then/else/end constructs.
|
202
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#ternary-operator
|
203
|
+
Enabled: false
|
204
|
+
Style/PerlBackrefs:
|
205
|
+
Description: Avoid Perl-style regex back references.
|
206
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers
|
207
|
+
Enabled: true
|
208
|
+
Style/Send:
|
209
|
+
Description: Prefer `Object#__send__` or `Object#public_send` to `send`, as `send`
|
210
|
+
may overlap with existing methods.
|
211
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#prefer-public-send
|
212
|
+
Enabled: false
|
213
|
+
Style/SpecialGlobalVars:
|
214
|
+
Description: Avoid Perl-style global variables.
|
215
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms
|
216
|
+
Enabled: true
|
217
|
+
Style/VariableInterpolation:
|
218
|
+
Description: Don't interpolate global, instance and class variables directly in
|
219
|
+
strings.
|
220
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#curlies-interpolate
|
221
|
+
Enabled: false
|
222
|
+
Style/WhenThen:
|
223
|
+
Description: Use when x then ... for one-line cases.
|
224
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#one-line-cases
|
225
|
+
Enabled: false
|
226
|
+
Layout/TrailingBlankLines:
|
227
|
+
Description: 'Checks trailing blank lines and final newline.'
|
228
|
+
StyleGuide: '#newline-eof'
|
229
|
+
Enabled: false
|
230
|
+
Lint/EachWithObjectArgument:
|
231
|
+
Description: Check for immutable argument given to each_with_object.
|
232
|
+
Enabled: true
|
233
|
+
Lint/HandleExceptions:
|
234
|
+
Description: Don't suppress exception.
|
235
|
+
StyleGuide: https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions
|
236
|
+
Enabled: true
|
237
|
+
Lint/LiteralInCondition:
|
238
|
+
Description: Checks of literals used in conditions.
|
239
|
+
Enabled: false
|
240
|
+
Lint/LiteralInInterpolation:
|
241
|
+
Description: Checks for literals used in interpolation.
|
242
|
+
Enabled: false
|
243
|
+
RedundantBlockCall:
|
244
|
+
Enabled: false
|
245
|
+
Style/EmptyMethod:
|
246
|
+
Enabled: false
|
247
|
+
Style/VariableNumber:
|
248
|
+
EnforcedStyle: snake_case
|
249
|
+
|
250
|
+
# checks whether the end keywords are aligned properly for `do` `end` blocks.
|
251
|
+
Lint/BlockAlignment:
|
252
|
+
# The value `start_of_block` means that the `end` should be aligned with line
|
253
|
+
# where the `do` keyword appears.
|
254
|
+
# The value `start_of_line` means it should be aligned with the whole
|
255
|
+
# expression's starting line.
|
256
|
+
# The value `either` means both are allowed.
|
257
|
+
EnforcedStyleAlignWith: either
|
258
|
+
SupportedStylesAlignWith:
|
259
|
+
- either
|
260
|
+
- start_of_block
|
261
|
+
- start_of_line
|
262
|
+
|
263
|
+
Layout/MultilineMethodCallIndentation:
|
264
|
+
EnforcedStyle: indented_relative_to_receiver
|
265
|
+
IndentationWidth: 4
|
266
|
+
Layout/MultilineOperationIndentation:
|
267
|
+
EnforcedStyle: indented
|
268
|
+
IndentationWidth: 4
|
269
|
+
Metrics/LineLength:
|
270
|
+
Max: 150
|
271
|
+
# TODO: Renable after exclusions cleaned up.
|
272
|
+
#Metrics/BlockLength:
|
273
|
+
# Exclude:
|
274
|
+
# - spec/**/*
|
275
|
+
# - lib/tasks/**/*
|
276
|
+
Layout/CaseIndentation:
|
277
|
+
EnforcedStyle: case
|
278
|
+
IndentOneStep: true
|
279
|
+
Layout/IndentArray:
|
280
|
+
IndentationWidth: 4
|
281
|
+
Layout/IndentHash:
|
282
|
+
IndentationWidth: 4
|
283
|
+
Layout/FirstParameterIndentation:
|
284
|
+
IndentationWidth: 4
|
285
|
+
Layout/MultilineMethodCallIndentation:
|
286
|
+
Enabled: false
|
287
|
+
Layout/MultilineOperationIndentation:
|
288
|
+
Enabled: false
|
289
|
+
Style/FrozenStringLiteralComment:
|
290
|
+
Enabled: true
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
hekate (0.1.0.
|
4
|
+
hekate (0.1.0.pre20)
|
5
5
|
aws-sdk-core (~> 3.6.0, >= 3.6.0)
|
6
6
|
aws-sdk-kms (~> 1.2.0, >= 1.2.0)
|
7
7
|
aws-sdk-ssm (~> 1.3.0, >= 1.3.0)
|
@@ -51,8 +51,8 @@ GEM
|
|
51
51
|
addressable (2.5.1)
|
52
52
|
public_suffix (~> 2.0, >= 2.0.2)
|
53
53
|
arel (6.0.4)
|
54
|
-
aws-partitions (1.
|
55
|
-
aws-sdk-core (3.6.
|
54
|
+
aws-partitions (1.53.0)
|
55
|
+
aws-sdk-core (3.6.1)
|
56
56
|
aws-partitions (~> 1.0)
|
57
57
|
aws-sigv4 (~> 1.0)
|
58
58
|
jmespath (~> 1.0)
|
@@ -73,7 +73,7 @@ GEM
|
|
73
73
|
concurrent-ruby (1.0.5)
|
74
74
|
crack (0.4.3)
|
75
75
|
safe_yaml (~> 1.0.0)
|
76
|
-
crass (1.0.
|
76
|
+
crass (1.0.3)
|
77
77
|
diff-lcs (1.3)
|
78
78
|
docile (1.1.5)
|
79
79
|
dotenv (2.2.1)
|
@@ -82,7 +82,7 @@ GEM
|
|
82
82
|
globalid (0.4.1)
|
83
83
|
activesupport (>= 4.2.0)
|
84
84
|
hashdiff (0.3.5)
|
85
|
-
highline (1.7.
|
85
|
+
highline (1.7.10)
|
86
86
|
i18n (0.9.1)
|
87
87
|
concurrent-ruby (~> 1.0)
|
88
88
|
jmespath (1.3.1)
|
@@ -92,9 +92,9 @@ GEM
|
|
92
92
|
nokogiri (>= 1.5.9)
|
93
93
|
mail (2.7.0)
|
94
94
|
mini_mime (>= 0.1.1)
|
95
|
-
mini_mime (0.
|
95
|
+
mini_mime (1.0.0)
|
96
96
|
mini_portile2 (2.3.0)
|
97
|
-
minitest (5.
|
97
|
+
minitest (5.11.1)
|
98
98
|
nokogiri (1.8.1)
|
99
99
|
mini_portile2 (~> 2.3.0)
|
100
100
|
public_suffix (2.0.5)
|
@@ -114,8 +114,8 @@ GEM
|
|
114
114
|
sprockets-rails
|
115
115
|
rails-deprecated_sanitizer (1.0.3)
|
116
116
|
activesupport (>= 4.2.0.alpha)
|
117
|
-
rails-dom-testing (1.0.
|
118
|
-
activesupport (>= 4.2.0
|
117
|
+
rails-dom-testing (1.0.9)
|
118
|
+
activesupport (>= 4.2.0, < 5.0)
|
119
119
|
nokogiri (~> 1.6)
|
120
120
|
rails-deprecated_sanitizer (>= 1.0.1)
|
121
121
|
rails-html-sanitizer (1.0.3)
|
@@ -154,7 +154,7 @@ GEM
|
|
154
154
|
actionpack (>= 4.0)
|
155
155
|
activesupport (>= 4.0)
|
156
156
|
sprockets (>= 3.0.0)
|
157
|
-
thor (0.
|
157
|
+
thor (0.20.0)
|
158
158
|
thread_safe (0.3.6)
|
159
159
|
tzinfo (1.2.4)
|
160
160
|
thread_safe (~> 0.1)
|
data/Rakefile
CHANGED
data/hekate.gemspec
CHANGED
@@ -1,39 +1,40 @@
|
|
1
1
|
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
|
-
lib = File.expand_path(
|
4
|
+
lib = File.expand_path("../lib", __FILE__)
|
4
5
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
|
-
require
|
6
|
+
require "hekate/version"
|
6
7
|
|
7
8
|
Gem::Specification.new do |spec|
|
8
|
-
spec.name =
|
9
|
+
spec.name = "hekate"
|
9
10
|
spec.version = Hekate::VERSION
|
10
|
-
spec.authors = [
|
11
|
-
spec.email = [
|
11
|
+
spec.authors = ["jasonrisch"]
|
12
|
+
spec.email = ["krimsonkla@yahoo.com"]
|
12
13
|
|
13
|
-
spec.summary =
|
14
|
-
spec.homepage =
|
15
|
-
spec.license =
|
14
|
+
spec.summary = "A simple rails interface for hiding secrets in AWS EC2 Parameters"
|
15
|
+
spec.homepage = "https://github.com/krimsonkla/hekate"
|
16
|
+
spec.license = "MIT"
|
16
17
|
|
17
18
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
18
19
|
f.match(%r{^(test|spec|features)/})
|
19
20
|
end
|
20
|
-
spec.bindir =
|
21
|
-
spec.executables = [
|
22
|
-
spec.require_paths = [
|
21
|
+
spec.bindir = "bin"
|
22
|
+
spec.executables = ["hekate"]
|
23
|
+
spec.require_paths = ["lib"]
|
23
24
|
|
24
|
-
spec.add_runtime_dependency
|
25
|
-
spec.add_runtime_dependency
|
26
|
-
spec.add_runtime_dependency
|
27
|
-
spec.add_runtime_dependency
|
28
|
-
spec.add_runtime_dependency
|
29
|
-
spec.add_runtime_dependency
|
30
|
-
spec.add_runtime_dependency
|
31
|
-
spec.add_runtime_dependency
|
25
|
+
spec.add_runtime_dependency "aws-sdk-core", "~>3.6.0", ">= 3.6.0"
|
26
|
+
spec.add_runtime_dependency "aws-sdk-kms", "~>1.2.0", ">= 1.2.0"
|
27
|
+
spec.add_runtime_dependency "aws-sdk-ssm", "~>1.3.0", ">= 1.3.0"
|
28
|
+
spec.add_runtime_dependency "commander", "~> 4.4", ">= 4.4.0"
|
29
|
+
spec.add_runtime_dependency "ec2-metadata", "~> 0.2", ">= 0.2.0"
|
30
|
+
spec.add_runtime_dependency "railties", "~> 4.2", ">= 4.2.0"
|
31
|
+
spec.add_runtime_dependency "rails", "~> 4"
|
32
|
+
spec.add_runtime_dependency "dotenv", "~> 2.2", ">= 2.2.1"
|
32
33
|
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
35
|
-
spec.add_development_dependency
|
36
|
-
spec.add_development_dependency
|
37
|
-
spec.add_development_dependency
|
38
|
-
spec.add_development_dependency
|
34
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
35
|
+
spec.add_development_dependency "codecov", "~> 0.1", "~> 0.1.0"
|
36
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
38
|
+
spec.add_development_dependency "rspec_junit_formatter", "~> 0.3.0"
|
39
|
+
spec.add_development_dependency "webmock", "~> 3.0", "~> 3.0.0"
|
39
40
|
end
|
data/lib/hekate.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rails"
|
4
|
+
require "hekate/aws"
|
5
|
+
require "hekate/version"
|
6
|
+
require "hekate/railtie"
|
7
|
+
require "hekate/engine"
|
data/lib/hekate/aws.rb
CHANGED
@@ -1,42 +1,47 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "aws-sdk-ssm"
|
4
|
+
require "aws-sdk-kms"
|
3
5
|
|
4
6
|
module Hekate
|
5
7
|
class Aws
|
6
|
-
def initialize(region
|
8
|
+
def initialize(region)
|
7
9
|
@region = region
|
8
|
-
@environment = environment
|
9
10
|
end
|
10
11
|
|
11
12
|
def get_parameter(name)
|
12
13
|
parameters = ssm.get_parameters(
|
13
|
-
|
14
|
-
|
14
|
+
names: [name],
|
15
|
+
with_decryption: true
|
15
16
|
).parameters
|
16
17
|
|
17
18
|
if parameters.to_a.empty?
|
18
19
|
fail "Could not find parameter #{name}"
|
19
20
|
else
|
20
|
-
parameters.first[
|
21
|
+
parameters.first["value"]
|
21
22
|
end
|
22
23
|
end
|
23
24
|
|
24
|
-
def list_parameters(
|
25
|
-
get_app_env_parameters(
|
25
|
+
def list_parameters(environments = [])
|
26
|
+
get_app_env_parameters(environments)
|
26
27
|
end
|
27
28
|
|
28
29
|
def get_parameters(names)
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
result = []
|
31
|
+
names.each_slice(10) do |slice|
|
32
|
+
result.concat(ssm.get_parameters(
|
33
|
+
names: slice,
|
34
|
+
with_decryption: true
|
35
|
+
).parameters)
|
36
|
+
end
|
37
|
+
result.flatten
|
33
38
|
end
|
34
39
|
|
35
|
-
def put_parameter(name, value)
|
40
|
+
def put_parameter(name, value, environment)
|
36
41
|
ssm.put_parameter(name: name,
|
37
42
|
value: value,
|
38
|
-
type:
|
39
|
-
key_id: kms_key,
|
43
|
+
type: "SecureString",
|
44
|
+
key_id: kms_key(environment),
|
40
45
|
overwrite: true)
|
41
46
|
end
|
42
47
|
|
@@ -54,22 +59,26 @@ module Hekate
|
|
54
59
|
@ssm ||= ::Aws::SSM::Client.new(region: @region)
|
55
60
|
end
|
56
61
|
|
57
|
-
def kms_key
|
58
|
-
return @
|
62
|
+
def kms_key(environment)
|
63
|
+
return @keys[environment].key_id if @keys[environment]
|
59
64
|
|
60
|
-
alias_name = "alias/#{Hekate::Engine.application}_#{
|
65
|
+
alias_name = "alias/#{Hekate::Engine.application}_#{environment}"
|
61
66
|
|
62
67
|
if kms_alias_exists? alias_name
|
63
68
|
key = kms.describe_key(key_id: alias_name).key_metadata
|
64
69
|
else
|
65
70
|
key = kms.create_key.key_metadata
|
66
71
|
kms.create_alias(
|
67
|
-
|
68
|
-
|
72
|
+
alias_name: alias_name,
|
73
|
+
target_key_id: key.key_id
|
69
74
|
)
|
70
75
|
end
|
76
|
+
if key
|
77
|
+
@keys[environment] = key
|
78
|
+
return key.key_id
|
79
|
+
end
|
71
80
|
|
72
|
-
key
|
81
|
+
fail "Failed to create or retrieve kms key"
|
73
82
|
end
|
74
83
|
|
75
84
|
def kms_alias_exists?(kms_alias)
|
@@ -77,22 +86,22 @@ module Hekate
|
|
77
86
|
aliases.include? kms_alias
|
78
87
|
end
|
79
88
|
|
80
|
-
def get_app_env_parameters(
|
89
|
+
def get_app_env_parameters(environments = [], parameters = [], next_token = nil)
|
81
90
|
query = {
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
91
|
+
filters: [
|
92
|
+
{
|
93
|
+
key: "Name",
|
94
|
+
values: environments.map { |e| "#{Hekate::Engine.application}.#{e}" }
|
95
|
+
}
|
96
|
+
],
|
97
|
+
max_results: 50
|
89
98
|
}
|
90
99
|
query[:next_token] = next_token if next_token
|
91
100
|
response = ssm.describe_parameters(query)
|
92
101
|
|
93
102
|
parameters += response.parameters
|
94
103
|
|
95
|
-
parameters = get_app_env_parameters(
|
104
|
+
parameters = get_app_env_parameters(environments, parameters, response.next_token) if response.next_token
|
96
105
|
|
97
106
|
parameters
|
98
107
|
end
|
data/lib/hekate/engine.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
require
|
4
|
-
require
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "commander/user_interaction"
|
4
|
+
require "dotenv"
|
5
|
+
require "ec2_metadata"
|
6
|
+
require "open-uri"
|
5
7
|
|
6
8
|
module Hekate
|
7
9
|
class Engine
|
@@ -10,9 +12,9 @@ module Hekate
|
|
10
12
|
|
11
13
|
def get_region
|
12
14
|
if ec2?
|
13
|
-
Ec2Metadata[:placement][
|
15
|
+
Ec2Metadata[:placement]["availability-zone"][0...-1]
|
14
16
|
else
|
15
|
-
ENV[
|
17
|
+
ENV["AWS_REGION"] || "us-east-1"
|
16
18
|
end
|
17
19
|
end
|
18
20
|
|
@@ -24,38 +26,37 @@ module Hekate
|
|
24
26
|
end
|
25
27
|
|
26
28
|
def online?
|
27
|
-
require
|
29
|
+
require "socket"
|
28
30
|
|
29
|
-
return false if ENV[
|
31
|
+
return false if ENV["HAKATE_DISABLE"]
|
30
32
|
|
31
|
-
timeout = ENV.fetch(
|
33
|
+
timeout = ENV.fetch("HEKATE_SSM_TIMEOUT") { 0.5 }
|
32
34
|
can_connect?(
|
33
|
-
|
35
|
+
"ssm.us-east-1.amazonaws.com",
|
34
36
|
443,
|
35
37
|
timeout
|
36
38
|
)
|
37
39
|
end
|
38
40
|
|
39
41
|
def root
|
40
|
-
@root ||= Rails::Engine.find_root_with_flag(
|
42
|
+
@root ||= Rails::Engine.find_root_with_flag("config.ru", File.dirname($PROGRAM_NAME))
|
41
43
|
end
|
42
44
|
|
43
45
|
def dotenv_files
|
44
46
|
files = [
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
47
|
+
root.join(".env.#{Rails.env}.local"),
|
48
|
+
(root.join(".env.local") unless Rails.env.test?),
|
49
|
+
root.join(".env.#{Rails.env}"),
|
50
|
+
root.join(".env")
|
49
51
|
].compact.select { |file| File.exist? file }
|
50
52
|
|
51
|
-
raise
|
53
|
+
raise "Could not find .env files while falling back to dotenv" if files.empty?
|
52
54
|
files
|
53
55
|
end
|
54
56
|
|
55
57
|
private
|
56
58
|
|
57
59
|
def can_connect?(host, port, timeout = 2)
|
58
|
-
|
59
60
|
# Convert the passed host into structures the non-blocking calls
|
60
61
|
# can deal with
|
61
62
|
addr = Socket.getaddrinfo(host, nil)
|
@@ -70,7 +71,6 @@ module Hekate
|
|
70
71
|
# immediatelyit will raise an IO::WaitWritable (Errno::EINPROGRESS)
|
71
72
|
# indicating the connection is in progress.
|
72
73
|
socket.connect_nonblock(sockaddr)
|
73
|
-
|
74
74
|
rescue IO::WaitWritable
|
75
75
|
# IO.select will block until the socket is writable or the timeout
|
76
76
|
# is exceeded - whichever comes first.
|
@@ -109,30 +109,29 @@ module Hekate
|
|
109
109
|
end
|
110
110
|
|
111
111
|
def awsclient
|
112
|
-
@awsclient ||= Hekate::Aws.new(@region
|
112
|
+
@awsclient ||= Hekate::Aws.new(@region)
|
113
113
|
end
|
114
114
|
|
115
115
|
def load_environment
|
116
116
|
if Hekate::Engine.online?
|
117
|
-
|
118
|
-
|
117
|
+
application = "#{Hekate::Engine.application}."
|
118
|
+
environments = ["root", @environment].compact
|
119
119
|
|
120
|
-
|
121
|
-
|
120
|
+
parameters = awsclient.list_parameters(environments)
|
121
|
+
parameters = parameters.map(&:name)
|
122
122
|
|
123
|
-
|
124
|
-
result = awsclient.get_parameters(slice)
|
123
|
+
result = awsclient.get_parameters(parameters)
|
125
124
|
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
125
|
+
environments.each do |env|
|
126
|
+
result.select { |r| r.name[/#{Hekate::Engine.application}\.#{env}\./] }.each do |parameter|
|
127
|
+
parameter_name = parameter.name.gsub(application, "").gsub("#{env}.", "")
|
128
|
+
ENV[parameter_name] = parameter.value
|
130
129
|
end
|
131
130
|
end
|
132
131
|
elsif Rails.env.development? || Rails.env.test?
|
133
132
|
Dotenv.load(*Hekate::Engine.dotenv_files)
|
134
133
|
else
|
135
|
-
raise
|
134
|
+
raise "Could not connect to parameter store"
|
136
135
|
end
|
137
136
|
end
|
138
137
|
|
@@ -144,9 +143,9 @@ module Hekate
|
|
144
143
|
progress = Commander::UI::ProgressBar.new(lines.length)
|
145
144
|
lines.each do |line|
|
146
145
|
progress.increment
|
147
|
-
next if line.start_with?
|
146
|
+
next if line.start_with? "#"
|
148
147
|
|
149
|
-
key, value = line.split(
|
148
|
+
key, value = line.split("=")
|
150
149
|
|
151
150
|
next if value.nil?
|
152
151
|
value = value.delete('"').delete("'").delete("\n")
|
@@ -158,7 +157,7 @@ module Hekate
|
|
158
157
|
|
159
158
|
def put(key, value)
|
160
159
|
parameter_key = "#{Hekate::Engine.application}.#{@environment}.#{key}"
|
161
|
-
awsclient.put_parameter(parameter_key, value)
|
160
|
+
awsclient.put_parameter(parameter_key, value, @environment)
|
162
161
|
end
|
163
162
|
|
164
163
|
def get(key)
|
@@ -167,7 +166,7 @@ module Hekate
|
|
167
166
|
end
|
168
167
|
|
169
168
|
def delete_all
|
170
|
-
parameters = awsclient.list_parameters(@environment).map(&:name)
|
169
|
+
parameters = awsclient.list_parameters([@environment]).map(&:name)
|
171
170
|
progress = Commander::UI::ProgressBar.new(parameters.length)
|
172
171
|
parameters.each do |parameter|
|
173
172
|
progress.increment
|
@@ -183,16 +182,16 @@ module Hekate
|
|
183
182
|
def export(env_file)
|
184
183
|
parameter_key = "#{Hekate::Engine.application}.#{@environment}."
|
185
184
|
|
186
|
-
parameters = awsclient.list_parameters(@environment).map(&:name)
|
185
|
+
parameters = awsclient.list_parameters([@environment]).map(&:name)
|
187
186
|
|
188
187
|
progress = Commander::UI::ProgressBar.new(parameters.length)
|
189
|
-
open(env_file,
|
188
|
+
open(env_file, "w") do |file|
|
190
189
|
parameters.each_slice(10) do |slice|
|
191
190
|
result = awsclient.get_parameters(slice)
|
192
191
|
|
193
192
|
result.each do |parameter|
|
194
193
|
progress.increment
|
195
|
-
parameter_name = parameter.name.gsub(parameter_key,
|
194
|
+
parameter_name = parameter.name.gsub(parameter_key, "")
|
196
195
|
file.puts "#{parameter_name}=#{parameter.value}"
|
197
196
|
end
|
198
197
|
end
|
data/lib/hekate/railtie.rb
CHANGED
@@ -1,7 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Hekate
|
2
4
|
class Railtie < Rails::Railtie
|
3
5
|
config.before_configuration do
|
4
|
-
Hekate::Engine.new(Engine.get_region, Rails.env.to_s, ENV[
|
6
|
+
Hekate::Engine.new(Engine.get_region, Rails.env.to_s, ENV["HEKATE_APPLICATION"]).load_environment
|
5
7
|
end
|
6
8
|
end
|
7
9
|
end
|
data/lib/hekate/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hekate
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.0.
|
4
|
+
version: 0.1.0.pre21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jasonrisch
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-core
|
@@ -272,6 +272,7 @@ files:
|
|
272
272
|
- ".gitignore"
|
273
273
|
- ".idea/vcs.xml"
|
274
274
|
- ".rspec"
|
275
|
+
- ".rubocop.yml"
|
275
276
|
- CODE_OF_CONDUCT.md
|
276
277
|
- Gemfile
|
277
278
|
- Gemfile.lock
|