marathon-api 1.3.5 → 1.3.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5ec756f5d2eb488416f50de1d83bb181091dd46b
4
- data.tar.gz: 6ea47852e64d444617cf19028c9aff59cedd845e
3
+ metadata.gz: 9654134c87faac00b19343eb041d4c7be5bafe14
4
+ data.tar.gz: d81dc5a1dc3955ec339d32cfe39f1e18f85cd876
5
5
  SHA512:
6
- metadata.gz: 3c49001387c2b89593d22021c8f1522bbf8477e36a6072063ee8fcaa4eac7c356c3492fd2e7edbe1e88797bfefe678ece2ee6428e1fa95a1be51bfa82f4f41ba
7
- data.tar.gz: a3ec6efa4bb735d095f5da81c550291bc865d7aef29025040b0658592b6c21e76558d1a72c9d5d339fc5335569db4c969da5975b8f4797ef78c24acbe5c49253
6
+ metadata.gz: 4f1233cc97367d154e742a0d72fb333f117e123eefc7145be68f740bd4733e8396584f6db6a97b0d5a1d21d7a873fb2e4a3e79ddd9f0776be572b02d67c00af4
7
+ data.tar.gz: 932fb164588d973f55ea9e0d472fc5a50ade3014d8fadbb3deaaae8ad1b604e015b61959ee1c8b33b97f3d42f9ba8a040b5baeff741c7d377bc0e4b089d0b455
@@ -4,7 +4,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'maratho
4
4
  require 'trollop'
5
5
  require 'json'
6
6
 
7
- SUB_COMMANDS = %w[kill kill_tasks start scale list list_tasks]
7
+ SUB_COMMANDS = %w[kill kill_tasks start scale rollback list list_tasks]
8
8
  ATTRIBUTES = [:id, :cmd, :executor, :instances, :cpus, :mem, :uris]
9
9
  DEFAULT_APP_OPTS = {
10
10
  :instances => 1,
@@ -121,6 +121,23 @@ def subcmd_kill_tasks(cmd_opts)
121
121
  print_tasks(tasks)
122
122
  end
123
123
 
124
+ def subcmd_rollback(cmd_opts)
125
+ app = Marathon::App.get(cmd_opts[:id])
126
+ # Get current versions
127
+ versions = app.versions
128
+ # Retrieve N-1 version if none given
129
+ target = cmd_opts[:version_id] ? cmd_opts[:version_id] : versions[1]
130
+ # Deploy the target version of the app
131
+ puts "Rollback app '#{app.id}' from #{versions[0]} to #{target}"
132
+ app.roll_back!(target, cmd_opts[:force])
133
+ rescue Marathon::Error::MarathonError => e
134
+ puts "#{e.class}: #{e.message}"
135
+ exit 1
136
+ rescue TimeoutError => e
137
+ puts "Deployment took too long"
138
+ exit 1
139
+ end
140
+
124
141
  # parse global options
125
142
  def parse_global_opts
126
143
  global_opts = Trollop.options do
@@ -134,6 +151,7 @@ Available commands:
134
151
  kill_tasks Kill a task or tasks belonging to a specified app.
135
152
  list Show a list of running apps and their options.
136
153
  list_tasks Show a list of an app's running tasks.
154
+ rollback Rollback an app to a specific version.
137
155
  scale Scale the number of app instances.
138
156
  start Start a new app.
139
157
 
@@ -201,6 +219,12 @@ def parse_subcmd_opts(cmd)
201
219
  opt :sync, 'Wait for the deployment to finish', :short => '-s'
202
220
  opt :timeout, 'Timout for sync call in seconds (default 60).', :type => Integer, :short => '-t'
203
221
  end
222
+ when 'rollback'
223
+ Trollop.options do
224
+ opt :id, 'A unique identifier for the app.', :short => '-i', :type => String, :required => true
225
+ opt :version_id, 'A version identifier.', :short => '-v', :type => String, :default => nil
226
+ opt :force, 'The current deployment can be overridden by setting the `force`.', :short => '-f'
227
+ end
204
228
  when 'kill'
205
229
  Trollop.options do
206
230
  opt :id, 'A unique identifier for the app.', :short => '-i', :type => String, :required => true
@@ -238,6 +262,8 @@ def run_subcmd(cmd, cmd_opts)
238
262
  subcmd_list_tasks(cmd_opts)
239
263
  when 'kill_tasks'
240
264
  subcmd_kill_tasks(cmd_opts)
265
+ when 'rollback'
266
+ subcmd_rollback(cmd_opts)
241
267
  else
242
268
  Trollop.die "unknown subcommand #{cmd.inspect}"
243
269
  end
@@ -16,8 +16,6 @@ class Marathon::ContainerVolume < Marathon::Base
16
16
  raise Marathon::Error::ArgumentError, 'containerPath must be an absolute path' \
17
17
  unless Pathname.new(containerPath).absolute?
18
18
  raise Marathon::Error::ArgumentError, 'hostPath must not be nil' unless hostPath
19
- raise Marathon::Error::ArgumentError, 'hostPath must be an absolute path' \
20
- unless Pathname.new(hostPath).absolute?
21
19
  end
22
20
 
23
21
  def to_pretty_s
@@ -28,4 +26,4 @@ class Marathon::ContainerVolume < Marathon::Base
28
26
  "Marathon::ContainerVolume { :containerPath => #{containerPath} :hostPath => #{hostPath} :mode => #{mode} }"
29
27
  end
30
28
 
31
- end
29
+ end
@@ -1,3 +1,3 @@
1
1
  module Marathon
2
- VERSION = '1.3.5'
2
+ VERSION = '1.3.6'
3
3
  end
@@ -24,7 +24,7 @@ Gem::Specification.new do |gem|
24
24
  gem.add_development_dependency 'rspec', '~> 3.0'
25
25
  gem.add_development_dependency 'rspec-its'
26
26
  gem.add_development_dependency 'vcr', '>= 2.7.0'
27
- gem.add_development_dependency 'webmock'
27
+ gem.add_development_dependency 'webmock', '< 2.0.0'
28
28
  gem.add_development_dependency 'pry'
29
29
  gem.add_development_dependency 'cane'
30
30
  gem.add_development_dependency 'simplecov'
@@ -19,12 +19,8 @@ describe Marathon::ContainerVolume do
19
19
  it 'should fail with invalid path' do
20
20
  expect { subject.new(:hostPath => '/') }
21
21
  .to raise_error(Marathon::Error::ArgumentError, /containerPath .* not be nil/)
22
- expect { subject.new(:containerPath => 'foo', :hostPath => '/') }
23
- .to raise_error(Marathon::Error::ArgumentError, /containerPath .* absolute path/)
24
22
  expect { subject.new(:containerPath => '/') }
25
23
  .to raise_error(Marathon::Error::ArgumentError, /hostPath .* not be nil/)
26
- expect { subject.new(:containerPath => '/', :hostPath => 'foo') }
27
- .to raise_error(Marathon::Error::ArgumentError, /hostPath .* absolute path/)
28
24
  end
29
25
  end
30
26
 
@@ -47,4 +43,4 @@ describe Marathon::ContainerVolume do
47
43
  its(:to_pretty_s) { should == '/data:/var/opt/foo:RO' }
48
44
  end
49
45
 
50
- end
46
+ 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: 1.3.5
4
+ version: 1.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felix Bechstein
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-04 00:00:00.000000000 Z
11
+ date: 2016-06-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -112,16 +112,16 @@ dependencies:
112
112
  name: webmock
113
113
  requirement: !ruby/object:Gem::Requirement
114
114
  requirements:
115
- - - ">="
115
+ - - "<"
116
116
  - !ruby/object:Gem::Version
117
- version: '0'
117
+ version: 2.0.0
118
118
  type: :development
119
119
  prerelease: false
120
120
  version_requirements: !ruby/object:Gem::Requirement
121
121
  requirements:
122
- - - ">="
122
+ - - "<"
123
123
  - !ruby/object:Gem::Version
124
- version: '0'
124
+ version: 2.0.0
125
125
  - !ruby/object:Gem::Dependency
126
126
  name: pry
127
127
  requirement: !ruby/object:Gem::Requirement