class Drydock::ContainerConfig

Constants

DEFAULTS

Public Class Methods

from(hash) click to toggle source
# File lib/drydock/container_config.rb, line 21
def self.from(hash)
  return nil if hash.nil?

  self.new.tap do |cfg|
    DEFAULTS.each_pair do |k, v|
      cfg[k] = v
    end
    hash.each_pair do |k, v|
      cfg[k] = v
    end
  end
end

Public Instance Methods

==(other) click to toggle source

Logic taken from github.com/docker/docker/blob/master/runconfig/compare.go Last updated to conform to docker v1.9.1

# File lib/drydock/container_config.rb, line 36
def ==(other)
  return false if other.nil?

  return false if self['OpenStdin'] || other['OpenStdin']
  return false if self['AttachStdout'] != other['AttachStdout']
  return false if self['AttachStderr'] != other['AttachStderr']

  return false if self['User'] != other['User']
  return false if self['Tty'] != other['Tty']

  return false if self['Cmd'] != other['Cmd']
  return false if Array(self['Env']).sort != Array(other['Env']).sort
  return false if (self['Labels'] || {}) != (other['Labels'] || {})
  return false if self['Entrypoint'] != other['Entrypoint']

  my_ports = self['ExposedPorts'] || {}
  other_ports = other['ExposedPorts'] || {}
  return false if my_ports.keys.size != other_ports.keys.size
  my_ports.keys.each do |my_port|
    return false unless other_ports.key?(my_port)
  end

  my_vols = self['Volumes'] || {}
  other_vols = other['Volumes'] || {}
  return false if my_vols.keys.size != other_vols.keys.size
  my_vols.keys.each do |my_vol|
    return false unless other_vols.key?(my_vol)
  end

  return true
end
[](key) click to toggle source
Calls superclass method
# File lib/drydock/container_config.rb, line 68
def [](key)
  super(key.to_s)
end
[]=(key, value) click to toggle source
Calls superclass method
# File lib/drydock/container_config.rb, line 72
def []=(key, value)
  super(key.to_s, value)
end