Class: Bosh::Director::DeploymentPlan::TemplateLink

Inherits:
Struct
  • Object
show all
Defined in:
lib/bosh/director/deployment_plan/links/template_link.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#nameObject

Returns the value of attribute name

Returns:

  • (Object)

    the current value of name



3
4
5
# File 'lib/bosh/director/deployment_plan/links/template_link.rb', line 3

def name
  @name
end

#optionalObject

Returns the value of attribute optional

Returns:

  • (Object)

    the current value of optional



3
4
5
# File 'lib/bosh/director/deployment_plan/links/template_link.rb', line 3

def optional
  @optional
end

#sharedObject

Returns the value of attribute shared

Returns:

  • (Object)

    the current value of shared



3
4
5
# File 'lib/bosh/director/deployment_plan/links/template_link.rb', line 3

def shared
  @shared
end

#typeObject

Returns the value of attribute type

Returns:

  • (Object)

    the current value of 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

Raises:



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

Raises:



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_sObject



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