fleet-api 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +5 -1
- data/circle.yml +13 -0
- data/lib/fleet/request.rb +16 -2
- data/lib/fleet/version.rb +1 -1
- data/spec/fleet/request_spec.rb +26 -4
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 432b71f5c32088d0776432ac6b6461e6572a1b8e
|
4
|
+
data.tar.gz: 95f6d020f76071b07ef7588286f1b17ec1ae96c9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 813b9b6a98b6bbbddd0147339712b2d1487240a730be884f620572f896f91063ce48a0532173c4553c7e078ec13a1d0f6c1d39b6fffa2b5e2226ea6253b9efe1
|
7
|
+
data.tar.gz: a1c4e1e8c50f5edb6a7ae2b64cf166bd39fc0b1ab3ed5f079c2ce106b5d76c7e29ee5f486a948913ecb8212ced0fa941970575c51cde0420cd27a5206debddd5
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -2,12 +2,16 @@ fleet-api
|
|
2
2
|
=========
|
3
3
|
|
4
4
|
[![Gem Version](https://badge.fury.io/rb/fleet-api.svg)](http://badge.fury.io/rb/fleet-api)
|
5
|
-
[![
|
5
|
+
[![Circle CI](https://circleci.com/gh/CenturyLinkLabs/fleet-api.svg?style=svg)](https://circleci.com/gh/CenturyLinkLabs/fleet-api)
|
6
6
|
|
7
7
|
Provides a Ruby wrapper around the CoreOS Fleet API.
|
8
8
|
|
9
9
|
The client allows programmatic access to most of the *fleetctl* commands including the ability to load, start, stop, unload and destroy unit files.
|
10
10
|
|
11
|
+
**Important Note:** As of version 1.0.0, this gem is now using the official Fleet REST API. Previous versions of this gem communicated with Fleet by reading/writing directly from/to the etcd key-value store. While this approach was functional, it was extremely brittle due to the fact that we were essentially using a private API. Now that the Fleet API has hit version 1.0 and is presumably stable it makes more sense to leverage the official API.
|
12
|
+
|
13
|
+
Users migrating from an older version of the Gem will simply need to make sure they configure it with the Fleet API endpoint instead of the etcd API endpoint.
|
14
|
+
|
11
15
|
### Installation
|
12
16
|
|
13
17
|
Install the gem directly:
|
data/circle.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
dependencies:
|
2
|
+
override:
|
3
|
+
- 'rvm-exec 1.9.3 bundle install'
|
4
|
+
- 'rvm-exec 2.0.0 bundle install'
|
5
|
+
- 'rvm-exec 2.1.5 bundle install'
|
6
|
+
- 'rvm-exec 2.2.0 bundle install'
|
7
|
+
|
8
|
+
test:
|
9
|
+
override:
|
10
|
+
- 'rvm-exec 1.9.3 bundle exec rake'
|
11
|
+
- 'rvm-exec 2.0.0 bundle exec rake'
|
12
|
+
- 'rvm-exec 2.1.5 bundle exec rake'
|
13
|
+
- 'rvm-exec 2.2.0 bundle exec rake'
|
data/lib/fleet/request.rb
CHANGED
@@ -13,6 +13,22 @@ module Fleet
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def request(connection, method, path, options)
|
16
|
+
response = perform_request(connection, method, path, options)
|
17
|
+
return response if method != :get
|
18
|
+
|
19
|
+
next_page_token = response.delete('nextPageToken')
|
20
|
+
while next_page_token
|
21
|
+
next_options = options.merge('nextPageToken' => next_page_token)
|
22
|
+
next_response = perform_request(connection, method, path, next_options)
|
23
|
+
next_page_token = next_response.delete('nextPageToken')
|
24
|
+
next_response.each { |k, v| response[k] += v }
|
25
|
+
end
|
26
|
+
response
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def perform_request(connection, method, path, options)
|
16
32
|
req = {
|
17
33
|
path: escape_path(path),
|
18
34
|
}
|
@@ -41,8 +57,6 @@ module Fleet
|
|
41
57
|
raise Fleet::ConnectionError, ex.message
|
42
58
|
end
|
43
59
|
|
44
|
-
private
|
45
|
-
|
46
60
|
def escape_path(path)
|
47
61
|
URI.escape(path).gsub(/@/, '%40')
|
48
62
|
end
|
data/lib/fleet/version.rb
CHANGED
data/spec/fleet/request_spec.rb
CHANGED
@@ -34,6 +34,28 @@ describe Fleet::Request do
|
|
34
34
|
expect(subject.send(:get, path, options)).to eq('name' => 'foo')
|
35
35
|
end
|
36
36
|
|
37
|
+
context 'when there is pagination' do
|
38
|
+
let(:first_response) do
|
39
|
+
double(:first_response, body: '{"things":[{"name":"foo"}], "nextPageToken":"123"}', status: 200)
|
40
|
+
end
|
41
|
+
let(:second_response) do
|
42
|
+
double(:second_response, body: '{"things":[{"name":"bah"}], "nextPageToken":"456"}', status: 200)
|
43
|
+
end
|
44
|
+
let(:third_response) do
|
45
|
+
double(:second_response, body: '{"things":[{"name":"tah"}]}', status: 200)
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'merges the responses' do
|
49
|
+
expect(connection).to receive(:send).with(:get, anything).and_return(first_response)
|
50
|
+
expect(connection).to receive(:send).with(:get, hash_including(query: { 'nextPageToken' => '123' })).and_return(second_response)
|
51
|
+
expect(connection).to receive(:send).with(:get, hash_including(query: {'nextPageToken' => '456'})).and_return(third_response)
|
52
|
+
|
53
|
+
expect(subject.send(:get, path)).to eql(
|
54
|
+
'things' => [{ 'name' => 'foo' }, { 'name' => 'bah' }, { 'name' => 'tah' }]
|
55
|
+
)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
37
59
|
context 'when there is a SocketError' do
|
38
60
|
before do
|
39
61
|
allow(connection).to receive(:send)
|
@@ -58,13 +80,13 @@ describe Fleet::Request do
|
|
58
80
|
|
59
81
|
describe '#put' do
|
60
82
|
|
61
|
-
let(:options) do
|
62
|
-
{ foo: 'bar' }
|
83
|
+
let(:options) do
|
84
|
+
{ foo: 'bar' }
|
63
85
|
end
|
64
86
|
|
65
87
|
it 'invokes #put on the connection with the correct params' do
|
66
|
-
opts = {
|
67
|
-
path: '/foo%20bar%40',
|
88
|
+
opts = {
|
89
|
+
path: '/foo%20bar%40',
|
68
90
|
headers: { 'Content-Type' => 'application/json' },
|
69
91
|
body: JSON.dump(options)
|
70
92
|
}
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fleet-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- CenturyLink
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: excon
|
@@ -95,6 +95,7 @@ files:
|
|
95
95
|
- LICENSE
|
96
96
|
- README.md
|
97
97
|
- Rakefile
|
98
|
+
- circle.yml
|
98
99
|
- fleet-api.gemspec
|
99
100
|
- lib/fleet.rb
|
100
101
|
- lib/fleet/client.rb
|