fleet-api 1.0.0 → 1.1.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: 40cafdb1518899f8d9da9e7621e01bb0b77b2282
4
- data.tar.gz: 29fdaa40bb4ff55aa9af252a2f75658d9b5d1c61
3
+ metadata.gz: e76824863766406ea4fa859149d71e42147f7509
4
+ data.tar.gz: 4fc476f3c9c283b7cc91f22f67ecb87fc8e4e6d6
5
5
  SHA512:
6
- metadata.gz: 892ebd1582a5b7a84e7460e08573962dd66cf0cd446b111403f2e4f80623ad812cf6756e84df60dc48a53060bfcdba06f3b9172010530b2cda1e32fec51c0df2
7
- data.tar.gz: 6748da6745a7a3dac060f9fbd56797cd01a91d5849da9e149bdd382373c778bd5977d8c4287c2802801f390aeee17c12cc8fd971e02efea1cb4503b02cf114d1
6
+ metadata.gz: b14298bc17e6aaf575e0fa1b7d130420c5345f808e66f38c23bb8ea9c4ee93359d4315ff13507f368825fda568016c659d587cbe0fa232fa5fe00ee89fe29971
7
+ data.tar.gz: 1fde940443cf548edd7e1255e7f654dfaffc1922fd65f13642785347b07cf8e252f4ff7551912ebc3ed1afe6ee2315554b0c2a51ef586393129a58d8dd6dbc65
data/CHANGELOG.md CHANGED
@@ -1,6 +1,16 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ 1.1.0 - 2015-02-19
5
+ ------------------
6
+
7
+ ### Added
8
+ - New submit method for submitting units without loading them
9
+
10
+ ### Fixed
11
+ - Error where units are not loaded when submitted via the load method
12
+ - Out-dated Gemfile.lock
13
+
4
14
  1.0.0 - 2015-02-17
5
15
  ------------------
6
16
 
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fleet-api (0.6.0)
4
+ fleet-api (1.1.0)
5
5
  excon (>= 0.27.4)
6
6
 
7
7
  GEM
@@ -9,7 +9,7 @@ GEM
9
9
  specs:
10
10
  diff-lcs (1.2.5)
11
11
  docile (1.1.5)
12
- excon (0.41.0)
12
+ excon (0.44.2)
13
13
  multi_json (1.10.1)
14
14
  rake (10.3.2)
15
15
  rspec (3.0.0)
data/README.md CHANGED
@@ -66,9 +66,9 @@ If you need mutiple values for a single statement (like multiple `ExecStart` ins
66
66
  }
67
67
  }
68
68
 
69
- #### Loading a Unit File
69
+ #### Submitting a Unit File
70
70
 
71
- Equivalent of `fleetctl load`:
71
+ Equivalent of `fleetctl submit`:
72
72
 
73
73
  service = {
74
74
  'Unit' => {
@@ -80,9 +80,16 @@ Equivalent of `fleetctl load`:
80
80
  }
81
81
 
82
82
  client = Fleet.new
83
- client.load('forever.service', service)
83
+ client.submit('forever.service', service)
84
84
 
85
- Note that the name you pass-in as the first parameter to the `.load` method should end in ".service"
85
+ Note that the name you pass-in as the first parameter to the `.submit` method should end in ".service"
86
+
87
+ #### Loading a Unit File
88
+
89
+ Equivalent of `fleetctl load`:
90
+
91
+ client = Fleet.new
92
+ client.load('forever.service')
86
93
 
87
94
  #### Starting a Service
88
95
 
data/lib/fleet/client.rb CHANGED
@@ -44,25 +44,30 @@ module Fleet
44
44
  end
45
45
  end
46
46
 
47
- def load(name, service_def=nil)
47
+ def submit(name, service_def)
48
48
 
49
49
  unless name =~ /\A[a-zA-Z0-9:_.@-]+\Z/
50
50
  raise ArgumentError, 'name may only contain [a-zA-Z0-9:_.@-]'
51
51
  end
52
52
 
53
+ unless service_def.is_a?(ServiceDefinition)
54
+ service_def = ServiceDefinition.new(service_def)
55
+ end
56
+
57
+ begin
58
+ create_unit(name, service_def.to_unit(name))
59
+ rescue Fleet::PreconditionFailed
60
+ end
61
+ end
62
+
63
+ def load(name, service_def=nil)
64
+
53
65
  if service_def
54
- unless service_def.is_a?(ServiceDefinition)
55
- service_def = ServiceDefinition.new(service_def)
56
- end
57
-
58
- begin
59
- create_unit(name, service_def.to_unit(name))
60
- rescue Fleet::PreconditionFailed
61
- end
62
- else
63
- opts = { 'desiredState' => 'loaded', 'name' => name }
64
- update_unit(name, opts)
66
+ submit(name, service_def)
65
67
  end
68
+
69
+ opts = { 'desiredState' => 'loaded', 'name' => name }
70
+ update_unit(name, opts)
66
71
  end
67
72
 
68
73
  def start(name)
data/lib/fleet/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Fleet
2
- VERSION = '1.0.0'.freeze unless defined?(Fleet::VERSION)
2
+ VERSION = '1.1.0'.freeze unless defined?(Fleet::VERSION)
3
3
  end
@@ -77,83 +77,98 @@ describe Fleet::Client do
77
77
  end
78
78
  end
79
79
 
80
- describe '#load' do
81
-
80
+ describe '#submit' do
82
81
  let(:name) { 'foo.service' }
83
82
  let(:service_def) { { 'Unit' => { 'Description' => 'bar' } } }
84
83
  let(:sd) { Fleet::ServiceDefinition.new(service_def) }
85
84
  let(:response) { double(:response) }
86
85
 
87
- context 'when a service definition is provided' do
88
- before do
89
- allow(subject).to receive(:create_unit).and_return(response)
90
- allow(Fleet::ServiceDefinition).to receive(:new).and_return(sd)
91
- end
86
+ before do
87
+ allow(subject).to receive(:create_unit).and_return(response)
88
+ allow(Fleet::ServiceDefinition).to receive(:new).and_return(sd)
89
+ end
92
90
 
93
- it 'invokes #create_unit' do
94
- expect(subject).to receive(:create_unit)
95
- .with(name, sd.to_unit(name))
91
+ it 'invokes #create_unit' do
92
+ expect(subject).to receive(:create_unit)
93
+ .with(name, sd.to_unit(name))
96
94
 
97
- subject.load(name, service_def)
95
+ subject.submit(name, service_def)
96
+ end
97
+
98
+ it 'returns the #create_unit response' do
99
+ r = subject.submit(name, service_def)
100
+ expect(r).to eq response
101
+ end
102
+
103
+ context 'when #create_unit raises PreconditionFailed' do
104
+
105
+ before do
106
+ allow(subject).to receive(:create_unit)
107
+ .and_raise(Fleet::PreconditionFailed.new('boom'))
98
108
  end
99
109
 
100
- it 'returns the #create_unit response' do
101
- r = subject.load(name, service_def)
102
- expect(r).to eq response
110
+ it 'does not blow up' do
111
+ expect { subject.submit(name, service_def) }.to_not raise_error
103
112
  end
113
+ end
104
114
 
105
- context 'when #create_unit raises PreconditionFailed' do
115
+ context 'when #create_unit raises something other than PreconditionFailed' do
106
116
 
107
- before do
108
- allow(subject).to receive(:create_unit)
109
- .and_raise(Fleet::PreconditionFailed.new('boom'))
110
- end
117
+ before do
118
+ allow(subject).to receive(:create_unit)
119
+ .and_raise(Fleet::BadRequest.new('boom'))
120
+ end
111
121
 
112
- it 'does not blow up' do
113
- expect { subject.load(name, service_def) }.to_not raise_error
114
- end
122
+ it 'propagates the error' do
123
+ expect { subject.submit(name, service_def) }.to(raise_error(Fleet::BadRequest))
115
124
  end
125
+ end
116
126
 
117
- context 'when #create_unit raises something other than PreconditionFailed' do
127
+ context 'when the supplied name is invalid' do
118
128
 
119
- before do
120
- allow(subject).to receive(:create_unit)
121
- .and_raise(Fleet::BadRequest.new('boom'))
122
- end
129
+ let(:name) { 'foo!.service' }
123
130
 
124
- it 'propagates the error' do
125
- expect { subject.load(name, service_def) }.to(raise_error(Fleet::BadRequest))
126
- end
131
+ it 'raises an ArgumentError' do
132
+ expect { subject.submit(name, nil) }.to raise_error(ArgumentError, /only contain/)
127
133
  end
128
134
  end
135
+ end
129
136
 
130
- context 'when no service definition is provided' do
137
+ describe '#load' do
131
138
 
132
- before do
133
- allow(subject).to receive(:update_unit).and_return(response)
134
- end
139
+ let(:name) { 'foo.service' }
140
+ let(:response) { double(:response) }
135
141
 
136
- it 'does NOT invoke #create_unit' do
137
- expect(subject).to_not receive(:create_unit)
138
- subject.load(name)
139
- end
142
+ before do
143
+ allow(subject).to receive(:update_unit).and_return(response)
144
+ end
140
145
 
141
- it 'invokes #update' do
142
- expect(subject).to receive(:update_unit)
143
- .with(name, { 'desiredState' => 'loaded', 'name' => name })
146
+ it 'does NOT invoke #submit' do
147
+ expect(subject).not_to receive(:submit)
148
+ subject.load(name)
149
+ end
144
150
 
145
- subject.load(name)
146
- end
151
+ it 'invokes #update' do
152
+ expect(subject).to receive(:update_unit)
153
+ .with(name, { 'desiredState' => 'loaded', 'name' => name })
154
+
155
+ subject.load(name)
147
156
  end
148
157
 
149
- context 'when the supplied name is invalid' do
158
+ context 'when a service definition is provided' do
150
159
 
151
- let(:name) { 'foo!.service' }
160
+ let(:service_def) { { 'Unit' => { 'Description' => 'bar' } } }
152
161
 
153
- it 'raises an ArgumentError' do
154
- expect { subject.load(name, nil) }.to raise_error(ArgumentError, /only contain/)
162
+ before do
163
+ allow(subject).to receive(:submit)
164
+ end
165
+
166
+ it 'invokes #load' do
167
+ expect(subject).to receive(:submit)
168
+ subject.load(name, service_def)
155
169
  end
156
170
  end
171
+
157
172
  end
158
173
 
159
174
  describe '#start' do
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.0.0
4
+ version: 1.1.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-02-17 00:00:00.000000000 Z
11
+ date: 2015-02-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon