Class: KubernetesTemplateRendering::Template

Inherits:
OpenStruct
  • Object
show all
Defined in:
lib/kubernetes_template_rendering/template.rb

Direct Known Subclasses

ErbTemplate, JsonnetTemplate

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template_path, variables) ⇒ Template

Returns a new instance of Template.



12
13
14
15
# File 'lib/kubernetes_template_rendering/template.rb', line 12

def initialize(template_path, variables)
  @template_path = template_path
  @variables = variables
end

Instance Attribute Details

#template_pathObject (readonly)

Returns the value of attribute template_path.



11
12
13
# File 'lib/kubernetes_template_rendering/template.rb', line 11

def template_path
  @template_path
end

#variablesObject (readonly)

Returns the value of attribute variables.



11
12
13
# File 'lib/kubernetes_template_rendering/template.rb', line 11

def variables
  @variables
end

Class Method Details

.render(template_path, variables, erb_binding: nil, jsonnet_library_path: nil) ⇒ Object

TODO The ErbTemplate and JsonnetTemplate classes both inherit from the Template class and implement a render method. However, the erb_binding parameter is used just in ErbTemplate, while the jsonnet_library_path parameter is used just in JsonnetTemplate. This is a little awkward. Potentially this could be refactored.



46
47
48
# File 'lib/kubernetes_template_rendering/template.rb', line 46

def render(template_path, variables, erb_binding: nil, jsonnet_library_path: nil)
  new(template_path, variables).render(erb_binding: erb_binding, jsonnet_library_path: jsonnet_library_path)
end

Instance Method Details

#render(args) ⇒ Object



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

def render(args)
  raise "must be defined by subclass"
end