Class: Bosh::Director::DeploymentPlan::TemplateLink
- Defined in:
- lib/bosh/director/deployment_plan/links/template_link.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#optional ⇒ Object
Returns the value of attribute optional.
-
#shared ⇒ Object
Returns the value of attribute shared.
-
#type ⇒ Object
Returns the value of attribute type.
Class Method Summary collapse
- .parse(kind, link_def) ⇒ Object
- .parse_consumes_link(link_def) ⇒ Object
- .parse_provides_link(link_def) ⇒ Object
Instance Method Summary collapse
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name
3 4 5 |
# File 'lib/bosh/director/deployment_plan/links/template_link.rb', line 3 def name @name end |
#optional ⇒ Object
Returns the value of attribute optional
3 4 5 |
# File 'lib/bosh/director/deployment_plan/links/template_link.rb', line 3 def optional @optional end |
#shared ⇒ Object
Returns the value of attribute shared
3 4 5 |
# File 'lib/bosh/director/deployment_plan/links/template_link.rb', line 3 def shared @shared end |
#type ⇒ Object
Returns the value of attribute type
3 4 5 |
# File 'lib/bosh/director/deployment_plan/links/template_link.rb', line 3 def type @type end |
Class Method Details
.parse(kind, link_def) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/bosh/director/deployment_plan/links/template_link.rb', line 4 def self.parse(kind, link_def) if kind == "consumes" return self.parse_consumes_link(link_def) elsif kind == "provides" return self.parse_provides_link(link_def) end end |
.parse_consumes_link(link_def) ⇒ Object
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/bosh/director/deployment_plan/links/template_link.rb', line 12 def self.parse_consumes_link(link_def) if link_def.is_a?(Hash) && link_def.has_key?('type') && link_def.has_key?('name') if link_def.has_key?('from') return new(link_def['from'].split(".")[-1], link_def['type'], link_def['optional'] || false) else return new(link_def['name'], link_def['type'], link_def['optional'] || false) end end raise JobInvalidLinkSpec, "Link '#{link_def}' must be a hash with name and type" end |
.parse_provides_link(link_def) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/bosh/director/deployment_plan/links/template_link.rb', line 23 def self.parse_provides_link(link_def) if link_def.is_a?(Hash) && link_def.has_key?('type') && link_def.has_key?('name') if link_def.has_key?('optional') raise JobInvalidLinkSpec, "Link '#{link_def['name']}' of type '#{link_def['type']}' is a provides link, not allowed to have 'optional' key" elsif link_def.has_key?('as') return new(link_def['as'], link_def['type'], false, link_def['shared'] || false) else return new(link_def['name'], link_def['type'], false, link_def['shared'] || false) end end raise JobInvalidLinkSpec, "Link '#{link_def}' must be a hash with name and type" end |
Instance Method Details
#to_s ⇒ Object
36 37 38 |
# File 'lib/bosh/director/deployment_plan/links/template_link.rb', line 36 def to_s "name: #{name}, type: #{type}, shared: #{shared || false}" end |