sekreto 0.3.0 → 0.4.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: 377252aece33da9b2a4bcb882921a5858d9482113e39a97e30922f951a1240e7
4
- data.tar.gz: 3edd4cdc85dee0be3d0418004eeddb7d55437feda7a7ea8bbd09b2ab5d1bdb5e
3
+ metadata.gz: 4ef433a73a4b38041a6eda3ff98ac6b0cd696a8b081706a52ef2989f8914c113
4
+ data.tar.gz: f40316dd6e2c01a62858c3de990dd7a6b1b8f40eb6040601b10197187309d562
5
5
  SHA512:
6
- metadata.gz: e52439c6b4460510de465501d741d4c2972ecffb75007a4e8a83ceb670fbb7cbf2ecd05897ff228d3b08a2c60aa1bff8c6e5dae356780740fc4c5e90c0b45bab
7
- data.tar.gz: abe64a6f163be84b3178de0e3e53c1e8187da6e4615f08cebe97695c46b13cef03c75da10ff49db549320c3f21aed373cdc173c5043dfe2a178766cb93620f3a
6
+ metadata.gz: fbc396f208a6689cc06be6d1d42f0f23309d794cb1542d979bff25962bff160003a089c9634160f6b9a2afa8bc5d97e400be102b9112834a7788432fc096a7e3
7
+ data.tar.gz: cc600feac613119f06ccdeb8c9502c55411bd610c6a69a6309308506490e2f7785aaf2080a26b14315d264c1fc1b4fea17aa3b4071de0580db4da5234005a55c
data/README.md CHANGED
@@ -92,6 +92,16 @@ puts secret
92
92
  # Output: { some: 'json', data: 'here' }
93
93
  ```
94
94
 
95
+ If you want to skip prefixes all together you can pas `false` to either
96
+ get value methods. **Not recommended**
97
+
98
+ ```ruby
99
+ # Will query for "shared-secrets/MY-SECRET-CONFIG"
100
+ secret = Sekreto.get_json_value('MY-SECRET-CONFIG', false)
101
+ puts secret
102
+ # Output: { some: 'json', data: 'here' }
103
+ ```
104
+
95
105
  ## Development
96
106
 
97
107
  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.
@@ -4,6 +4,8 @@ module Sekreto
4
4
  ##
5
5
  # Config class for setting up Sekreto for usage
6
6
  class Config
7
+ DEFAULT_PREFIX = 'secrets'.freeze
8
+
7
9
  attr_accessor :prefix
8
10
  attr_accessor :is_allowed_env
9
11
  attr_accessor :fallback_lookup
@@ -16,11 +18,26 @@ module Sekreto
16
18
  #
17
19
  # @return [Sekreto::Config]
18
20
  def initialize
19
- @prefix = 'secrets'
21
+ @prefix = DEFAULT_PREFIX
20
22
  @is_allowed_env = -> { true }
21
23
  @fallback_lookup = ->(secret_id) { ENV[secret_id] }
22
24
  @secrets_manager = nil
23
25
  @logger = Logger.new(STDOUT)
24
26
  end
27
+
28
+ ##
29
+ #
30
+ # Get the prefix name to use when looking up secrets
31
+ #
32
+ # @param prefix_path [String,NilClass,FalseClass] - The path to use for the prefix
33
+ #
34
+ # @return [String] prefix path
35
+ #
36
+ # @example If a nil is passed it defaults to the config.prefix.
37
+ # When a false is passed then no prefix is used. (Not recommended)
38
+ def prefix_name(prefix_path = nil)
39
+ return nil if prefix_path == false
40
+ prefix_path || prefix
41
+ end
25
42
  end
26
43
  end
@@ -1,3 +1,3 @@
1
1
  module Sekreto
2
- VERSION = '0.3.0'.freeze
2
+ VERSION = '0.4.0'.freeze
3
3
  end
data/lib/sekreto.rb CHANGED
@@ -65,8 +65,7 @@ module Sekreto
65
65
  private
66
66
 
67
67
  def secret_name(secret_id, prefix = nil)
68
- prefix ||= config.prefix
69
- [prefix, secret_id].join('/')
68
+ [config.prefix_name(prefix), secret_id].compact.join('/')
70
69
  end
71
70
 
72
71
  def secrets_manager
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sekreto
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Autolist Engineering
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-08-31 00:00:00.000000000 Z
11
+ date: 2018-09-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-secretsmanager
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.4
47
+ version: 0.2.0
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.1.4
54
+ version: 0.2.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: bundler
57
57
  requirement: !ruby/object:Gem::Requirement