Class: AethernalAgent::Docker::Env

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

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, value) ⇒ Env

Returns a new instance of Env.



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

def initialize(key, value)
  self.key= key
  self.value= value
end

Instance Attribute Details

#keyObject

Returns the value of attribute key.



4
5
6
# File 'lib/aethernal_agent/docker/env.rb', line 4

def key
  @key
end

#valueObject

Returns the value of attribute value.



4
5
6
# File 'lib/aethernal_agent/docker/env.rb', line 4

def value
  @value
end

Class Method Details

.create_from_options(manifest_options, opts) ⇒ Object



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

def self.create_from_options(manifest_options, opts)
  envs = []
  manifest_options.each do |k,v|
    if v.present?
      if v["docker"].present? && v["docker"]["env"].present?
        if v["docker"].has_key?("auto_source") && ["user_id"].include?(v["docker"]["auto_source"])
          # For now only allow user_id to be auto-sourced but we can add more things later
           user_id = Etc.getpwnam(opts["user"]).uid
          envs << Env.new(v["docker"]["env"], user_id)
        else
          envs << Env.new(v["docker"]["env"], opts[k])
        end
      end
    end
  end
  return envs
end

Instance Method Details

#to_dockerObject



28
29
30
# File 'lib/aethernal_agent/docker/env.rb', line 28

def to_docker
  "#{self.key}=#{self.value}"
end