Class: KuberKit::Core::Service

Inherits:
Object
  • Object
show all
Defined in:
lib/kuber_kit/core/service.rb

Constant Summary collapse

AttributeNotSet =
Class.new(KuberKit::Error)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name:, dependencies:, template_name:, tags:, images:, attributes:, deployer_strategy:) ⇒ Service

Returns a new instance of Service.



15
16
17
18
19
20
21
22
23
# File 'lib/kuber_kit/core/service.rb', line 15

def initialize(name:, dependencies:, template_name:, tags:, images:, attributes:, deployer_strategy:)
  @name = name
  @dependencies = dependencies
  @template_name = template_name
  @tags = tags
  @images = images
  @attributes = attributes
  @deployer_strategy = deployer_strategy
end

Instance Attribute Details

#attributesObject (readonly)

Returns the value of attribute attributes.



4
5
6
# File 'lib/kuber_kit/core/service.rb', line 4

def attributes
  @attributes
end

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



4
5
6
# File 'lib/kuber_kit/core/service.rb', line 4

def dependencies
  @dependencies
end

#deployer_strategyObject (readonly)

Returns the value of attribute deployer_strategy.



4
5
6
# File 'lib/kuber_kit/core/service.rb', line 4

def deployer_strategy
  @deployer_strategy
end

#imagesObject (readonly)

Returns the value of attribute images.



4
5
6
# File 'lib/kuber_kit/core/service.rb', line 4

def images
  @images
end

#nameObject (readonly)

Returns the value of attribute name.



4
5
6
# File 'lib/kuber_kit/core/service.rb', line 4

def name
  @name
end

#tagsObject (readonly)

Returns the value of attribute tags.



4
5
6
# File 'lib/kuber_kit/core/service.rb', line 4

def tags
  @tags
end

#template_nameObject (readonly)

Returns the value of attribute template_name.



4
5
6
# File 'lib/kuber_kit/core/service.rb', line 4

def template_name
  @template_name
end

Instance Method Details

#attribute(attribute_name, default: nil) ⇒ Object



29
30
31
32
33
34
35
36
37
38
39
# File 'lib/kuber_kit/core/service.rb', line 29

def attribute(attribute_name, default: nil)
  if !attributes.has_key?(attribute_name.to_sym) && default.nil?
    raise AttributeNotSet, "attribute #{attribute_name} was not set"
  end

  if !attributes.has_key?(attribute_name.to_sym) && !default.nil?
    return default
  end

  attributes[attribute_name.to_sym]
end

#uriObject



25
26
27
# File 'lib/kuber_kit/core/service.rb', line 25

def uri
  name.to_s.gsub("_", "-")
end