marathon-api 2.1.0 → 2.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: fbb0e48998c8f3c64b8002009bdba92f13aea4e8
4
- data.tar.gz: 19ba1b91937a2455bc175da83552c5ce0f2455f3
3
+ metadata.gz: 1706cc80987ace99626068137b1f7bea726c7bb9
4
+ data.tar.gz: 87571a9f41049b0c042ed7adc8f519fa3cc7958d
5
5
  SHA512:
6
- metadata.gz: f41e51ef482f0a041b13efac4b7d47549419dc29ad8f021bc6e6f426da993d3d29ceaddc73263beeb3c7d312156bbba3a55266d61ce57b93eb0b4fcd7495c6be
7
- data.tar.gz: 2c3497dae1b201f45df830c74fc781824b31ff7514b2de7a870942c4d4f6f15d5b898e2b1fee8cb627bad3805f132df6cfa6577ff7ad00820b7a94f4c1c68315
6
+ metadata.gz: 35be5caa1de1d2b6d5140f548d417cc88610f1b5fe38d652b4011d223168736163c9da34483a460fb729c0a4dcfd7619670e50c998d430bfbdf7f8cd3eed3477
7
+ data.tar.gz: 63bfa8546577bea9680fc945ccdd4629e418f46530193e0a4617b1a0a17e76385413b00c0b98f95cf66838ae96b3d9d44a56433f08701d34843f5ec2b4724272
@@ -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
@@ -41,7 +41,12 @@ module Marathon
41
41
  end
42
42
 
43
43
  def ping
44
- connection.get('/ping')
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
@@ -8,8 +8,7 @@ class Marathon::App < Marathon::Base
8
8
 
9
9
  DEFAULTS = {
10
10
  :env => {},
11
- :labels => {},
12
- :ports => [],
11
+ :labels => {}
13
12
  }
14
13
 
15
14
  attr_reader :healthChecks, :constraints, :container, :read_only, :tasks
@@ -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
- response.parsed_response
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
@@ -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
@@ -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.
@@ -1,3 +1,3 @@
1
1
  module Marathon
2
- VERSION = '2.1.0'
2
+ VERSION = '2.2.0'
3
3
  end
@@ -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":{},"ports":[],"id":"/app/foo"}'
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 => {}, :ports => [], :id => "/app/foo"},
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 => {}, :ports => [], :id => "/app/foo"},
168
+ {:env => {}, :labels => {}, :id => "/app/foo"},
169
169
  false
170
170
  )
171
171
  @subject.start!
@@ -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
 
@@ -91,5 +91,9 @@ describe Marathon do
91
91
  it 'returns pong' do
92
92
  ping.should == "pong\n"
93
93
  end
94
+
95
+ it 'handles incorrect content type' do
96
+ ping.should =~ /pong/
97
+ end
94
98
  end
95
99
  end
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.1.0
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: 2017-01-13 00:00:00.000000000 Z
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.4.8
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