marathon_deploy 0.1.51 → 0.1.52
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 +4 -4
- data/README.md +8 -7
- data/bin/marathon_deploy +26 -19
- data/lib/marathon_deploy/marathon_defaults.rb +13 -12
- data/lib/marathon_deploy/version.rb +1 -1
- 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: a265f5dc795bc51e9c035966521634822beb2fc9
|
|
4
|
+
data.tar.gz: 00e27a266c4d60bd58d47a1a494851067b29f34a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 75def4b7aa80d74ba68280f08a9fc1ffe94333f1b50f6c36c792223093a78ba4e62e560f76ea210ac61cee72c4d2c4b513a9472a5e5168cd8b9842a28f1675aa
|
|
7
|
+
data.tar.gz: c10a6e7281e272d6126440e2cd6649c7bc672751e3163fbecfb55c1212e5863ee21ee28716f702729d71137f225b7d02457051dea27a3796cc4f7ffb87d5e023
|
data/README.md
CHANGED
|
@@ -42,13 +42,14 @@ Executables from this gem:
|
|
|
42
42
|
```
|
|
43
43
|
>marathon_deploy -h
|
|
44
44
|
Usage: bin/marathon_deploy [options]
|
|
45
|
-
-u, --url MARATHON_URL(S)
|
|
46
|
-
-l, --logfile LOGFILE
|
|
47
|
-
-d, --debug
|
|
48
|
-
-v, --version
|
|
49
|
-
-f, --force
|
|
50
|
-
-n, --noop
|
|
51
|
-
-
|
|
45
|
+
-u, --url MARATHON_URL(S) Default: ["http://localhost:8080"]
|
|
46
|
+
-l, --logfile LOGFILE Default: STDOUT
|
|
47
|
+
-d, --debug Run in debug mode
|
|
48
|
+
-v, --version Version info
|
|
49
|
+
-f, --force Force deployment when sending same deploy JSON to Marathon
|
|
50
|
+
-n, --noop No action. Just display what would be performed.
|
|
51
|
+
-i, --ignore-preproduction-defaults Ignores the preproduction defaults for cpu, memory, and instance limits
|
|
52
|
+
-e, --environment ENVIRONMENT Default: PREPRODUC
|
|
52
53
|
```
|
|
53
54
|
|
|
54
55
|
### Overriding configuration based on environment
|
data/bin/marathon_deploy
CHANGED
|
@@ -21,16 +21,17 @@ options[:logfile] = MarathonDeploy::MarathonDefaults::DEFAULT_LOGFILE
|
|
|
21
21
|
options[:force] = MarathonDeploy::MarathonDefaults::DEFAULT_FORCE_DEPLOY
|
|
22
22
|
options[:noop] = MarathonDeploy::MarathonDefaults::DEFAULT_NOOP
|
|
23
23
|
options[:remove_elements] = MarathonDeploy::MarathonDefaults::DEFAULT_REMOVE_ELEMENTS
|
|
24
|
+
options[:ignore_preproduction_defaults] = MarathonDeploy::MarathonDefaults::DEFAULT_IGNORE_PREPRODUCTION_DEFAULTS
|
|
24
25
|
options[:marathon_username] = nil
|
|
25
26
|
options[:marathon_password] = nil
|
|
26
|
-
|
|
27
|
-
|
|
27
|
+
|
|
28
|
+
|
|
28
29
|
OptionParser.new do |opts|
|
|
29
30
|
opts.banner = "Usage: #{$0} [options]"
|
|
30
31
|
opts.release = MarathonDeploy::VERSION
|
|
31
|
-
|
|
32
|
-
opts.on("-u","--url MARATHON_URL(S)", Array, "Default: #{options[:marathon_endpoints]}") do |u|
|
|
33
|
-
options[:marathon_endpoints] = u
|
|
32
|
+
|
|
33
|
+
opts.on("-u","--url MARATHON_URL(S)", Array, "Default: #{options[:marathon_endpoints]}") do |u|
|
|
34
|
+
options[:marathon_endpoints] = u
|
|
34
35
|
end
|
|
35
36
|
|
|
36
37
|
opts.on("-U","--username USERNAME", "Marathon authentication username") do |u|
|
|
@@ -40,15 +41,15 @@ OptionParser.new do |opts|
|
|
|
40
41
|
opts.on("-p","--password PASSWORD", "Marathon authentication password") do |p|
|
|
41
42
|
options[:marathon_password] = p
|
|
42
43
|
end
|
|
43
|
-
|
|
44
|
+
|
|
44
45
|
opts.on("-l", "--logfile LOGFILE", "Default: STDOUT") do |l|
|
|
45
|
-
options[:logfile] = l
|
|
46
|
+
options[:logfile] = l
|
|
46
47
|
end
|
|
47
|
-
|
|
48
|
+
|
|
48
49
|
opts.on("-d", "--debug", "Run in debug mode") do |d|
|
|
49
50
|
options[:debug] = Logger::DEBUG
|
|
50
51
|
end
|
|
51
|
-
|
|
52
|
+
|
|
52
53
|
opts.on("-v", "--version", "Version info") do |v|
|
|
53
54
|
puts "#{$0} version #{opts.release}"
|
|
54
55
|
exit
|
|
@@ -70,11 +71,15 @@ OptionParser.new do |opts|
|
|
|
70
71
|
options[:environment] = e
|
|
71
72
|
end
|
|
72
73
|
|
|
74
|
+
opts.on("-i", "--ignore-preproduction-defaults", "Default: #{options[:ignore_preproduction_defaults]}" ) do |i|
|
|
75
|
+
options[:ignore_preproduction_defaults] = true
|
|
76
|
+
end
|
|
77
|
+
|
|
73
78
|
opts.on_tail("-h", "--help", "Show this message") do
|
|
74
79
|
puts opts
|
|
75
80
|
puts " ----------------- Additional Info -----------------", <<-DESCRIPTION
|
|
76
81
|
* Marathon Env variables:
|
|
77
|
-
- Env variables with the prefix "#{MarathonDeploy::MarathonDefaults::ENVIRONMENT_VARIABLE_PREFIX}" will be injected into the deployment plan.
|
|
82
|
+
- Env variables with the prefix "#{MarathonDeploy::MarathonDefaults::ENVIRONMENT_VARIABLE_PREFIX}" will be injected into the deployment plan.
|
|
78
83
|
- The prefix "#{MarathonDeploy::MarathonDefaults::ENVIRONMENT_VARIABLE_PREFIX}" will be removed before being added to the marathon json payload.
|
|
79
84
|
- Example: Env variable #{MarathonDeploy::MarathonDefaults::ENVIRONMENT_VARIABLE_PREFIX}DEBUG=True with be passed as DEBUG=True to the marathon-api.
|
|
80
85
|
* Macros:
|
|
@@ -83,8 +88,8 @@ OptionParser.new do |opts|
|
|
|
83
88
|
- If any marcos are not defined by Env variables, deployment will fail.
|
|
84
89
|
DESCRIPTION
|
|
85
90
|
exit
|
|
86
|
-
end
|
|
87
|
-
|
|
91
|
+
end
|
|
92
|
+
|
|
88
93
|
end.parse!
|
|
89
94
|
|
|
90
95
|
abort("Ambiguous arguments: #{ARGV.join(',')}. Only one deploy file argument may be passed.") if (ARGV.length > 1)
|
|
@@ -97,7 +102,7 @@ if (!argfile.nil?)
|
|
|
97
102
|
elsif (File.file?(DEFAULT_DEPLOYFILE))
|
|
98
103
|
deployfile = DEFAULT_DEPLOYFILE
|
|
99
104
|
else
|
|
100
|
-
abort("No deploy file argument provided and default \'#{DEFAULT_DEPLOYFILE}\' does not exist in current directory \'#{Dir.pwd}\'")
|
|
105
|
+
abort("No deploy file argument provided and default \'#{DEFAULT_DEPLOYFILE}\' does not exist in current directory \'#{Dir.pwd}\'")
|
|
101
106
|
end
|
|
102
107
|
|
|
103
108
|
if options[:marathon_username] and options[:marathon_password]
|
|
@@ -108,9 +113,9 @@ end
|
|
|
108
113
|
$LOG = options[:logfile] ? Logger.new(options[:logfile]) : Logger.new(STDOUT)
|
|
109
114
|
$LOG.level = options[:debug]
|
|
110
115
|
|
|
111
|
-
noop = options[:noop]
|
|
116
|
+
noop = options[:noop]
|
|
112
117
|
environment = MarathonDeploy::Environment.new(options[:environment])
|
|
113
|
-
|
|
118
|
+
|
|
114
119
|
marathon_endpoints = Array.new
|
|
115
120
|
if (options[:marathon_endpoints].nil?)
|
|
116
121
|
if (environment.is_production?)
|
|
@@ -131,7 +136,7 @@ remove_elements = Array.new
|
|
|
131
136
|
eval n if not MarathonDeploy::MarathonDefaults::DEFAULT_KEEP_ELEMENTS.include? n
|
|
132
137
|
end
|
|
133
138
|
end
|
|
134
|
-
|
|
139
|
+
|
|
135
140
|
begin
|
|
136
141
|
application = MarathonDeploy::Application.new(
|
|
137
142
|
:deployfile => deployfile,
|
|
@@ -155,8 +160,10 @@ rescue MarathonDeploy::Error::BadFormatError => e
|
|
|
155
160
|
exit!
|
|
156
161
|
end
|
|
157
162
|
|
|
158
|
-
|
|
159
|
-
|
|
163
|
+
unless options[:ignore_preproduction_defaults]
|
|
164
|
+
if (!environment.is_production?)
|
|
165
|
+
application.overlay_preproduction_settings
|
|
166
|
+
end
|
|
160
167
|
end
|
|
161
168
|
|
|
162
169
|
display_msg = " MARATHON JSON DEPLOYMENT INSTRUCTIONS "
|
|
@@ -171,7 +178,7 @@ marathon_endpoints.each do |marathon_url|
|
|
|
171
178
|
next if (noop)
|
|
172
179
|
client = MarathonDeploy::MarathonClient.new(marathon_url)
|
|
173
180
|
client.application = application
|
|
174
|
-
client.deploy
|
|
181
|
+
client.deploy
|
|
175
182
|
rescue MarathonDeploy::Error::MissingMarathonAttributesError,MarathonDeploy::Error::BadURLError, Timeout::Error => e
|
|
176
183
|
$LOG.error(e.message)
|
|
177
184
|
exit!
|
|
@@ -4,7 +4,7 @@ require 'logger'
|
|
|
4
4
|
|
|
5
5
|
module MarathonDeploy
|
|
6
6
|
module MarathonDefaults
|
|
7
|
-
|
|
7
|
+
|
|
8
8
|
class << self
|
|
9
9
|
attr_accessor :marathon_username, :marathon_password
|
|
10
10
|
end
|
|
@@ -25,6 +25,7 @@ module MarathonDeploy
|
|
|
25
25
|
MARATHON_DEPLOYMENT_REST_PATH = '/v2/deployments/'
|
|
26
26
|
DEFAULT_FORCE_DEPLOY = false
|
|
27
27
|
DEFAULT_NOOP = false
|
|
28
|
+
DEFAULT_IGNORE_PREPRODUCTION_DEFAULTS = false
|
|
28
29
|
DEFAULT_REMOVE_ELEMENTS = []
|
|
29
30
|
DEFAULT_KEEP_ELEMENTS = [':id']
|
|
30
31
|
ENVIRONMENT_VARIABLE_PREFIX = 'MARATHON_DEPLOY_'
|
|
@@ -44,37 +45,37 @@ module MarathonDeploy
|
|
|
44
45
|
}
|
|
45
46
|
|
|
46
47
|
@@required_marathon_env_variables = %w[]
|
|
47
|
-
|
|
48
|
+
|
|
48
49
|
#@@required_marathon_attributes = %w[id env container healthChecks args storeUrls].map(&:to_sym)
|
|
49
50
|
@@required_marathon_attributes = %w[id].map(&:to_sym)
|
|
50
|
-
|
|
51
|
+
|
|
51
52
|
def self.missing_attributes(json)
|
|
52
53
|
json = Utils.symbolize(json)
|
|
53
54
|
missing = []
|
|
54
55
|
@@required_marathon_attributes.each do |att|
|
|
55
56
|
if (!json[att])
|
|
56
|
-
missing << att
|
|
57
|
+
missing << att
|
|
57
58
|
end
|
|
58
59
|
end
|
|
59
60
|
return missing
|
|
60
61
|
end
|
|
61
|
-
|
|
62
|
+
|
|
62
63
|
def self.missing_envs(json)
|
|
63
64
|
json = Utils.symbolize(json)
|
|
64
|
-
|
|
65
|
+
|
|
65
66
|
if (!json.key?(:env))
|
|
66
|
-
raise Error::MissingMarathonAttributesError, "no env attribute found in deployment file", caller
|
|
67
|
+
raise Error::MissingMarathonAttributesError, "no env attribute found in deployment file", caller
|
|
67
68
|
end
|
|
68
|
-
|
|
69
|
+
|
|
69
70
|
missing = []
|
|
70
71
|
@@required_marathon_env_variables.each do |variable|
|
|
71
72
|
if (!json[:env][variable])
|
|
72
|
-
missing << variable
|
|
73
|
+
missing << variable
|
|
73
74
|
end
|
|
74
75
|
end
|
|
75
76
|
return missing
|
|
76
|
-
end
|
|
77
|
-
|
|
77
|
+
end
|
|
78
|
+
|
|
78
79
|
def self.overlay_preproduction_settings(json)
|
|
79
80
|
json = Utils.deep_symbolize(json)
|
|
80
81
|
@@preproduction_override.each do |property,value|
|
|
@@ -90,6 +91,6 @@ module MarathonDeploy
|
|
|
90
91
|
end
|
|
91
92
|
return json
|
|
92
93
|
end
|
|
93
|
-
|
|
94
|
+
|
|
94
95
|
end
|
|
95
96
|
end
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: marathon_deploy
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.52
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Colby
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2017-02-03 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: logger
|