confidante 0.28.0.pre.16 → 0.28.0.pre.20

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: f227c07f069e181681816cc7489b858e84902900d7c19f31b5ba99449f6e431b
4
- data.tar.gz: b0d0e7a23a56b82c86a26aedad88b03f12ae92a08a8a6d670cd6929916c15c79
3
+ metadata.gz: f1bfb2c0fa603d1a89d220fd4c54dc97fb1ef1a00447ceabfe657e9dfb1d4e29
4
+ data.tar.gz: 98ebe1930702415a5f6fc09fc206d165498dcbb0696b00cd387b9ff0baa75924
5
5
  SHA512:
6
- metadata.gz: 83b32114eccd28d13653e36afe295828adf3def314aa33d21da2665e237021c74128b852c7244a273cedfa880bcd2ad628226ca16ae14db5f50d9adb39cc0626
7
- data.tar.gz: 031042a9e6e29028ff51a5772c834cf4025f04b4e250a3ca2ea5fe638d1d1fb70c43bf209200ff5c2e3b6ccc07537a711d87277b1035ac5fdfebb4d8d51fe5a9
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.16)
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.0)
116
+ rubocop (1.36.0)
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
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.16'
4
+ VERSION = '0.28.0.pre.20'
5
5
  end
@@ -16,22 +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
- vault_client = Vault::Client.new(address: vault_address)
21
19
 
22
- value = get_value(vault_client, key, vault_config[:sources])
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
23
27
 
24
- Backend.parse_answer(value, scope)
28
+ def valid_vault_address?(vault_config)
29
+ vault_address = vault_config[:address]
30
+ vault_address.nil? || vault_address.empty?
25
31
  end
26
32
 
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
33
+ def get_value(vault_config, key)
34
+ vault_address = vault_config[:address]
35
+ vault_client = Vault::Client.new(address: vault_address)
36
+ get_first_value_from_sources(
37
+ vault_client,
38
+ key,
39
+ vault_config[:sources]
40
+ )
41
+ end
31
42
 
32
- throw(:no_such_key) unless found_source
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)
46
+
47
+ return value if value
48
+ end
33
49
 
34
- read_kv_value(vault_client, found_source, key)
50
+ throw(:no_such_key)
35
51
  end
36
52
 
37
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.16
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-17 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