escobar 0.3.13 → 0.3.14
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 +4 -4
- data/lib/escobar.rb +8 -0
- data/lib/escobar/client.rb +15 -0
- data/lib/escobar/github/client.rb +10 -8
- data/lib/escobar/heroku/app.rb +3 -0
- data/lib/escobar/heroku/client.rb +10 -10
- data/lib/escobar/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 035950776942aaae20ca8e18c5f81c049c33d04f
|
4
|
+
data.tar.gz: 3e02f301fcc4ec2a6073f2add4b751638632d3d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 83cae7d927fb2c220d90aba09a3686bd0968feb67eac7e873a6ee7bc12148c088c5359aa55a63e91ff4190e77d328169251d4e175fd852bc64f8c7e6ca11ab85
|
7
|
+
data.tar.gz: 00f5a6b7d2317100127c27ccaa5df9d738061d27e417b8d89ba8959fd11e1eefc6245a862c262ab0a2f6bd539a41f4cfd5358f6a4f7094b1d081dc1dcde03476
|
data/lib/escobar.rb
CHANGED
@@ -48,6 +48,14 @@ module Escobar
|
|
48
48
|
def self.zipkin_enabled?
|
49
49
|
!ENV["ZIPKIN_SERVICE_NAME"].nil? && !ENV["ZIPKIN_API_HOST"].nil?
|
50
50
|
end
|
51
|
+
|
52
|
+
def self.http_open_timeout
|
53
|
+
3
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.http_timeout
|
57
|
+
6
|
58
|
+
end
|
51
59
|
end
|
52
60
|
|
53
61
|
require_relative "./escobar/client"
|
data/lib/escobar/client.rb
CHANGED
@@ -1,6 +1,21 @@
|
|
1
1
|
module Escobar
|
2
2
|
# Top-level client for heroku
|
3
3
|
class Client
|
4
|
+
# Class for returning API errors to escobar clients
|
5
|
+
class HTTPError < StandardError
|
6
|
+
attr_accessor :body, :headers, :status
|
7
|
+
def self.from_response(err, response)
|
8
|
+
error = new("Error from Heroku API")
|
9
|
+
|
10
|
+
error.body = response.body
|
11
|
+
error.status = response.status
|
12
|
+
error.headers = response.headers
|
13
|
+
|
14
|
+
error.set_backtrace(err.backtrace)
|
15
|
+
error
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
4
19
|
def self.from_environment
|
5
20
|
new(Escobar.github_api_token, Escobar.heroku_api_token)
|
6
21
|
end
|
@@ -78,8 +78,8 @@ module Escobar
|
|
78
78
|
def get(path)
|
79
79
|
response = http_method(:get, path)
|
80
80
|
JSON.parse(response.body)
|
81
|
-
rescue StandardError
|
82
|
-
|
81
|
+
rescue StandardError => e
|
82
|
+
raise Escobar::Client::HTTPError.from_response(e, response)
|
83
83
|
end
|
84
84
|
|
85
85
|
def accept_headers
|
@@ -92,26 +92,28 @@ module Escobar
|
|
92
92
|
request.headers["Accept"] = accept_headers
|
93
93
|
request.headers["Content-Type"] = "application/json"
|
94
94
|
request.headers["Authorization"] = "token #{token}"
|
95
|
-
request.options.timeout =
|
96
|
-
request.options.open_timeout =
|
95
|
+
request.options.timeout = Escobar.http_timeout
|
96
|
+
request.options.open_timeout = Escobar.http_open_timeout
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
+
# rubocop:disable Metrics/AbcSize
|
100
101
|
def post(path, body)
|
101
102
|
response = client.post do |request|
|
102
103
|
request.url path
|
103
104
|
request.headers["Accept"] = accept_headers
|
104
105
|
request.headers["Content-Type"] = "application/json"
|
105
106
|
request.headers["Authorization"] = "token #{token}"
|
106
|
-
request.options.timeout =
|
107
|
-
request.options.open_timeout =
|
107
|
+
request.options.timeout = Escobar.http_timeout
|
108
|
+
request.options.open_timeout = Escobar.http_open_timeout
|
108
109
|
request.body = body.to_json
|
109
110
|
end
|
110
111
|
|
111
112
|
JSON.parse(response.body)
|
112
|
-
rescue StandardError
|
113
|
-
|
113
|
+
rescue StandardError => e
|
114
|
+
raise Escobar::Client::HTTPError.from_response(e, response)
|
114
115
|
end
|
116
|
+
# rubocop:enable Metrics/AbcSize
|
115
117
|
|
116
118
|
private
|
117
119
|
|
data/lib/escobar/heroku/app.rb
CHANGED
@@ -52,6 +52,9 @@ module Escobar
|
|
52
52
|
def locked?
|
53
53
|
response = client.heroku.get("/apps/#{id}/config-vars")
|
54
54
|
response["id"] == "two_factor"
|
55
|
+
rescue Escobar::Heroku::Client::HTTPError => e
|
56
|
+
response = JSON.parse(e.response.body)
|
57
|
+
response["id"] == "two_factor"
|
55
58
|
end
|
56
59
|
|
57
60
|
def build_request_for(pipeline)
|
@@ -26,8 +26,8 @@ module Escobar
|
|
26
26
|
end
|
27
27
|
|
28
28
|
JSON.parse(response.body)
|
29
|
-
rescue StandardError
|
30
|
-
|
29
|
+
rescue StandardError => e
|
30
|
+
raise Escobar::Client::HTTPError.from_response(e, response)
|
31
31
|
end
|
32
32
|
|
33
33
|
def get_range(path, range, version = 3)
|
@@ -38,8 +38,8 @@ module Escobar
|
|
38
38
|
end
|
39
39
|
|
40
40
|
JSON.parse(response.body)
|
41
|
-
rescue StandardError
|
42
|
-
|
41
|
+
rescue StandardError => e
|
42
|
+
raise Escobar::Client::HTTPError.from_response(e, response)
|
43
43
|
end
|
44
44
|
|
45
45
|
def post(path, body)
|
@@ -50,8 +50,8 @@ module Escobar
|
|
50
50
|
end
|
51
51
|
|
52
52
|
JSON.parse(response.body)
|
53
|
-
rescue StandardError
|
54
|
-
|
53
|
+
rescue StandardError => e
|
54
|
+
raise Escobar::Client::HTTPError.from_response(e, response)
|
55
55
|
end
|
56
56
|
|
57
57
|
def put(path, second_factor = nil)
|
@@ -64,8 +64,8 @@ module Escobar
|
|
64
64
|
end
|
65
65
|
|
66
66
|
JSON.parse(response.body)
|
67
|
-
rescue StandardError
|
68
|
-
|
67
|
+
rescue StandardError => e
|
68
|
+
raise Escobar::Client::HTTPError.from_response(e, response)
|
69
69
|
end
|
70
70
|
|
71
71
|
private
|
@@ -77,8 +77,8 @@ module Escobar
|
|
77
77
|
if token
|
78
78
|
request.headers["Authorization"] = "Bearer #{token}"
|
79
79
|
end
|
80
|
-
request.options.timeout =
|
81
|
-
request.options.open_timeout =
|
80
|
+
request.options.timeout = Escobar.http_timeout
|
81
|
+
request.options.open_timeout = Escobar.http_open_timeout
|
82
82
|
end
|
83
83
|
|
84
84
|
def heroku_accept_header(version)
|
data/lib/escobar/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: escobar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Corey Donohoe
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|