Class: AethernalAgent::Docker::PortBinding

Inherits:
Object
  • Object
show all
Defined in:
lib/aethernal_agent/docker/port_binding.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source, target) ⇒ PortBinding

Returns a new instance of PortBinding.



6
7
8
9
# File 'lib/aethernal_agent/docker/port_binding.rb', line 6

def initialize(source, target)
  self.source = source
  self.target = target
end

Instance Attribute Details

#sourceObject

Returns the value of attribute source.



5
6
7
# File 'lib/aethernal_agent/docker/port_binding.rb', line 5

def source
  @source
end

#targetObject

Returns the value of attribute target.



5
6
7
# File 'lib/aethernal_agent/docker/port_binding.rb', line 5

def target
  @target
end

Class Method Details

.create_from_options(manifest_options, opts) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/aethernal_agent/docker/port_binding.rb', line 11

def self.create_from_options(manifest_options, opts)
  bindings = {}
  manifest_options.each do |k,v|
    if v.present?
      if v["docker"].present? && v["docker"]["source"].present?
        if v["docker"]["source"].to_s.include?("$port")
          v["docker"]["source"].gsub!("$port", opts[k].to_s)
        end
        bindings.merge!(PortBinding.new(v["docker"]["source"], opts[k]).to_docker)
      end
    end
  end

  return bindings
end

Instance Method Details

#to_dockerObject



27
28
29
# File 'lib/aethernal_agent/docker/port_binding.rb', line 27

def to_docker
  { self.source => [{ "HostPort" => self.target.to_s}] }
end