marathon-api 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/marathon/app.rb +13 -5
- data/lib/marathon/container_docker.rb +2 -1
- data/lib/marathon/version.rb +1 -1
- data/spec/marathon/app_spec.rb +14 -0
- data/spec/marathon/container_docker_spec.rb +15 -3
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bcd9ae14a3459ba8f19f3be38d2f1aa5bdb5746
|
4
|
+
data.tar.gz: d3c3091fcdc97ecab48f942588bcba2b8cdeed43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c16b9ee84d8b507a4c62c8a29b63e2922be7b519986a513b63331241b3f77a27d7d200e2c29d557a4123bb9ad44f1e9c25e64fd2fb4acc16c1610fbcd6ea8a37
|
7
|
+
data.tar.gz: 487c87de5f3a68325c8f421e4006f86f892166ce694d0c4d603cc024390e252ff2339eea2ceda78bed5893f0cb85fbbaa27c4f216c6cc8b48846abd0a331fefc
|
data/lib/marathon/app.rb
CHANGED
@@ -3,7 +3,8 @@
|
|
3
3
|
class Marathon::App < Marathon::Base
|
4
4
|
|
5
5
|
ACCESSORS = %w[ id args cmd cpus disk env executor instances mem ports requirePorts
|
6
|
-
storeUris tasksHealthy tasksUnhealthy tasksRunning tasksStaged upgradeStrategy
|
6
|
+
storeUris tasksHealthy tasksUnhealthy tasksRunning tasksStaged upgradeStrategy
|
7
|
+
uris user version labels ]
|
7
8
|
|
8
9
|
DEFAULTS = {
|
9
10
|
:env => {},
|
@@ -122,15 +123,22 @@ Instances: #{tasks.size}/#{instances}
|
|
122
123
|
Command: #{cmd}
|
123
124
|
CPUs: #{cpus}
|
124
125
|
Memory: #{mem} MB
|
125
|
-
#{
|
126
|
-
#{
|
127
|
-
#{
|
126
|
+
#{pretty_container}
|
127
|
+
#{pretty_uris}
|
128
|
+
#{pretty_env}
|
129
|
+
#{pretty_constraints}
|
128
130
|
Version: #{version}
|
129
131
|
].gsub(/\n\n+/, "\n").strip
|
130
132
|
end
|
131
133
|
|
132
134
|
private
|
133
135
|
|
136
|
+
def pretty_container
|
137
|
+
if container and container.docker
|
138
|
+
"Docker: #{container.docker.to_pretty_s}"
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
134
142
|
def pretty_env
|
135
143
|
env.map { |k,v| "ENV: #{k}=#{v}" }.join("\n")
|
136
144
|
end
|
@@ -214,7 +222,7 @@ Version: #{version}
|
|
214
222
|
def change(id, hash, force = false)
|
215
223
|
query = {}
|
216
224
|
query[:force] = true if force
|
217
|
-
json = Marathon.connection.put("/v2/apps/#{id}", query, :body => hash)
|
225
|
+
json = Marathon.connection.put("/v2/apps/#{id}", query, :body => hash.merge(:id => id))
|
218
226
|
Marathon::DeploymentInfo.new(json)
|
219
227
|
end
|
220
228
|
|
@@ -2,7 +2,7 @@
|
|
2
2
|
# See https://mesosphere.github.io/marathon/docs/native-docker.html for full details.
|
3
3
|
class Marathon::ContainerDocker < Marathon::Base
|
4
4
|
|
5
|
-
ACCESSORS = %w[ image network ]
|
5
|
+
ACCESSORS = %w[ image network privileged parameters ]
|
6
6
|
DEFAULTS = {
|
7
7
|
:network => 'BRIDGE',
|
8
8
|
:portMappings => []
|
@@ -15,6 +15,7 @@ class Marathon::ContainerDocker < Marathon::Base
|
|
15
15
|
def initialize(hash)
|
16
16
|
super(Marathon::Util.merge_keywordized_hash(DEFAULTS, hash), ACCESSORS)
|
17
17
|
Marathon::Util.validate_choice('network', network, %w[BRIDGE HOST])
|
18
|
+
Marathon::Util.validate_choice('privileged', privileged, ['true', 'false', true, false])
|
18
19
|
raise Marathon::Error::ArgumentError, 'image must not be nil' unless image
|
19
20
|
@portMappings = (info[:portMappings] || []).map { |e| Marathon::ContainerDockerPortMapping.new(e) }
|
20
21
|
end
|
data/lib/marathon/version.rb
CHANGED
data/spec/marathon/app_spec.rb
CHANGED
@@ -7,6 +7,9 @@ describe Marathon::App do
|
|
7
7
|
'id' => '/app/foo',
|
8
8
|
'instances' => 1,
|
9
9
|
'tasks' => [],
|
10
|
+
'container' => {
|
11
|
+
:type => 'DOCKER', 'docker' => { 'image' => 'foo/bar:latest' },
|
12
|
+
},
|
10
13
|
'env' => {'FOO' => 'BAR', 'blubb' => 'blah'},
|
11
14
|
'constraints' => [['hostname', 'UNIQUE']],
|
12
15
|
'uris' => ['http://example.com/big.tar'],
|
@@ -23,6 +26,7 @@ describe Marathon::App do
|
|
23
26
|
"Command: \n" + \
|
24
27
|
"CPUs: \n" + \
|
25
28
|
"Memory: MB\n" + \
|
29
|
+
"Docker: foo/bar:latest\n" + \
|
26
30
|
"URI: http://example.com/big.tar\n" + \
|
27
31
|
"ENV: FOO=BAR\n" + \
|
28
32
|
"ENV: blubb=blah\n" + \
|
@@ -72,6 +76,16 @@ describe Marathon::App do
|
|
72
76
|
end
|
73
77
|
end
|
74
78
|
|
79
|
+
describe '#labels' do
|
80
|
+
subject { described_class.new({ 'id' => '/ubuntu2', 'labels' => { 'env'=>'abc','xyz'=>'123'}}) }
|
81
|
+
|
82
|
+
it 'has labels' do
|
83
|
+
expect(subject.labels).to be_instance_of(Hash)
|
84
|
+
puts subject.labels
|
85
|
+
expect(subject.labels).to have_key(:env)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
75
89
|
describe '#constraints' do
|
76
90
|
subject { described_class.new({ 'id' => '/ubuntu2', 'healthChecks' => [{ 'path' => '/ping' }] }) }
|
77
91
|
|
@@ -1,8 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
CONTAINER_DOCKER_EXAMPLE = {
|
4
|
-
:network
|
5
|
-
:image
|
4
|
+
:network => 'HOST',
|
5
|
+
:image => 'felixb/yocto-httpd',
|
6
|
+
:privileged => false
|
6
7
|
}
|
7
8
|
|
8
9
|
describe Marathon::ContainerDocker do
|
@@ -26,6 +27,17 @@ describe Marathon::ContainerDocker do
|
|
26
27
|
|
27
28
|
its(:network) { should == 'HOST' }
|
28
29
|
its(:image) { should == 'felixb/yocto-httpd' }
|
30
|
+
its(:portMappings){ should == [] }
|
31
|
+
its(:privileged){ should == false}
|
32
|
+
end
|
33
|
+
describe '#privileged' do
|
34
|
+
subject { described_class.new({
|
35
|
+
:network => 'HOST',
|
36
|
+
:image => 'felixb/yocto-httpd',
|
37
|
+
:privileged => true
|
38
|
+
})
|
39
|
+
}
|
40
|
+
its(:privileged){ should == true}
|
29
41
|
end
|
30
42
|
|
31
43
|
describe '#to_s' do
|
@@ -39,4 +51,4 @@ describe Marathon::ContainerDocker do
|
|
39
51
|
its(:to_pretty_s) { should == 'felixb/yocto-httpd' }
|
40
52
|
end
|
41
53
|
|
42
|
-
end
|
54
|
+
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.2.
|
4
|
+
version: 1.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Felix Bechstein
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-06-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|