Class: Kubec::Kubernetes::Template

Inherits:
Hash
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/kubec/kubernetes/template.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initializeTemplate

Returns a new instance of Template.



11
12
13
14
# File 'lib/kubec/kubernetes/template.rb', line 11

def initialize
  self[:metadata] = Metadata.new
  self[:spec] = {}
end

Instance Method Details

#container(name, &block) ⇒ Object



35
36
37
38
# File 'lib/kubec/kubernetes/template.rb', line 35

def container(name, &block)
  spec[:containers] ||= []
  spec[:containers].push Container.new(name, &block)
end

#fetch(*args) ⇒ Object

TODO: Refactor this feature



17
18
19
# File 'lib/kubec/kubernetes/template.rb', line 17

def fetch(*args)
  Environment.instance.fetch(*args)
end

#metadata(&block) ⇒ Object



26
27
28
29
# File 'lib/kubec/kubernetes/template.rb', line 26

def (&block)
  return self[:metadata] unless block_given?
  self[:metadata].instance_eval(&block)
end

#restart(policy) ⇒ Object



40
41
42
# File 'lib/kubec/kubernetes/template.rb', line 40

def restart(policy)
  spec[:restartPolicy] = policy.to_s.capitalize
end

#specObject



31
32
33
# File 'lib/kubec/kubernetes/template.rb', line 31

def spec
  self[:spec]
end

#volume(name, &block) ⇒ Object



21
22
23
24
# File 'lib/kubec/kubernetes/template.rb', line 21

def volume(name, &block)
  spec[:volumes] ||= []
  spec[:volumes].push Volume.new(name, &block)
end