Class: Lemans::Config::Environment
- Inherits:
-
Object
- Object
- Lemans::Config::Environment
- Extended by:
- Conversion
- Defined in:
- lib/lemans/config/environment.rb
Overview
:nodoc:
Defined Under Namespace
Classes: Resources
Constant Summary
Constants included from Conversion
Conversion::DURATION, Conversion::DURATION_FACTORS, Conversion::SIZE, Conversion::SIZE_FACTORS
Instance Attribute Summary collapse
-
#backend ⇒ Object
Returns the value of attribute backend.
-
#build_timeout ⇒ Object
Returns the value of attribute build_timeout.
-
#dockerfile ⇒ Object
Returns the value of attribute dockerfile.
-
#image ⇒ Object
Returns the value of attribute image.
-
#network ⇒ Object
Returns the value of attribute network.
-
#resources ⇒ Object
Returns the value of attribute resources.
-
#workdir ⇒ Object
Returns the value of attribute workdir.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize ⇒ Environment
constructor
A new instance of Environment.
Methods included from Conversion
absolute_path!, float!, integer!, megabytes!, seconds!
Constructor Details
#initialize ⇒ Environment
Returns a new instance of Environment.
35 36 37 38 39 40 41 42 43 |
# File 'lib/lemans/config/environment.rb', line 35 def initialize @image = nil @dockerfile = nil @backend = "daytona" @workdir = "/app" @resources = Resources.new(cpus: 2, memory: 2048, storage: 5120) @build_timeout = 10 * 60 @network = NetworkPolicy.new end |
Instance Attribute Details
#backend ⇒ Object
Returns the value of attribute backend.
32 33 34 |
# File 'lib/lemans/config/environment.rb', line 32 def backend @backend end |
#build_timeout ⇒ Object
Returns the value of attribute build_timeout.
32 33 34 |
# File 'lib/lemans/config/environment.rb', line 32 def build_timeout @build_timeout end |
#dockerfile ⇒ Object
Returns the value of attribute dockerfile.
32 33 34 |
# File 'lib/lemans/config/environment.rb', line 32 def dockerfile @dockerfile end |
#image ⇒ Object
Returns the value of attribute image.
32 33 34 |
# File 'lib/lemans/config/environment.rb', line 32 def image @image end |
#network ⇒ Object
Returns the value of attribute network.
32 33 34 |
# File 'lib/lemans/config/environment.rb', line 32 def network @network end |
#resources ⇒ Object
Returns the value of attribute resources.
32 33 34 |
# File 'lib/lemans/config/environment.rb', line 32 def resources @resources end |
#workdir ⇒ Object
Returns the value of attribute workdir.
32 33 34 |
# File 'lib/lemans/config/environment.rb', line 32 def workdir @workdir end |
Class Method Details
.from_config(data) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/lemans/config/environment.rb', line 11 def from_config(data) return if data.nil? conf = new conf.backend = data["backend"] if data["backend"] conf.image = data["image"] if data["image"] conf.dockerfile = data["dockerfile"] if data["dockerfile"] raise ConfigError, "environment.image and environment.dockerfile are mutually exclusive" if conf.image && conf.dockerfile conf.workdir = absolute_path!(data["workdir"]) if data["workdir"] conf.build_timeout = seconds!(data["build_timeout"]) if data["build_timeout"] conf.network = NetworkPolicy.from_config(data["network"]) if data["network"] conf.resources.cpus = integer!(data.dig("resources", "cpus")) if data.dig("resources", "cpus") conf.resources.memory = megabytes!(data.dig("resources", "memory")) if data.dig("resources", "memory") conf.resources.storage = megabytes!(data.dig("resources", "storage")) if data.dig("resources", "storage") conf end |