confidante 0.28.0.pre.19 → 0.28.0.pre.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5f3e97cd1b0dcd653425d0934a613a5a8228b0158fdc452686380daae3300e53
4
- data.tar.gz: 9c71a804a9684722971e6fb83c08a850585abd4713c530bad399038b363bb4b3
3
+ metadata.gz: f1bfb2c0fa603d1a89d220fd4c54dc97fb1ef1a00447ceabfe657e9dfb1d4e29
4
+ data.tar.gz: 98ebe1930702415a5f6fc09fc206d165498dcbb0696b00cd387b9ff0baa75924
5
5
  SHA512:
6
- metadata.gz: 86540c8fdac3b8e870a11dcb34578ebadfb944532b879467f6c3750616d24420f86e8dd6a742e5b241fde95564537804f8f3da00570375d2ebd485752971f152
7
- data.tar.gz: d3aa207302d69f104fc35e9e5dbd77d405237fa303ec4aa756d0bdb8f940a1877ece7855e2ea73a7995da811801dda191984325186d949560865beaad89ff86a
6
+ metadata.gz: 5e5278e02d47658641d1ce61d9f147a60cebae653792bbfdf09bf8641e0034087fbf5059da792ddb39a3ec67764e435e3aeb04a5dd204f592991d9443a2152fa
7
+ data.tar.gz: 248b245aa62c7005f8de4939351a63cf80f84b9d6561885e1cdbc70d81abf9cc137bfe2071dd009bd620b542af280d5c90b41d6ca64b15dc85508dbe0dc497fa
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- confidante (0.28.0.pre.19)
4
+ confidante (0.28.0.pre.20)
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.1)
116
+ rubocop (1.36.0)
117
117
  json (~> 2.3)
118
118
  parallel (~> 1.10)
119
119
  parser (>= 3.1.2.1)
data/Rakefile CHANGED
@@ -50,7 +50,7 @@ namespace :library do
50
50
  task check: [:rubocop]
51
51
 
52
52
  desc 'Attempt to automatically fix issues with the library'
53
- task fix: [:'rubocop:auto_correct']
53
+ task fix: [:'rubocop:autocorrect']
54
54
  end
55
55
 
56
56
  namespace :test do
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Confidante
4
- VERSION = '0.28.0.pre.19'
4
+ VERSION = '0.28.0.pre.20'
5
5
  end
@@ -16,23 +16,38 @@ class Hiera
16
16
  "with #{resolution_type}")
17
17
 
18
18
  vault_config = Backend.parse_answer(Config[:vault], scope)
19
- vault_address = vault_config[:address]
20
19
 
21
- throw :no_vault_address_provided unless vault_address
20
+ if valid_vault_address?(vault_config)
21
+ Hiera.warn('No vault address provided. Skipping lookup!')
22
+ nil
23
+ else
24
+ Backend.parse_answer(get_value(vault_config, key), scope)
25
+ end
26
+ end
22
27
 
28
+ def valid_vault_address?(vault_config)
29
+ vault_address = vault_config[:address]
30
+ vault_address.nil? || vault_address.empty?
31
+ end
32
+
33
+ def get_value(vault_config, key)
34
+ vault_address = vault_config[:address]
23
35
  vault_client = Vault::Client.new(address: vault_address)
24
- value = get_value(vault_client, key, vault_config[:sources])
25
- Backend.parse_answer(value, scope)
36
+ get_first_value_from_sources(
37
+ vault_client,
38
+ key,
39
+ vault_config[:sources]
40
+ )
26
41
  end
27
42
 
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
43
+ def get_first_value_from_sources(vault_client, key, sources)
44
+ sources.each do |source|
45
+ value = read_kv_value(vault_client, source, key)
32
46
 
33
- throw(:no_such_key) unless found_source
47
+ return value if value
48
+ end
34
49
 
35
- read_kv_value(vault_client, found_source, key)
50
+ throw(:no_such_key)
36
51
  end
37
52
 
38
53
  def read_kv_value(vault_client, source, key)
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.19
4
+ version: 0.28.0.pre.20
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-25 00:00:00.000000000 Z
11
+ date: 2022-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport