Class: Drydock::ContainerConfig
- Inherits:
-
Hash
- Object
- Hash
- Drydock::ContainerConfig
- Defined in:
- lib/drydock/container_config.rb
Constant Summary collapse
- DEFAULTS =
{ 'MetaOptions' => {}, 'OpenStdin' => false, 'AttachStdin' => false, 'AttachStdout' => false, 'AttachStderr' => false, 'User' => '', 'Tty' => false, 'Cmd' => nil, 'Env' => ['PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin'], 'Labels' => nil, 'Entrypoint' => nil, 'ExposedPorts' => nil, 'Volumes' => nil }
Class Method Summary collapse
Instance Method Summary collapse
-
#==(other) ⇒ Object
Logic taken from github.com/docker/docker/blob/master/runconfig/compare.go.
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
Class Method Details
.from(hash) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# 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 |
Instance Method Details
#==(other) ⇒ Object
Logic taken from github.com/docker/docker/blob/master/runconfig/compare.go
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/drydock/container_config.rb', line 35 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) ⇒ Object
67 68 69 |
# File 'lib/drydock/container_config.rb', line 67 def [](key) super(key.to_s) end |
#[]=(key, value) ⇒ Object
71 72 73 |
# File 'lib/drydock/container_config.rb', line 71 def []=(key, value) super(key.to_s, value) end |