Module: Marathon

Defined in:
lib/marathon.rb,
lib/marathon/version.rb

Overview

The top-level module for this gem. It’s purpose is to hold global configuration variables that are used as defaults in other classes.

Defined Under Namespace

Modules: Error Classes: App, Base, Connection, Constraint, Container, ContainerDocker, ContainerDockerPortMapping, ContainerVolume, Deployment, DeploymentAction, DeploymentInfo, DeploymentStep, EventSubscriptions, Group, HealthCheck, Leader, Queue, Task, Util

Constant Summary collapse

DEFAULT_URL =
'http://localhost:8080'
VERSION =
'1.2.0'

Class Method Summary collapse

Class Method Details

.connectionObject

Set a new connection



73
74
75
# File 'lib/marathon.rb', line 73

def connection
  @connection ||= Connection.new(url, options)
end

.env_optionsObject

Get marathon options from environment



42
43
44
45
46
47
# File 'lib/marathon.rb', line 42

def env_options
  opts = {}
  opts[:username] = ENV['MARATHON_USER'] if ENV['MARATHON_USER']
  opts[:password] = ENV['MARATHON_PASSWORD'] if ENV['MARATHON_PASSWORD']
  opts
end

.env_urlObject

Get the marathon url from environment



37
38
39
# File 'lib/marathon.rb', line 37

def env_url
  ENV['MARATHON_URL']
end

.infoObject

Get information about the marathon server



83
84
85
# File 'lib/marathon.rb', line 83

def info
  connection.get('/v2/info')
end

.loggerObject

Returns the value of attribute logger.



10
11
12
# File 'lib/marathon.rb', line 10

def logger
  @logger
end

.logger=(value) ⇒ Object

Sets the attribute logger

Parameters:

  • value

    the value to set the attribute logger to.



10
11
12
# File 'lib/marathon.rb', line 10

def logger=(value)
  @logger = value
end

.optionsObject

Get options for connecting to marathon API



56
57
58
# File 'lib/marathon.rb', line 56

def options
  @options ||= env_options
end

.options=(new_options) ⇒ Object

Set new options



67
68
69
70
# File 'lib/marathon.rb', line 67

def options=(new_options)
  @options = env_options.merge(new_options || {})
  reset_connection!
end

.pingObject

Ping marathon



88
89
90
# File 'lib/marathon.rb', line 88

def ping
  connection.get('/ping')
end

.reset_connection!Object

Reset the connection



78
79
80
# File 'lib/marathon.rb', line 78

def reset_connection!
  @connection = nil
end

.urlObject

Get the marathon API URL



50
51
52
53
# File 'lib/marathon.rb', line 50

def url
  @url ||= env_url || DEFAULT_URL
  @url
end

.url=(new_url) ⇒ Object

Set a new url



61
62
63
64
# File 'lib/marathon.rb', line 61

def url=(new_url)
  @url = new_url
  reset_connection!
end