secret_env 0.4.0 → 0.5.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
  SHA1:
3
- metadata.gz: b1e1505edb2746b3c514bcfc4d63a55932bac752
4
- data.tar.gz: 8caaa36d3a22b33d9d7765298239da62df506724
3
+ metadata.gz: da53d177eb5d09cf20c548bdb1e6133f3b3b9bd5
4
+ data.tar.gz: 381545548cdfd4ef862c7297c094217de18979d1
5
5
  SHA512:
6
- metadata.gz: f7875732f6642c3da35395258b837ff955368002094eefce272ce3acd06b945bb47689ec661604e4962aa4551333dd8f68406e17eb833f551ee9ebab81d43fad
7
- data.tar.gz: 7b99d06bea62e93ba190d134c0fedfd86ffebdf9c0930dc0b683e1090c4b2f7d17e1c4e27f8373ec979272ccef38d60198d5cd36cf562e81f68685da813fe988
6
+ metadata.gz: 19ee8fa8dda27709ad24efb0594f3ba0ad7b86a061adeb28007cee1beed5a87e01d94090a15e9c7678f5723d6912b1b007b0f5d3dec5fa05b123f51fb3e09d2c
7
+ data.tar.gz: 5aa50c61ab6766be2984edc91a7496574032bc38348e8e9d9021af539ac41c507b7629041ece8055c74d376169f36fa7218284ac4207862be743c4881120bd24
data/.travis.yml CHANGED
@@ -1,5 +1,6 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.2.3
5
- before_install: gem install bundler -v 1.12.5
4
+ - 2.4.0
5
+ - 2.3.3
6
+ - 2.2.6
data/README.md CHANGED
@@ -1,8 +1,32 @@
1
- # SecretEnv
2
-
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/secret_env`. To experiment with that code, run `bin/console` for an interactive prompt.
1
+ # SecretEnv [![Build Status](https://travis-ci.org/adorechic/secret_env.svg?branch=master)](https://travis-ci.org/adorechic/secret_env)
2
+ SecretEnv is a environment variables manager for rails. SecretEnv can resolve secret variables from storages.
3
+
4
+ ```yaml
5
+ development:
6
+ env:
7
+ AUTH_SECRET: secret
8
+ DATABASE_URL: 'mysql2://local_user@localhost:3306'
9
+
10
+ staging:
11
+ storage:
12
+ type: credstash
13
+ namespace: awesome_app.staging.
14
+ env:
15
+ AUTH_SECRET: '#{auth_secret}'
16
+ DATABASE_URL: 'mysql2://db_user:#{db_password}@db-staging:3306/main?read_timeout=10&encoding=utf8'
17
+
18
+ production:
19
+ storage:
20
+ type: credstash
21
+ namespace: awesome_app.production.
22
+ env:
23
+ AUTH_SECRET: '#{auth_secret}'
24
+ DATABASE_URL: 'mysql2://db_user:#{db_password}@db-production:3306/main?read_timeout=10&encoding=utf8'
25
+ ```
4
26
 
5
- TODO: Delete this and the text above, and describe your gem
27
+ ## Features
28
+ - Put secrets out of a config file in repository. You can choose backend storages.
29
+ - Configure multi environments via one file.
6
30
 
7
31
  ## Installation
8
32
 
@@ -16,26 +40,36 @@ And then execute:
16
40
 
17
41
  $ bundle
18
42
 
19
- Or install it yourself as:
43
+ Put config/secret_env.yml in your application.
20
44
 
21
- $ gem install secret_env
45
+ ## Storages
46
+ SecretEnv resolves keys in given namespace. If you set `some.namespace`, SecretEnv finds `some.namespace.super_secret` key from storages.
22
47
 
23
- ## Usage
48
+ ### type: plain
49
+ This is default storage type. This type does not retrieve secrets, just extract it as full namespaced key.
24
50
 
25
- TODO: Write usage instructions here
51
+ ### type: credstash
52
+ This type finds secrets via credstash. You have to bundle 'rcredstash'.
26
53
 
27
- ## Development
54
+ ```ruby
55
+ gem 'secret_env'
56
+ gem 'rcredstash'
57
+ ```
28
58
 
29
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
59
+ ### type: file
60
+ This type finds secrets from local file. Put your secrets in config/secret_env.local, and add it to your gitignores.
30
61
 
31
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
62
+ ```
63
+ # config/secret_env.local
64
+ foo=1
65
+ bar=2
66
+ ```
32
67
 
33
68
  ## Contributing
34
69
 
35
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/secret_env.
70
+ Bug reports and pull requests are welcome on GitHub at https://github.com/adorechic/secret_env.
36
71
 
37
72
 
38
73
  ## License
39
74
 
40
75
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
-
@@ -17,6 +17,8 @@ module SecretEnv
17
17
  Storage::Plain
18
18
  when 'credstash'
19
19
  Storage::CredStash
20
+ when 'file'
21
+ Storage::File
20
22
  else
21
23
  raise "Unknown storage type: #{type}"
22
24
  end
@@ -52,5 +54,18 @@ module SecretEnv
52
54
  ::CredStash.get(full_key(secret_key))
53
55
  end
54
56
  end
57
+
58
+ class File < Base
59
+ LOCAL_FILE_PATH = 'config/secret_env.local'
60
+
61
+ def initialize(namespace: '')
62
+ super
63
+ @secrets = Hash[*::File.readlines(LOCAL_FILE_PATH).map(&:strip).map {|line| line.split("=", 2) }.flatten]
64
+ end
65
+
66
+ def retrieve(secret_key)
67
+ @secrets[full_key(secret_key)]
68
+ end
69
+ end
55
70
  end
56
71
  end
@@ -1,3 +1,3 @@
1
1
  module SecretEnv
2
- VERSION = "0.4.0"
2
+ VERSION = "0.5.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: secret_env
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - adorechic
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-11-30 00:00:00.000000000 Z
11
+ date: 2017-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
109
109
  version: '0'
110
110
  requirements: []
111
111
  rubyforge_project:
112
- rubygems_version: 2.5.1
112
+ rubygems_version: 2.6.10
113
113
  signing_key:
114
114
  specification_version: 4
115
115
  summary: SecretEnv retrieves secrets and export to ENV