rubyconfig-vault 1.0.4 → 1.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/config/vault/vault_error.rb +7 -0
- data/lib/config/vault/vault_source.rb +30 -3
- data/lib/config/vault/version.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 615bbf4df424a7d1f403b806113e097c81ef41752afa9ebd61771d45a10f4991
|
4
|
+
data.tar.gz: 563b9bd3cd608d49ee2050bd86dd0374cd8fd5a12549f3235f3170ddc65f889a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 36c354d9baf5cce5f2cd4d0492caa90ae3b77ee4e0e7891d6e260f0a3b2a33f42c749193c5b7c4e82526b5ac9d55dd4d35e4a90a274f89302910deea94f71859
|
7
|
+
data.tar.gz: 652d144137915a2e7213fbf4cb4fb12efa3fecc8fe6861a376a67ff3c1f6ec7edfc44e364ec07553282b4cc687024c5aab29a826691e910c0d1fd57cd92b6965
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'config'
|
2
2
|
require 'vault'
|
3
|
+
require_relative 'vault_error'
|
3
4
|
|
4
5
|
module Config
|
5
6
|
module Sources
|
@@ -68,7 +69,7 @@ module Config
|
|
68
69
|
#
|
69
70
|
# @return [Hash]
|
70
71
|
def load
|
71
|
-
::Vault.with_retries(
|
72
|
+
::Vault.with_retries(RecoverableVaultError,
|
72
73
|
attempts: @attempts,
|
73
74
|
base: @base,
|
74
75
|
max_wait: @max_wait) do
|
@@ -86,6 +87,30 @@ module Config
|
|
86
87
|
end
|
87
88
|
end
|
88
89
|
|
90
|
+
def read_at_path(query_path)
|
91
|
+
client_ops.read(query_path)&.data || {}
|
92
|
+
rescue ::Vault::HTTPClientError => e
|
93
|
+
if e.code == 403
|
94
|
+
raise VaultError, "Attempting to read at path #{query_path}\n#{e.response}", caller
|
95
|
+
else
|
96
|
+
raise RecoverableVaultError, e.response, caller
|
97
|
+
end
|
98
|
+
rescue ::Vault::HTTPError => e
|
99
|
+
raise RecoverableVaultError, e.response, caller
|
100
|
+
end
|
101
|
+
|
102
|
+
def list_at_path(query_path)
|
103
|
+
client_ops.list(query_path)
|
104
|
+
rescue ::Vault::HTTPClientError => e
|
105
|
+
if e.code == 403
|
106
|
+
raise VaultError, "Attempting to list at path #{query_path}\n#{e.response}", caller
|
107
|
+
else
|
108
|
+
raise RecoverableVaultError, e.response, caller
|
109
|
+
end
|
110
|
+
rescue ::Vault::HTTPError => e
|
111
|
+
raise RecoverableVaultError, e.response, caller
|
112
|
+
end
|
113
|
+
|
89
114
|
def process_paths
|
90
115
|
root = {}
|
91
116
|
parsed_paths = @paths.map { |p| process_path(p) }
|
@@ -104,7 +129,7 @@ module Config
|
|
104
129
|
query_path, idx, parent = stack.pop
|
105
130
|
sp = subpaths[idx]
|
106
131
|
if sp.nil? || sp.eql?('*')
|
107
|
-
data =
|
132
|
+
data = read_at_path(query_path)
|
108
133
|
node = root if @flatten
|
109
134
|
node = parent unless @flatten
|
110
135
|
node.merge!(data)
|
@@ -113,7 +138,7 @@ module Config
|
|
113
138
|
end
|
114
139
|
|
115
140
|
if sp.eql?('**') || sp.eql?('*')
|
116
|
-
subtrees =
|
141
|
+
subtrees = list_at_path(query_path)
|
117
142
|
subtrees.each do |st|
|
118
143
|
new_parent = {}
|
119
144
|
new_key = st.split('/').last.downcase.to_sym
|
@@ -131,6 +156,8 @@ module Config
|
|
131
156
|
end
|
132
157
|
|
133
158
|
if path.last
|
159
|
+
{ path.last => root }
|
160
|
+
elsif @root
|
134
161
|
{ @root => root }
|
135
162
|
else
|
136
163
|
root
|
data/lib/config/vault/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rubyconfig-vault
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Young
|
@@ -88,6 +88,7 @@ extensions: []
|
|
88
88
|
extra_rdoc_files: []
|
89
89
|
files:
|
90
90
|
- lib/config/vault.rb
|
91
|
+
- lib/config/vault/vault_error.rb
|
91
92
|
- lib/config/vault/vault_source.rb
|
92
93
|
- lib/config/vault/version.rb
|
93
94
|
homepage: https://github.com/CrunchwrapSupreme/rubyconfig-vault
|