hako-vault 0.1.1 → 0.2.0

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
  SHA1:
3
- metadata.gz: 4ab8f9cf0880782503565e24819fe1ba10a0514c
4
- data.tar.gz: 116f4a68bc5e8195d36d96ad0b61b99ac9dc364d
3
+ metadata.gz: d80f0c86dda0790aa97a2a120a06b8c2fed2187f
4
+ data.tar.gz: c17f73cb5751c60a39ceab5eb732f1994a34b663
5
5
  SHA512:
6
- metadata.gz: 88a1f61545a4fb1fb7f4ba059ca2afc3536b373e3d760b40edca4423a1c3ea0c352d4dec3fb011a9b03bf2cbe542b5c3c3b476e64f419614c19e464f6f8160a2
7
- data.tar.gz: 53c6bc27a8eced1ef346e394d9e6f8e5a1a1843e76392288fbeb13b65507461558351e4e3b8225b3dfc7321050999901c7973ff56b32053d2a42f966472aaad6
6
+ metadata.gz: a08275013f565ed8232bec84922c526c85a142b1fef354db58918e4a6d81b73ad87ab568e8c4075b4d5d324d6beb2fb3e51aca959e13d08be08f3515ba3ca9b4
7
+ data.tar.gz: 46c980de8e5a37ea3cde564747e15e80420783818e198d56fbbb6b6dc0bd8fb19e4c70e9d135f8d1108bdf66083c936de27fb361c280cceb49c47834c44320c5
@@ -5,7 +5,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
5
 
6
6
  Gem::Specification.new do |spec|
7
7
  spec.name = 'hako-vault'
8
- spec.version = '0.1.1'
8
+ spec.version = '0.2.0'
9
9
  spec.authors = ['Kohei Suzuki']
10
10
  spec.email = ['eagletmt@gmail.com']
11
11
 
@@ -49,6 +49,43 @@ module Hako
49
49
  end
50
50
  env
51
51
  end
52
+
53
+ # @return [Boolean]
54
+ def can_ask_keys?
55
+ true
56
+ end
57
+
58
+ # @param [Array<String>] variables
59
+ # @return [Array<String>]
60
+ def ask_keys(variables)
61
+ keys = []
62
+ @http.start do
63
+ parent_directories_for(variables).each do |parent_dir|
64
+ req = Net::HTTP::Get.new("/v1/secret/#{@directory}/#{parent_dir}?list=true")
65
+ req['X-Vault-Token'] = ENV['VAULT_TOKEN']
66
+ res = @http.request(req)
67
+ case res.code
68
+ when '200'
69
+ keys += JSON.parse(res.body)['data']['keys'].map { |key| "#{parent_dir}#{key}" }
70
+ when '404'
71
+ # Ignore
72
+ else
73
+ raise Error.new("Vault HTTP Error: #{res.code}: #{res.body}")
74
+ end
75
+ end
76
+ end
77
+ keys.select { |key| variables.include?(key) }
78
+ end
79
+
80
+ # @param [Array<String>] variables
81
+ # @return [Array<String>]
82
+ def parent_directories_for(variables)
83
+ # XXX: URI module cannot join relative URIs
84
+ base_uri = URI.parse("https://dummy/")
85
+ variables.map do |variable|
86
+ (base_uri + variable + '.').request_uri.sub(%r{\A/}, '')
87
+ end.uniq
88
+ end
52
89
  end
53
90
  end
54
91
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hako-vault
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kohei Suzuki
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-01-16 00:00:00.000000000 Z
11
+ date: 2017-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hako
@@ -104,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
104
104
  version: '0'
105
105
  requirements: []
106
106
  rubyforge_project:
107
- rubygems_version: 2.6.8
107
+ rubygems_version: 2.6.10
108
108
  signing_key:
109
109
  specification_version: 4
110
110
  summary: Provide variables from Vault to hako