marathon-api 2.1.0 → 2.2.0
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/.ruby-gemset +1 -0
- data/fixtures/vcr/Marathon/_ping/handles_incorrect_content_type.yml +44 -0
- data/lib/marathon.rb +6 -1
- data/lib/marathon/app.rb +1 -2
- data/lib/marathon/connection.rb +5 -1
- data/lib/marathon/error.rb +6 -1
- data/lib/marathon/group.rb +0 -2
- data/lib/marathon/version.rb +1 -1
- data/spec/marathon/app_spec.rb +3 -3
- data/spec/marathon/group_spec.rb +0 -8
- data/spec/marathon/marathon_spec.rb +4 -0
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1706cc80987ace99626068137b1f7bea726c7bb9
|
4
|
+
data.tar.gz: 87571a9f41049b0c042ed7adc8f519fa3cc7958d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35be5caa1de1d2b6d5140f548d417cc88610f1b5fe38d652b4011d223168736163c9da34483a460fb729c0a4dcfd7619670e50c998d430bfbdf7f8cd3eed3477
|
7
|
+
data.tar.gz: 63bfa8546577bea9680fc945ccdd4629e418f46530193e0a4617b1a0a17e76385413b00c0b98f95cf66838ae96b3d9d44a56433f08701d34843f5ec2b4724272
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
marathon-api
|
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
http_interactions:
|
3
|
+
- request:
|
4
|
+
method: get
|
5
|
+
uri: http://localhost:8080/ping
|
6
|
+
body:
|
7
|
+
encoding: US-ASCII
|
8
|
+
string: ''
|
9
|
+
headers:
|
10
|
+
Content-Type:
|
11
|
+
- application/json
|
12
|
+
Accept:
|
13
|
+
- application/json
|
14
|
+
User-Agent:
|
15
|
+
- ub0r/Marathon-API 1.3.2
|
16
|
+
response:
|
17
|
+
status:
|
18
|
+
code: 200
|
19
|
+
message: OK
|
20
|
+
headers:
|
21
|
+
Date:
|
22
|
+
- Wed, 02 Mar 2016 11:32:08 GMT
|
23
|
+
- Wed, 02 Mar 2016 11:32:08 GMT
|
24
|
+
Server:
|
25
|
+
- Jetty(9.3.z-SNAPSHOT)
|
26
|
+
Cache-Control:
|
27
|
+
- must-revalidate,no-cache,no-store
|
28
|
+
Access-Control-Allow-Credentials:
|
29
|
+
- 'true'
|
30
|
+
Expires:
|
31
|
+
- '0'
|
32
|
+
Pragma:
|
33
|
+
- no-cache
|
34
|
+
Content-Type:
|
35
|
+
- application/json; qs=2
|
36
|
+
Content-Length:
|
37
|
+
- '5'
|
38
|
+
body:
|
39
|
+
encoding: UTF-8
|
40
|
+
string: |
|
41
|
+
pong
|
42
|
+
http_version:
|
43
|
+
recorded_at: Wed, 02 Mar 2016 11:32:28 GMT
|
44
|
+
recorded_with: VCR 2.9.3
|
data/lib/marathon.rb
CHANGED
@@ -41,7 +41,12 @@ module Marathon
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def ping
|
44
|
-
|
44
|
+
begin
|
45
|
+
connection.get('/ping')
|
46
|
+
rescue Marathon::Error::UnexpectedResponseError => err
|
47
|
+
return err.response.body if err.response.code == 200
|
48
|
+
raise err
|
49
|
+
end
|
45
50
|
end
|
46
51
|
|
47
52
|
# Get information about the marathon server
|
data/lib/marathon/app.rb
CHANGED
data/lib/marathon/connection.rb
CHANGED
@@ -88,7 +88,11 @@ class Marathon::Connection
|
|
88
88
|
# ++response++: response from HTTParty call.
|
89
89
|
def parse_response(response)
|
90
90
|
if response.success?
|
91
|
-
|
91
|
+
begin
|
92
|
+
response.parsed_response
|
93
|
+
rescue => err
|
94
|
+
raise Marathon::Error.from_response(response)
|
95
|
+
end
|
92
96
|
else
|
93
97
|
raise Marathon::Error.from_response(response)
|
94
98
|
end
|
data/lib/marathon/error.rb
CHANGED
@@ -19,6 +19,7 @@ module Marathon::Error
|
|
19
19
|
|
20
20
|
# Raised when there is an unexpected response code / body.
|
21
21
|
class UnexpectedResponseError < MarathonError;
|
22
|
+
attr_accessor :response
|
22
23
|
end
|
23
24
|
|
24
25
|
# Raised when a request times out.
|
@@ -36,7 +37,9 @@ module Marathon::Error
|
|
36
37
|
# Raise error specific to http response.
|
37
38
|
# ++response++: HTTParty response object.
|
38
39
|
def from_response(response)
|
39
|
-
error_class(response).new(error_message(response))
|
40
|
+
error_class(response).new(error_message(response)).tap do |err|
|
41
|
+
err.response = response if err.is_a?(UnexpectedResponseError)
|
42
|
+
end
|
40
43
|
end
|
41
44
|
|
42
45
|
private
|
@@ -69,6 +72,8 @@ module Marathon::Error
|
|
69
72
|
else
|
70
73
|
body
|
71
74
|
end
|
75
|
+
rescue JSON::ParserError
|
76
|
+
body
|
72
77
|
end
|
73
78
|
|
74
79
|
module_function :error_class, :error_message, :from_response
|
data/lib/marathon/group.rb
CHANGED
@@ -19,8 +19,6 @@ class Marathon::Group < Marathon::Base
|
|
19
19
|
@marathon_instance = marathon_instance
|
20
20
|
raise ArgumentError, 'Group must have an id' unless id
|
21
21
|
refresh_attributes
|
22
|
-
raise ArgumentError, 'Group can have either groups or apps, not both' \
|
23
|
-
if apps.size > 0 and groups.size > 0 and id != '/'
|
24
22
|
end
|
25
23
|
|
26
24
|
# Reload attributes from marathon API.
|
data/lib/marathon/version.rb
CHANGED
data/spec/marathon/app_spec.rb
CHANGED
@@ -45,7 +45,7 @@ describe Marathon::App do
|
|
45
45
|
subject { described_class.new({'id' => '/app/foo'}, double(Marathon::MarathonInstance)) }
|
46
46
|
|
47
47
|
let(:expected_string) do
|
48
|
-
'{"env":{},"labels":{},"
|
48
|
+
'{"env":{},"labels":{},"id":"/app/foo"}'
|
49
49
|
end
|
50
50
|
|
51
51
|
its(:to_json) { should == expected_string }
|
@@ -155,7 +155,7 @@ describe Marathon::App do
|
|
155
155
|
expect(@subject).to receive(:check_read_only)
|
156
156
|
expect(@apps).to receive(:change).with(
|
157
157
|
'/app/foo',
|
158
|
-
{:env => {}, :labels => {}, :
|
158
|
+
{:env => {}, :labels => {}, :id => "/app/foo"},
|
159
159
|
false
|
160
160
|
)
|
161
161
|
@subject.start!
|
@@ -165,7 +165,7 @@ describe Marathon::App do
|
|
165
165
|
expect(@apps).to receive(:change)
|
166
166
|
.with(
|
167
167
|
'/app/foo',
|
168
|
-
{:env => {}, :labels => {}, :
|
168
|
+
{:env => {}, :labels => {}, :id => "/app/foo"},
|
169
169
|
false
|
170
170
|
)
|
171
171
|
@subject.start!
|
data/spec/marathon/group_spec.rb
CHANGED
@@ -32,14 +32,6 @@ EXAMPLE_GROUP = {
|
|
32
32
|
|
33
33
|
describe Marathon::Group do
|
34
34
|
|
35
|
-
describe '#init' do
|
36
|
-
it 'fails with group + apps' do
|
37
|
-
expect { described_class.new({:apps => [{:id => 'app'}], :groups => [{:id => 'group'}], :id => '/foo'},
|
38
|
-
double(Marathon::MarathonInstance)) }
|
39
|
-
.to raise_error(Marathon::Error::ArgumentError, /Group can have either/)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
35
|
describe '#to_s' do
|
44
36
|
subject { described_class.new(EXAMPLE_GROUP) }
|
45
37
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: marathon-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Bechstein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|
@@ -174,6 +174,7 @@ extra_rdoc_files: []
|
|
174
174
|
files:
|
175
175
|
- ".cane"
|
176
176
|
- ".gitignore"
|
177
|
+
- ".ruby-gemset"
|
177
178
|
- ".simplecov"
|
178
179
|
- ".travis.yml"
|
179
180
|
- Gemfile
|
@@ -186,6 +187,7 @@ files:
|
|
186
187
|
- fixtures/marathon_docker_sample_2.json
|
187
188
|
- fixtures/vcr/Marathon/_info/returns_the_info_hash.yml
|
188
189
|
- fixtures/vcr/Marathon/_metrics/returns_the_metrics_hash.yml
|
190
|
+
- fixtures/vcr/Marathon/_ping/handles_incorrect_content_type.yml
|
189
191
|
- fixtures/vcr/Marathon/_ping/returns_pong.yml
|
190
192
|
- fixtures/vcr/Marathon_App/_changes/changes_the_app.yml
|
191
193
|
- fixtures/vcr/Marathon_App/_changes/fails_with_stange_attributes.yml
|
@@ -291,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
291
293
|
version: '0'
|
292
294
|
requirements: []
|
293
295
|
rubyforge_project:
|
294
|
-
rubygems_version: 2.
|
296
|
+
rubygems_version: 2.5.1
|
295
297
|
signing_key:
|
296
298
|
specification_version: 4
|
297
299
|
summary: A simple REST client for the Marathon Remote API
|