samson_secret_puller 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 698d0caec5f77fed0dc0977db5c242b48baaff7e
4
+ data.tar.gz: def54fe2a0715e85d830358556b63395146a9cbd
5
+ SHA512:
6
+ metadata.gz: e03de7756eb3efd45041e21ed0091fef7fe9af4cfd3e4bd4f26a12b3117e02e88eaece9db95cdc03db70a4a5ee65f89a516bbe8fd106c27949fc9f4eb5988a8c
7
+ data.tar.gz: 57ec1c40e5bdac6ce7144e1d4e2a70685501d38b0c156938c7533716bc5706dec119ac10660cd6898eb1c223059f6dd302796b723a496bfebe33bd0fe9c31eda
data/MIT-LICENSE.txt ADDED
@@ -0,0 +1,18 @@
1
+ Permission is hereby granted, free of charge, to any person obtaining
2
+ a copy of this software and associated documentation files (the
3
+ "Software"), to deal in the Software without restriction, including
4
+ without limitation the rights to use, copy, modify, merge, publish,
5
+ distribute, sublicense, and/or sell copies of the Software, and to
6
+ permit persons to whom the Software is furnished to do so, subject to
7
+ the following conditions:
8
+
9
+ The above copyright notice and this permission notice shall be
10
+ included in all copies or substantial portions of the Software.
11
+
12
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,58 @@
1
+ module SamsonSecretPuller
2
+ FOLDER = '/secrets'.freeze
3
+ TIMEOUT = 60
4
+
5
+ class TimeoutError < StandardError
6
+ end
7
+
8
+ class << self
9
+ def [](key)
10
+ secrets[key]
11
+ end
12
+
13
+ def fetch(*args, &block)
14
+ secrets.fetch(*args, &block)
15
+ end
16
+
17
+ def keys
18
+ secrets.keys
19
+ end
20
+
21
+ private
22
+
23
+ def secrets
24
+ @secrets ||= begin
25
+ secrets = ENV.to_h
26
+
27
+ if File.exist?(FOLDER)
28
+ wait_for_secrets_to_appear
29
+ merge_secrets(secrets)
30
+ end
31
+
32
+ secrets
33
+ end
34
+ end
35
+
36
+ def merge_secrets(secrets)
37
+ Dir.glob("#{FOLDER}/*").each do |file|
38
+ name = File.basename(file)
39
+ next if name.start_with?(".") # ignore .done and maybe others
40
+ secrets[name] = File.read(file).strip
41
+ end
42
+ end
43
+
44
+ def wait_for_secrets_to_appear
45
+ start = Time.now
46
+ done_file = "#{FOLDER}/.done"
47
+ # secrets should appear in that folder any second now
48
+ until File.exist?(done_file)
49
+ if Time.now > start + TIMEOUT
50
+ raise TimeoutError, "Waited #{TIMEOUT} seconds for #{done_file} to appear."
51
+ else
52
+ warn 'waiting for secrets to appear'
53
+ sleep 0.1
54
+ end
55
+ end
56
+ end
57
+ end
58
+ end
metadata ADDED
@@ -0,0 +1,45 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: samson_secret_puller
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Grosser
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-06-16 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description:
14
+ email: michael@grosser.it
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - MIT-LICENSE.txt
20
+ - lib/samson_secret_puller.rb
21
+ homepage: https://github.com/zendesk/samson_secret_puller
22
+ licenses:
23
+ - MIT
24
+ metadata: {}
25
+ post_install_message:
26
+ rdoc_options: []
27
+ require_paths:
28
+ - lib
29
+ required_ruby_version: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.9.3
34
+ required_rubygems_version: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ">="
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ requirements: []
40
+ rubyforge_project:
41
+ rubygems_version: 2.4.5.1
42
+ signing_key:
43
+ specification_version: 4
44
+ summary: Gem to read secrets generated by samson secret puller
45
+ test_files: []