Class: KuberKit::Core::ServiceDefinition

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(service_name) ⇒ ServiceDefinition

Returns a new instance of ServiceDefinition.



5
6
7
# File 'lib/kuber_kit/core/service_definition.rb', line 5

def initialize(service_name)
  @service_name = service_name.to_sym
end

Instance Attribute Details

#service_nameObject (readonly)

Returns the value of attribute service_name.



2
3
4
# File 'lib/kuber_kit/core/service_definition.rb', line 2

def service_name
  @service_name
end

#template_nameObject (readonly)

Returns the value of attribute template_name.



2
3
4
# File 'lib/kuber_kit/core/service_definition.rb', line 2

def template_name
  @template_name
end

Instance Method Details

#attributes(value = nil, &block) ⇒ Object



38
39
40
41
42
# File 'lib/kuber_kit/core/service_definition.rb', line 38

def attributes(value = nil, &block)
  @attributes = block_given? ? block : value

  self
end

#deployer_strategy(value = nil, &block) ⇒ Object



44
45
46
47
48
# File 'lib/kuber_kit/core/service_definition.rb', line 44

def deployer_strategy(value = nil, &block)
  @deployer_strategy = block_given? ? block : value

  self
end

#images(*value, &block) ⇒ Object



32
33
34
35
36
# File 'lib/kuber_kit/core/service_definition.rb', line 32

def images(*value, &block)
  @images = block_given? ? block : Array(value).flatten

  self
end

#tags(*value, &block) ⇒ Object



26
27
28
29
30
# File 'lib/kuber_kit/core/service_definition.rb', line 26

def tags(*value, &block)
  @tags = block_given? ? block : Array(value).flatten

  self
end

#template(value = nil, &block) ⇒ Object



20
21
22
23
24
# File 'lib/kuber_kit/core/service_definition.rb', line 20

def template(value = nil, &block)
  @template_name = block_given? ? block : value

  self
end

#to_service_attrsObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/kuber_kit/core/service_definition.rb', line 9

def to_service_attrs
  OpenStruct.new(
    name:             @service_name,
    template_name:    get_value(@template_name),
    tags:             Array(get_value(@tags)).map(&:to_sym),
    images:           Array(get_value(@images)).map(&:to_sym),
    attributes:       get_value(@attributes),
    deployer_strategy:  get_value(@deployer_strategy),
  )
end