Class: MobyDerp::PodConfig
- Inherits:
-
ConfigFile
- Object
- ConfigFile
- MobyDerp::PodConfig
- Includes:
- LoggingHelpers
- Defined in:
- lib/moby_derp/pod_config.rb
Constant Summary collapse
- VALID_CONFIG_KEYS =
%w{ containers hostname common_environment common_labels root_labels common_mounts expose publish publish_all }
Instance Attribute Summary collapse
-
#common_environment ⇒ Object
readonly
Returns the value of attribute common_environment.
-
#common_labels ⇒ Object
readonly
Returns the value of attribute common_labels.
-
#common_mounts ⇒ Object
readonly
Returns the value of attribute common_mounts.
-
#containers ⇒ Object
readonly
Returns the value of attribute containers.
-
#expose ⇒ Object
readonly
Returns the value of attribute expose.
-
#hostname ⇒ Object
readonly
Returns the value of attribute hostname.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#mount_root ⇒ Object
readonly
Returns the value of attribute mount_root.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#publish ⇒ Object
readonly
Returns the value of attribute publish.
-
#publish_all ⇒ Object
readonly
Returns the value of attribute publish_all.
-
#root_labels ⇒ Object
readonly
Returns the value of attribute root_labels.
-
#system_config ⇒ Object
readonly
Returns the value of attribute system_config.
Instance Method Summary collapse
-
#initialize(filename, system_config) ⇒ PodConfig
constructor
A new instance of PodConfig.
- #network_name ⇒ Object
Constructor Details
#initialize(filename, system_config) ⇒ PodConfig
Returns a new instance of PodConfig.
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 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/moby_derp/pod_config.rb', line 38 def initialize(filename, system_config) @logger = system_config.logger super(filename) @system_config = system_config @name = File.basename(filename, ".*") validate_name unless (bad_keys = @config.keys - VALID_CONFIG_KEYS).empty? raise ConfigurationError, "Invalid pod configuration key(s): #{bad_keys.inspect}" end unless @config.has_key?("containers") raise ConfigurationError, "no containers defined" end @containers = @config.fetch("containers") validate_containers @logger.debug(logloc) { "Hostname is #{@system_config.host_hostname}" } @hostname = @config.fetch("hostname", "#{@name.gsub("_", "-")}-#{@system_config.host_hostname}") @common_environment = @config.fetch("common_environment", {}) @common_labels = @config.fetch("common_labels", {}) @root_labels = @config.fetch("root_labels", {}) validate_common_environment validate_hash(:common_labels) validate_hash(:root_labels) @common_mounts = @config.fetch("common_mounts", []) @expose = @config.fetch("expose", []) @publish = @config.fetch("publish", []) if @system_config.use_host_resolv_conf @common_mounts << { "source" => "/etc/resolv.conf", "target" => "/etc/resolv.conf", "readonly" => true } end validate_common_mounts validate_expose validate_publish @publish_all = @config.fetch("publish_all", false) validate_publish_all @mount_root = File.join(system_config.mount_root, @name) end |
Instance Attribute Details
#common_environment ⇒ Object (readonly)
Returns the value of attribute common_environment.
24 25 26 |
# File 'lib/moby_derp/pod_config.rb', line 24 def common_environment @common_environment end |
#common_labels ⇒ Object (readonly)
Returns the value of attribute common_labels.
24 25 26 |
# File 'lib/moby_derp/pod_config.rb', line 24 def common_labels @common_labels end |
#common_mounts ⇒ Object (readonly)
Returns the value of attribute common_mounts.
24 25 26 |
# File 'lib/moby_derp/pod_config.rb', line 24 def common_mounts @common_mounts end |
#containers ⇒ Object (readonly)
Returns the value of attribute containers.
24 25 26 |
# File 'lib/moby_derp/pod_config.rb', line 24 def containers @containers end |
#expose ⇒ Object (readonly)
Returns the value of attribute expose.
24 25 26 |
# File 'lib/moby_derp/pod_config.rb', line 24 def expose @expose end |
#hostname ⇒ Object (readonly)
Returns the value of attribute hostname.
24 25 26 |
# File 'lib/moby_derp/pod_config.rb', line 24 def hostname @hostname end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
24 25 26 |
# File 'lib/moby_derp/pod_config.rb', line 24 def logger @logger end |
#mount_root ⇒ Object (readonly)
Returns the value of attribute mount_root.
24 25 26 |
# File 'lib/moby_derp/pod_config.rb', line 24 def mount_root @mount_root end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
24 25 26 |
# File 'lib/moby_derp/pod_config.rb', line 24 def name @name end |
#publish ⇒ Object (readonly)
Returns the value of attribute publish.
24 25 26 |
# File 'lib/moby_derp/pod_config.rb', line 24 def publish @publish end |
#publish_all ⇒ Object (readonly)
Returns the value of attribute publish_all.
24 25 26 |
# File 'lib/moby_derp/pod_config.rb', line 24 def publish_all @publish_all end |
#root_labels ⇒ Object (readonly)
Returns the value of attribute root_labels.
24 25 26 |
# File 'lib/moby_derp/pod_config.rb', line 24 def root_labels @root_labels end |
#system_config ⇒ Object (readonly)
Returns the value of attribute system_config.
24 25 26 |
# File 'lib/moby_derp/pod_config.rb', line 24 def system_config @system_config end |
Instance Method Details
#network_name ⇒ Object
92 93 94 |
# File 'lib/moby_derp/pod_config.rb', line 92 def network_name @system_config.network_name end |