hako-vault 0.2.2 → 0.2.3

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: 22c6fcbd129b51b0c3ade5c375f03f1b2a398c3e
4
- data.tar.gz: 258e19161da4d0fce2b195b21a5b6bf9e5d02111
3
+ metadata.gz: 857dcdb4a7af8fa24681d44c9a7dfadd0b2f0fbb
4
+ data.tar.gz: 155f485439835ce24f8fdac0c010d97c1584a1e3
5
5
  SHA512:
6
- metadata.gz: 33b7621675c97fcc07e609ca5ffcc8a50e5f619819f7962fe377800a547140139ef3104ffbe7f5404dd26febafcd1af1acdff7a37db02688549dbb5e9acabe63
7
- data.tar.gz: 798a41387e80ad8b82ef2886cac5bb7875b62a07a9dd2e0f04e1ca3b20c1f008052e6a5f1c6aa3d79fe6faabc260e3d1d2fa9781b6bd2a8d7ed3aaa98d595d69
6
+ metadata.gz: 8ca9f0d575d0c89cddc8e60ac038b1e1338f28fc649790cbd7bc3983c8a35a7766d81c6d9002cf54237ab6faff9cf23d3a8249a0cf625ab8e7f17914304cfad3
7
+ data.tar.gz: f04e9d6cd602f3aa5e5cee050a334cb213ad8095cac2162eb410774842a609230a79ea84ac508428abf767cf926528a99d3cdadda379fb360fb3370a0e18da9c
@@ -1,3 +1,7 @@
1
+ # 0.2.3 (2017-07-20)
2
+ ## Bug fixes
3
+ - Retry when Vault returns 307
4
+
1
5
  # 0.2.2 (2017-06-26)
2
6
  ## Bug fixes
3
7
  - Retry when Vault returns 5xx
data/Gemfile CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  source 'https://rubygems.org'
3
4
 
4
5
  # Specify your gem's dependencies in hako-vault.gemspec
data/Rakefile CHANGED
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'bundler/gem_tasks'
3
4
  task default: :spec
@@ -1,11 +1,12 @@
1
1
  # coding: utf-8
2
2
  # frozen_string_literal: true
3
+
3
4
  lib = File.expand_path('../lib', __FILE__)
4
5
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
6
 
6
7
  Gem::Specification.new do |spec|
7
8
  spec.name = 'hako-vault'
8
- spec.version = '0.2.2'
9
+ spec.version = '0.2.3'
9
10
  spec.authors = ['Kohei Suzuki']
10
11
  spec.email = ['eagletmt@gmail.com']
11
12
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  require 'hako/env_provider'
3
4
  require 'json'
4
5
  require 'net/http'
@@ -80,7 +81,7 @@ module Hako
80
81
  # @return [Array<String>]
81
82
  def parent_directories_for(variables)
82
83
  # XXX: URI module cannot join relative URIs
83
- base_uri = URI.parse("https://dummy/")
84
+ base_uri = URI.parse('https://dummy/')
84
85
  variables.map do |variable|
85
86
  (base_uri + variable + '.').request_uri.sub(%r{\A/}, '')
86
87
  end.uniq
@@ -95,7 +96,7 @@ module Hako
95
96
  req['X-Vault-Token'] = ENV['VAULT_TOKEN']
96
97
  res = @http.request(req)
97
98
  code = res.code.to_i
98
- if code >= 500 && code < 600
99
+ if retryable_http_code?(code)
99
100
  Hako.logger.warn("Vault HTTP Error: #{res.code}: #{res.body}")
100
101
  last_error = res
101
102
  interval = 1.5**i
@@ -107,6 +108,10 @@ module Hako
107
108
  end
108
109
  raise Error.new("Vault HTTP Error: #{last_error.code}: #{last_error.body}")
109
110
  end
111
+
112
+ def retryable_http_code?(code)
113
+ code == 307 || (code >= 500 && code < 600)
114
+ end
110
115
  end
111
116
  end
112
117
  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.2.2
4
+ version: 0.2.3
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-06-26 00:00:00.000000000 Z
11
+ date: 2017-07-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hako