Class: KuberKit::Core::ContextHelper::ServiceHelper
- Inherits:
-
BaseHelper
show all
- Defined in:
- lib/kuber_kit/core/context_helper/service_helper.rb
Instance Attribute Summary
Attributes inherited from BaseHelper
#artifact_store, #env_file_reader, #image_store, #shell
Instance Method Summary
collapse
Methods inherited from BaseHelper
#artifact_path, #configuration_name, #env_file, #global_build_args, #global_build_vars, #image_url
#get_binding
Constructor Details
#initialize(image_store:, artifact_store:, shell:, env_file_reader:, service:, template_renderer:) ⇒ ServiceHelper
Returns a new instance of ServiceHelper.
2
3
4
5
6
7
8
9
10
11
|
# File 'lib/kuber_kit/core/context_helper/service_helper.rb', line 2
def initialize(image_store:, artifact_store:, shell:, env_file_reader:, service:, template_renderer:)
super(
image_store: image_store,
artifact_store: artifact_store,
shell: shell,
env_file_reader: env_file_reader
)
@service = service
@template_renderer = template_renderer
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &block) ⇒ Object
34
35
36
|
# File 'lib/kuber_kit/core/context_helper/service_helper.rb', line 34
def method_missing(m, *args, &block)
raise("Unknown variable: #{m} while rendering '#{service_name}' with '#{@service.template_name}' template.")
end
|
Instance Method Details
#attribute(attribute_name, default: nil) ⇒ Object
21
22
23
|
# File 'lib/kuber_kit/core/context_helper/service_helper.rb', line 21
def attribute(attribute_name, default: nil)
@service.attribute(attribute_name, default: default)
end
|
#render(template_name, variables = {}) ⇒ Object
26
27
28
29
30
31
32
|
# File 'lib/kuber_kit/core/context_helper/service_helper.rb', line 26
def render(template_name, variables = {})
context_helper = KuberKit::Core::ContextHelper::LocalContextHelper.new(
parent_context_helper: self,
variables: variables
)
@template_renderer.call(shell, template_name.to_sym, context_helper: context_helper)
end
|
#service_name ⇒ Object
13
14
15
|
# File 'lib/kuber_kit/core/context_helper/service_helper.rb', line 13
def service_name
@service.name.to_s
end
|
#service_uri ⇒ Object
17
18
19
|
# File 'lib/kuber_kit/core/context_helper/service_helper.rb', line 17
def service_uri
@service.uri
end
|