Class: Marathon::Container

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

Overview

This class represents a Marathon Container information. It is included in App’s definition. See mesosphere.github.io/marathon/docs/native-docker.html for full details.

Constant Summary collapse

SUPPERTED_TYPES =
%w[ DOCKER MESOS]
ACCESSORS =
%w[ type ]
DEFAULTS =
{
    :type => 'DOCKER',
    :volumes => []
}

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) ⇒ Container

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



17
18
19
20
21
22
# File 'lib/marathon/container.rb', line 17

def initialize(hash)
  super(Marathon::Util.merge_keywordized_hash(DEFAULTS, hash), ACCESSORS)
  Marathon::Util.validate_choice('type', type, SUPPERTED_TYPES)
  @docker = Marathon::ContainerDocker.new(info[:docker]) if info[:docker]
  @volumes = info[:volumes].map { |e| Marathon::ContainerVolume.new(e) }
end

Instance Attribute Details

#dockerObject (readonly)

Returns the value of attribute docker.



13
14
15
# File 'lib/marathon/container.rb', line 13

def docker
  @docker
end

#volumesObject (readonly)

Returns the value of attribute volumes.



13
14
15
# File 'lib/marathon/container.rb', line 13

def volumes
  @volumes
end

Instance Method Details

#to_sObject



24
25
26
27
# File 'lib/marathon/container.rb', line 24

def to_s
  "Marathon::Container { :type => #{type} :docker => #{Marathon::Util.items_to_pretty_s(docker)}"\
  + " :volumes => #{Marathon::Util.items_to_pretty_s(volumes)} }"
end