marathon_deploy 0.1.47 → 0.1.48
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 +8 -8
- data/bin/marathon_deploy +15 -0
- data/lib/marathon_deploy/http_util.rb +24 -48
- data/lib/marathon_deploy/marathon_defaults.rb +6 -0
- data/lib/marathon_deploy/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
OGJjNGVjMmZjN2M3MDU5ZTY4MWYxOWEyN2M3MDk2NGM2NDIyYjMzOQ==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
NDliMzdkMWNiY2ZhZTk4ZTcwOTc2NjY3NTZiYzZiMWZkMTA3ZTQ5MA==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
NGI2ZDY3ZDhiNGQ5MGYyM2U4ZGJkODc2MDhiN2MwMWI4YTkwMThhOGJkZmZm
|
|
10
|
+
NDNkYWEwZTEzZGMyODA2OWY4ZjA0MTIzNzkwOGJhYTdkZTNlMGMwZDY5NTgw
|
|
11
|
+
NTJkNzYwZmUwN2U0NmFlOTQzMjVmYjNmZTMwYTRhNTU4ZjRiMzA=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
N2YzNTlhZTA0YjhmMDc3ZmMyN2E0ODRjNDBkMzNmOTllMGVhYTYxZTk3NjAx
|
|
14
|
+
ODllZjk1OWQ5YzA3YWNmYzZjMGY0ZmZkYjM5OWIxMmY2ZmU5MzAyNzUzYzhl
|
|
15
|
+
NDUxYmJmYjE1YmUxODcyODdiYmIzOTRmYTk5YTQ0NTViMmVlM2U=
|
data/bin/marathon_deploy
CHANGED
|
@@ -21,6 +21,8 @@ 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[:marathon_username] = nil
|
|
25
|
+
options[:marathon_password] = nil
|
|
24
26
|
|
|
25
27
|
|
|
26
28
|
OptionParser.new do |opts|
|
|
@@ -30,6 +32,14 @@ OptionParser.new do |opts|
|
|
|
30
32
|
opts.on("-u","--url MARATHON_URL(S)", Array, "Default: #{options[:marathon_endpoints]}") do |u|
|
|
31
33
|
options[:marathon_endpoints] = u
|
|
32
34
|
end
|
|
35
|
+
|
|
36
|
+
opts.on("-U","--username USERNAME", "Marathon authentication username") do |u|
|
|
37
|
+
options[:marathon_username] = u
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
opts.on("-p","--password PASSWORD", "Marathon authentication password") do |p|
|
|
41
|
+
options[:marathon_password] = p
|
|
42
|
+
end
|
|
33
43
|
|
|
34
44
|
opts.on("-l", "--logfile LOGFILE", "Default: STDOUT") do |l|
|
|
35
45
|
options[:logfile] = l
|
|
@@ -90,6 +100,11 @@ else
|
|
|
90
100
|
abort("No deploy file argument provided and default \'#{DEFAULT_DEPLOYFILE}\' does not exist in current directory \'#{Dir.pwd}\'")
|
|
91
101
|
end
|
|
92
102
|
|
|
103
|
+
if options[:marathon_username] and options[:marathon_password]
|
|
104
|
+
MarathonDeploy::MarathonDefaults::marathon_username = options[:marathon_username]
|
|
105
|
+
MarathonDeploy::MarathonDefaults::marathon_password = options[:marathon_password]
|
|
106
|
+
end
|
|
107
|
+
|
|
93
108
|
$LOG = options[:logfile] ? Logger.new(options[:logfile]) : Logger.new(STDOUT)
|
|
94
109
|
$LOG.level = options[:debug]
|
|
95
110
|
|
|
@@ -10,39 +10,41 @@ module MarathonDeploy
|
|
|
10
10
|
@@og_timeout = 60.0
|
|
11
11
|
@@rg_timeout = 60.0
|
|
12
12
|
|
|
13
|
-
def self.
|
|
13
|
+
def self.req(method, url, payload=nil, errors_are_fatal=false)
|
|
14
14
|
uri = construct_uri url
|
|
15
15
|
begin
|
|
16
16
|
http = Net::HTTP.new(uri.host, uri.port)
|
|
17
|
+
http.use_ssl = uri.scheme == 'https'
|
|
17
18
|
http.open_timeout = @@o_timeout
|
|
18
19
|
http.read_timeout = @@r_timeout
|
|
19
|
-
req = Net::HTTP
|
|
20
|
-
|
|
20
|
+
req = Net::HTTP.const_get(method).new(uri.request_uri)
|
|
21
|
+
if MarathonDeploy::MarathonDefaults::marathon_username and MarathonDeploy::MarathonDefaults::marathon_password
|
|
22
|
+
req.basic_auth(MarathonDeploy::MarathonDefaults::marathon_username, MarathonDeploy::MarathonDefaults::marathon_password)
|
|
23
|
+
end
|
|
24
|
+
if payload
|
|
25
|
+
req.body = payload.to_json
|
|
26
|
+
end
|
|
21
27
|
req["Content-Type"] = "application/json"
|
|
22
28
|
response = http.request(req)
|
|
23
29
|
rescue Exception => e
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
if errors_are_fatal
|
|
31
|
+
$LOG.error("Error calling marathon api: #{e.message}")
|
|
32
|
+
exit!
|
|
33
|
+
else
|
|
34
|
+
message = "Error calling marathon api: #{e.message}"
|
|
35
|
+
$LOG.error(message)
|
|
36
|
+
raise Error::MarathonError, message, caller
|
|
37
|
+
end
|
|
26
38
|
end
|
|
27
39
|
return response
|
|
28
40
|
end
|
|
41
|
+
|
|
42
|
+
def self.put(url,payload)
|
|
43
|
+
return self.req('Put', url, payload, true)
|
|
44
|
+
end
|
|
29
45
|
|
|
30
46
|
def self.post(url, payload)
|
|
31
|
-
|
|
32
|
-
begin
|
|
33
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
|
34
|
-
http.open_timeout = @@o_timeout
|
|
35
|
-
http.read_timeout = @@r_timeout
|
|
36
|
-
req = Net::HTTP::Post.new(uri.request_uri)
|
|
37
|
-
req.body = payload.to_json
|
|
38
|
-
req["Content-Type"] = "application/json"
|
|
39
|
-
response = http.request(req)
|
|
40
|
-
rescue Exception => e
|
|
41
|
-
message = "Error calling marathon api: #{e.message}"
|
|
42
|
-
$LOG.error(message)
|
|
43
|
-
raise Error::MarathonError, message, caller
|
|
44
|
-
end
|
|
45
|
-
return response
|
|
47
|
+
return self.req('Post', url, payload, false)
|
|
46
48
|
end
|
|
47
49
|
|
|
48
50
|
def self.construct_uri(url)
|
|
@@ -51,19 +53,7 @@ module MarathonDeploy
|
|
|
51
53
|
end
|
|
52
54
|
|
|
53
55
|
def self.delete(url)
|
|
54
|
-
|
|
55
|
-
begin
|
|
56
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
|
57
|
-
http.open_timeout = @@o_timeout
|
|
58
|
-
http.read_timeout = @@r_timeout
|
|
59
|
-
req = Net::HTTP::Delete.new(uri.request_uri)
|
|
60
|
-
response = http.request(req)
|
|
61
|
-
rescue Exception => e
|
|
62
|
-
message = "Error calling marathon api: #{e.message}"
|
|
63
|
-
$LOG.error(message)
|
|
64
|
-
raise Error::MarathonError, message, caller
|
|
65
|
-
end
|
|
66
|
-
return response
|
|
56
|
+
return self.req('Delete', url, nil, false)
|
|
67
57
|
end
|
|
68
58
|
|
|
69
59
|
def self.clean_url(url)
|
|
@@ -71,21 +61,7 @@ module MarathonDeploy
|
|
|
71
61
|
end
|
|
72
62
|
|
|
73
63
|
def self.get(url)
|
|
74
|
-
|
|
75
|
-
begin
|
|
76
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
|
77
|
-
http.open_timeout = @@og_timeout
|
|
78
|
-
http.read_timeout = @@rg_timeout
|
|
79
|
-
# http.set_debug_output($stdout)
|
|
80
|
-
req = Net::HTTP::Get.new(uri.request_uri)
|
|
81
|
-
req["Content-Type"] = "application/json"
|
|
82
|
-
response = http.request(req)
|
|
83
|
-
rescue Exception => e
|
|
84
|
-
message = "Error calling marathon api: #{e.message}"
|
|
85
|
-
$LOG.error(message)
|
|
86
|
-
raise Error::MarathonError, message, caller
|
|
87
|
-
end
|
|
88
|
-
return response
|
|
64
|
+
return self.req('Get', url, nil, false)
|
|
89
65
|
end
|
|
90
66
|
|
|
91
67
|
def self.valid_url(url)
|
|
@@ -5,6 +5,10 @@ require 'logger'
|
|
|
5
5
|
module MarathonDeploy
|
|
6
6
|
module MarathonDefaults
|
|
7
7
|
|
|
8
|
+
class << self
|
|
9
|
+
attr_accessor :marathon_username, :marathon_password
|
|
10
|
+
end
|
|
11
|
+
|
|
8
12
|
DEPLOYMENT_RECHECK_INTERVAL = 3
|
|
9
13
|
DEPLOYMENT_TIMEOUT = 300
|
|
10
14
|
HEALTHY_WAIT_TIMEOUT = 300
|
|
@@ -23,6 +27,8 @@ module MarathonDeploy
|
|
|
23
27
|
DEFAULT_REMOVE_ELEMENTS = []
|
|
24
28
|
DEFAULT_KEEP_ELEMENTS = [':id']
|
|
25
29
|
ENVIRONMENT_VARIABLE_PREFIX = 'MARATHON_DEPLOY_'
|
|
30
|
+
marathon_username = nil
|
|
31
|
+
marathon_password = nil
|
|
26
32
|
|
|
27
33
|
@@preproduction_override = {
|
|
28
34
|
:instances => 5,
|
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.48
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jonathan Colby
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2016-02-
|
|
11
|
+
date: 2016-02-12 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: logger
|