confidante 0.28.0.pre.13 → 0.28.0.pre.16

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: f6a9c4e82dcf2195dba2d6bd9d93af2f0e6b84222b9536bda2f888a097076851
4
- data.tar.gz: b18f17998406440b3a075a4393399148cbda3fea00e56e36ab5d4ef30f192d7c
3
+ metadata.gz: f227c07f069e181681816cc7489b858e84902900d7c19f31b5ba99449f6e431b
4
+ data.tar.gz: b0d0e7a23a56b82c86a26aedad88b03f12ae92a08a8a6d670cd6929916c15c79
5
5
  SHA512:
6
- metadata.gz: 366c98cff98776df6b7a9577da69a97f36b7b96106c4345073521e26c24289a93207152e9e35ba7aa1043520b52579639e5bcf019a916ed6d266a0427c3a1686
7
- data.tar.gz: 173105f8ee23c22b82665947fd02cc0cc7ccc282b788c4d68a175aa8125494aea943fcc9c156b3a76a483ffba028c1c7740e7b1c9ae9d2a082cc9dd87ae9b5c7
6
+ metadata.gz: 83b32114eccd28d13653e36afe295828adf3def314aa33d21da2665e237021c74128b852c7244a273cedfa880bcd2ad628226ca16ae14db5f50d9adb39cc0626
7
+ data.tar.gz: 031042a9e6e29028ff51a5772c834cf4025f04b4e250a3ca2ea5fe638d1d1fb70c43bf209200ff5c2e3b6ccc07537a711d87277b1035ac5fdfebb4d8d51fe5a9
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- confidante (0.28.0.pre.13)
4
+ confidante (0.28.0.pre.16)
5
5
  activesupport (>= 4)
6
6
  hiera (~> 3.3)
7
7
  shikashi (~> 0.6)
@@ -161,6 +161,7 @@ GEM
161
161
  PLATFORMS
162
162
  arm64-darwin-21
163
163
  x86_64-darwin-20
164
+ x86_64-darwin-21
164
165
  x86_64-linux
165
166
 
166
167
  DEPENDENCIES
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Confidante
4
- VERSION = '0.28.0.pre.13'
4
+ VERSION = '0.28.0.pre.16'
5
5
  end
@@ -9,23 +9,44 @@ class Hiera
9
9
  class Vault_backend
10
10
  def initialize
11
11
  Hiera.debug('Hiera vault backend starting')
12
-
13
- @client = Vault::Client.new
14
12
  end
15
13
 
16
14
  def lookup(key, scope, _order_override, resolution_type, _context)
17
15
  Hiera.debug("Looking up #{key} in vault backend " \
18
16
  "with #{resolution_type}")
19
17
 
20
- secret = @client.kv('kv').read(key)
21
- throw(:no_such_key) unless secret
18
+ vault_config = Backend.parse_answer(Config[:vault], scope)
19
+ vault_address = vault_config[:address]
20
+ vault_client = Vault::Client.new(address: vault_address)
22
21
 
23
- value = secret.data[:value]
24
- throw(:no_such_key) unless value
22
+ value = get_value(vault_client, key, vault_config[:sources])
25
23
 
26
24
  Backend.parse_answer(value, scope)
27
25
  end
26
+
27
+ def get_value(vault_client, key, sources)
28
+ found_source = sources.find do |source|
29
+ read_kv_value(vault_client, source, key)
30
+ end
31
+
32
+ throw(:no_such_key) unless found_source
33
+
34
+ read_kv_value(vault_client, found_source, key)
35
+ end
36
+
37
+ def read_kv_value(vault_client, source, key)
38
+ throw(:unsupported_secrets_engine) unless source[:engine] == 'kv'
39
+
40
+ mount = source[:mount]
41
+ full_path = "#{source[:path]}/#{key}"
42
+
43
+ secret = vault_client.kv(mount).read(full_path)
44
+ return nil unless secret
45
+
46
+ secret.data[:value]
47
+ end
28
48
  end
49
+
29
50
  # rubocop:enable Naming/ClassAndModuleCamelCase
30
51
  end
31
52
  end
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.13
4
+ version: 0.28.0.pre.16
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-16 00:00:00.000000000 Z
11
+ date: 2022-08-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport