secrets_manager 0.1.0.rc1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 591fa8a47b755504c95eaa952c9b5fbe1242c1f22d32258846b57b2bd02a922e
4
- data.tar.gz: 8412a6e7b76eb42744ad8f5506f003cbc71081de6f653190cb12f8793527bb5f
3
+ metadata.gz: 96b49a6b9e2c3aebb09e2dc0a14dee6e78212f2461a554a5b0a6cc2bc460f6de
4
+ data.tar.gz: ae38f74722ff1d41e6c550f05d18f3236c87045b7b049bb0df88fec39d27ec0b
5
5
  SHA512:
6
- metadata.gz: e50276d674daca2c4c399f7a1437fcdf41b6dfc1dee7cd0047957b8fc5d7323188bad374fa6e7dd0338b50f9bff3c7ea522770be9acdd4cf0809c4cb011f5977
7
- data.tar.gz: bdfb15987e387471426c3abbcd05d843afbdce137f0e52135876a6c2f6ebfdcce58a1e9dc2f3416092d408c14ebc487c00549e06ac70ea601b30125564a9a9fd
6
+ metadata.gz: '09132b27bf6db0a9822b7ed44de7614c0bb0927ce080e5713ddf0e2a39f7868b7c7ca983b026608c54deffe81dd15f2ed96f4e708d5e06c704e5124bec0a5375'
7
+ data.tar.gz: 685cc0d9335183c83cc28fcdc586f4acf0db295661166ecbfc2892ed257c7b5e7139b6eb75972a04d10d14213828fdae85a9ac5923b15f172a55b42f90fb6bf7
@@ -2,12 +2,12 @@ require 'aws-sdk-secretsmanager'
2
2
 
3
3
  module SecretsManager
4
4
  class Client
5
- def initialize
6
- @client = Aws::SecretsManager::Client.new
5
+ def client
6
+ @client ||= Aws::SecretsManager::Client.new
7
7
  end
8
8
 
9
9
  def get_secret_string(secret_id)
10
- @client.get_secret_value(secret_id: secret_id).secret_string
10
+ client.get_secret_value(secret_id: secret_id).secret_string
11
11
  rescue Aws::SecretsManager::Errors::ServiceError
12
12
  aws_error(secret_id)
13
13
  end
@@ -0,0 +1,26 @@
1
+ require 'secrets_manager/config'
2
+ require 'secrets_manager/client'
3
+
4
+ module SecretsManager
5
+ class Railtie < ::Rails::Railtie
6
+ config.before_configuration do
7
+ unless File.file?(Rails.root.join('config', 'application.yml'))
8
+ puts 'Initializing secrets via Secrets Manager gem.'
9
+
10
+ config_path = Rails.root.join('secrets.json')
11
+ secrets_config = SecretsManager::Config.new(config_path, Rails.env).init
12
+ puts 'Secrets.json file is missing.' if secrets_config.nil?
13
+
14
+ aws_client = SecretsManager::Client.new
15
+
16
+ secrets_config.secrets.each do |secret|
17
+ next if File.file?(Rails.root.join(secret.path))
18
+
19
+ aws_client.get_secret_hash(secret.id).each do |key, value|
20
+ ENV[key.to_s] = value
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -1,3 +1,3 @@
1
1
  module SecretsManager
2
- VERSION = '0.1.0.rc1'.freeze
2
+ VERSION = '0.2.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: secrets_manager
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.rc1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - hmatic
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-12 00:00:00.000000000 Z
11
+ date: 2019-01-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-secretsmanager
@@ -88,6 +88,7 @@ files:
88
88
  - lib/secrets_manager/client.rb
89
89
  - lib/secrets_manager/config.rb
90
90
  - lib/secrets_manager/helpers.rb
91
+ - lib/secrets_manager/railtie.rb
91
92
  - lib/secrets_manager/version.rb
92
93
  - lib/tasks/productive_secrets_tasks.rake
93
94
  homepage: http://hrvojematic.com
@@ -105,9 +106,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
105
106
  version: '0'
106
107
  required_rubygems_version: !ruby/object:Gem::Requirement
107
108
  requirements:
108
- - - ">"
109
+ - - ">="
109
110
  - !ruby/object:Gem::Version
110
- version: 1.3.1
111
+ version: '0'
111
112
  requirements: []
112
113
  rubyforge_project:
113
114
  rubygems_version: 2.7.8