Class: Marathon::ContainerDocker

Inherits:
Base
  • Object
show all
Defined in:
lib/marathon/container_docker.rb

Overview

This class represents a Marathon Container docker information. See mesosphere.github.io/marathon/docs/native-docker.html for full details.

Constant Summary collapse

ACCESSORS =
%w[ image network privileged parameters ]
DEFAULTS =
{
    :network => 'BRIDGE',
    :portMappings => []
}

Instance Attribute Summary collapse

Attributes inherited from Base

#info

Instance Method Summary collapse

Methods inherited from Base

#to_json

Methods included from Error

error_class, error_message, from_response

Constructor Details

#initialize(hash) ⇒ ContainerDocker

Create a new container docker object. hash: Hash returned by API.



15
16
17
18
19
20
21
# File 'lib/marathon/container_docker.rb', line 15

def initialize(hash)
  super(Marathon::Util.merge_keywordized_hash(DEFAULTS, hash), ACCESSORS)
  Marathon::Util.validate_choice('network', network, %w[BRIDGE HOST])
  Marathon::Util.validate_choice('privileged', privileged, ['true', 'false', true, false])
  raise Marathon::Error::ArgumentError, 'image must not be nil' unless image
  @portMappings = (info[:portMappings] || []).map { |e| Marathon::ContainerDockerPortMapping.new(e) }
end

Instance Attribute Details

#portMappingsObject (readonly)

Returns the value of attribute portMappings.



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

def portMappings
  @portMappings
end

Instance Method Details

#to_pretty_sObject



23
24
25
# File 'lib/marathon/container_docker.rb', line 23

def to_pretty_s
  "#{image}"
end

#to_sObject



27
28
29
# File 'lib/marathon/container_docker.rb', line 27

def to_s
  "Marathon::ContainerDocker { :image => #{image} }"
end