confidante 0.28.0.pre.14 → 0.28.0.pre.17

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: 79c9839bc842ebec023e9ed5b5dfb855a0d71065197b823f61fd672ccde8ae0a
4
- data.tar.gz: 3fb77acf16a3aefb99ac313a02b834ac091b1ada64af3dd669d190c72e5d66b5
3
+ metadata.gz: 94d4ad7adeb2f7f50922b57bbcb7112754b76c8c14c1deec0f6e6c976ef746bc
4
+ data.tar.gz: 720f5ad0310855b2c45babda8fef3a0a2a31457a43e836a384c690ddc781b8b5
5
5
  SHA512:
6
- metadata.gz: ced6ac392c151b4a5e70ea61cbb5a17c3e4f41c99c54d70f780e0079697b09a2b63099eb367a4eaf1c791a51aff82ed1082bf6d6cf5dcb1346cfb8f0e60aad9e
7
- data.tar.gz: e94e7f53374f7e2b5b3570111cc959874b546ecbea03738eff28c0f890637d43260f2884a8d93b3b45c146b38cdfb88ac5c58f8476174a8f48b1bfe6ed5d5e91
6
+ metadata.gz: bcb0aaf12c349634d99b098d74fff4eceb293105f9a763e6651f3ff85af907b865d87e3e16fd68b57c8db368b641977f705705969de78e4b1030621f559f45b0
7
+ data.tar.gz: 60436dbd48b8ec6e338a407381acaa839361e3b658216f81d70f2786b06a159c985cc992f8614ded82516ef8a0d51afbbbf32190b30a8b0a31a95b7147227dc1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- confidante (0.28.0.pre.14)
4
+ confidante (0.28.0.pre.17)
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)
@@ -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
@@ -179,4 +180,4 @@ DEPENDENCIES
179
180
  simplecov
180
181
 
181
182
  BUNDLED WITH
182
- 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.14'
4
+ VERSION = '0.28.0.pre.17'
5
5
  end
@@ -17,17 +17,37 @@ class Hiera
17
17
 
18
18
  vault_config = Backend.parse_answer(Config[:vault], scope)
19
19
  vault_address = vault_config[:address]
20
+
21
+ throw :no_vault_address_provided unless vault_address
22
+
20
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
21
27
 
22
- secret = vault_client.kv('kv').read(key)
23
- throw(:no_such_key) unless secret
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
24
32
 
25
- value = secret.data[:value]
26
- throw(:no_such_key) unless value
33
+ throw(:no_such_key) unless found_source
27
34
 
28
- Backend.parse_answer(value, scope)
35
+ read_kv_value(vault_client, found_source, key)
36
+ end
37
+
38
+ def read_kv_value(vault_client, source, key)
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
46
+
47
+ secret.data[:value]
29
48
  end
30
49
  end
50
+
31
51
  # rubocop:enable Naming/ClassAndModuleCamelCase
32
52
  end
33
53
  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.14
4
+ version: 0.28.0.pre.17
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-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport