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 +4 -4
- data/.travis.yml +3 -2
- data/README.md +47 -13
- data/lib/secret_env/storage.rb +15 -0
- data/lib/secret_env/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: da53d177eb5d09cf20c548bdb1e6133f3b3b9bd5
|
4
|
+
data.tar.gz: 381545548cdfd4ef862c7297c094217de18979d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 19ee8fa8dda27709ad24efb0594f3ba0ad7b86a061adeb28007cee1beed5a87e01d94090a15e9c7678f5723d6912b1b007b0f5d3dec5fa05b123f51fb3e09d2c
|
7
|
+
data.tar.gz: 5aa50c61ab6766be2984edc91a7496574032bc38348e8e9d9021af539ac41c507b7629041ece8055c74d376169f36fa7218284ac4207862be743c4881120bd24
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,8 +1,32 @@
|
|
1
|
-
# SecretEnv
|
2
|
-
|
3
|
-
|
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
|
-
|
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
|
-
|
43
|
+
Put config/secret_env.yml in your application.
|
20
44
|
|
21
|
-
|
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
|
-
|
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
|
-
|
51
|
+
### type: credstash
|
52
|
+
This type finds secrets via credstash. You have to bundle 'rcredstash'.
|
26
53
|
|
27
|
-
|
54
|
+
```ruby
|
55
|
+
gem 'secret_env'
|
56
|
+
gem 'rcredstash'
|
57
|
+
```
|
28
58
|
|
29
|
-
|
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
|
-
|
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/
|
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
|
-
|
data/lib/secret_env/storage.rb
CHANGED
@@ -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
|
data/lib/secret_env/version.rb
CHANGED
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
|
+
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:
|
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.
|
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
|