confidante 0.28.0.pre.15 → 0.28.0.pre.19

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: 9650fc6b5cfb60cde80bd5d25dde663535bca870a8f9b08ce29eb9c2375be8f7
4
- data.tar.gz: 17cc9dd25523d6415681f1fcda2b8036c94360b4927fa97dd5532e1bfc3386e8
3
+ metadata.gz: 5f3e97cd1b0dcd653425d0934a613a5a8228b0158fdc452686380daae3300e53
4
+ data.tar.gz: 9c71a804a9684722971e6fb83c08a850585abd4713c530bad399038b363bb4b3
5
5
  SHA512:
6
- metadata.gz: 8a81fed1309c40c7f52fac384b1f084ad7f1a8352adc031aed918d780f7d072436007f12571fe8c739173f35f6b834073bb1e67efc4441ac4d085fda3e57d642
7
- data.tar.gz: e8eb70b0f2246395a497ade451252cf05d762bad52d2128f6ce50360ba20709f8921de4059202d19463641dc39dbb10a8c7f5fce7f9f81d1248e7567721abe4c
6
+ metadata.gz: 86540c8fdac3b8e870a11dcb34578ebadfb944532b879467f6c3750616d24420f86e8dd6a742e5b241fde95564537804f8f3da00570375d2ebd485752971f152
7
+ data.tar.gz: d3aa207302d69f104fc35e9e5dbd77d405237fa303ec4aa756d0bdb8f940a1877ece7855e2ea73a7995da811801dda191984325186d949560865beaad89ff86a
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- confidante (0.28.0.pre.15)
4
+ confidante (0.28.0.pre.19)
5
5
  activesupport (>= 4)
6
6
  hiera (~> 3.3)
7
7
  shikashi (~> 0.6)
@@ -113,7 +113,7 @@ GEM
113
113
  diff-lcs (>= 1.2.0, < 2.0)
114
114
  rspec-support (~> 3.11.0)
115
115
  rspec-support (3.11.0)
116
- rubocop (1.35.0)
116
+ rubocop (1.35.1)
117
117
  json (~> 2.3)
118
118
  parallel (~> 1.10)
119
119
  parser (>= 3.1.2.1)
@@ -136,12 +136,12 @@ GEM
136
136
  sexp_processor (~> 4.6)
137
137
  ruby_gpg2 (0.8.0)
138
138
  lino (>= 1.5)
139
- ruby_parser (3.18.1)
139
+ ruby_parser (3.19.1)
140
140
  sexp_processor (~> 4.16)
141
141
  sawyer (0.8.2)
142
142
  addressable (>= 2.3.5)
143
143
  faraday (> 0.8, < 2.0)
144
- sexp_processor (4.16.0)
144
+ sexp_processor (4.16.1)
145
145
  shikashi (0.6.0)
146
146
  evalhook (>= 0.6.0)
147
147
  getsource (>= 0.1.0)
@@ -180,4 +180,4 @@ DEPENDENCIES
180
180
  simplecov
181
181
 
182
182
  BUNDLED WITH
183
- 2.3.20
183
+ 2.3.21
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Confidante
4
- VERSION = '0.28.0.pre.15'
4
+ VERSION = '0.28.0.pre.19'
5
5
  end
@@ -17,24 +17,34 @@ class Hiera
17
17
 
18
18
  vault_config = Backend.parse_answer(Config[:vault], scope)
19
19
  vault_address = vault_config[:address]
20
- vault_client = Vault::Client.new(address: vault_address)
21
20
 
22
- source = vault_config[:sources][0]
21
+ throw :no_vault_address_provided unless vault_address
23
22
 
24
- throw(:unsupported_secrets_engine) unless source[:engine] == 'kv'
23
+ vault_client = Vault::Client.new(address: vault_address)
24
+ value = get_value(vault_client, key, vault_config[:sources])
25
+ Backend.parse_answer(value, scope)
26
+ end
25
27
 
26
- value = read_kv_value(vault_client, source, key)
28
+ def get_value(vault_client, key, sources)
29
+ found_source = sources.find do |source|
30
+ read_kv_value(vault_client, source, key)
31
+ end
27
32
 
28
- Backend.parse_answer(value, scope)
33
+ throw(:no_such_key) unless found_source
34
+
35
+ read_kv_value(vault_client, found_source, key)
29
36
  end
30
37
 
31
38
  def read_kv_value(vault_client, source, key)
32
- secret = vault_client.kv(source[:mount]).read(key)
33
- throw(:no_such_key) unless secret
39
+ throw(:unsupported_secrets_engine) unless source[:engine] == 'kv'
40
+
41
+ mount = source[:mount]
42
+ full_path = "#{source[:path]}/#{key}"
43
+
44
+ secret = vault_client.kv(mount).read(full_path)
45
+ return nil unless secret
34
46
 
35
- value = secret.data[:value]
36
- throw(:no_such_key) unless value
37
- value
47
+ secret.data[:value]
38
48
  end
39
49
  end
40
50
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: confidante
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.0.pre.15
4
+ version: 0.28.0.pre.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - InfraBlocks Maintainers
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-08-17 00:00:00.000000000 Z
11
+ date: 2022-08-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport