Class: KubernetesTemplateRendering::DeployGroupedResource
- Inherits:
-
Object
- Object
- KubernetesTemplateRendering::DeployGroupedResource
- Defined in:
- lib/kubernetes_template_rendering/deploy_grouped_resource.rb
Constant Summary collapse
- DEFAULT_GROUP_VARIABLE_NAME =
"deploy_group"
Instance Attribute Summary collapse
-
#group_variable_name ⇒ Object
readonly
Returns the value of attribute group_variable_name.
-
#groups_to_render ⇒ Object
readonly
Returns the value of attribute groups_to_render.
-
#output_directory ⇒ Object
readonly
Returns the value of attribute output_directory.
-
#template_path ⇒ Object
readonly
Returns the value of attribute template_path.
-
#template_path_exclusions ⇒ Object
readonly
Returns the value of attribute template_path_exclusions.
-
#variables ⇒ Object
readonly
Returns the value of attribute variables.
Instance Method Summary collapse
-
#initialize(template_path:, definitions_path:, variables:, output_directory:, groups_to_render:, template_path_exclusions:, group_variable_name: nil) ⇒ DeployGroupedResource
constructor
A new instance of DeployGroupedResource.
- #render(args) ⇒ Object
Constructor Details
#initialize(template_path:, definitions_path:, variables:, output_directory:, groups_to_render:, template_path_exclusions:, group_variable_name: nil) ⇒ DeployGroupedResource
Returns a new instance of DeployGroupedResource.
11 12 13 14 15 16 17 18 19 |
# File 'lib/kubernetes_template_rendering/deploy_grouped_resource.rb', line 11 def initialize(template_path:, definitions_path:, variables:, output_directory:, groups_to_render:, template_path_exclusions:, group_variable_name: nil) @template_path = template_path @definitions_path = definitions_path @variables = variables @output_directory = output_directory @groups_to_render = groups_to_render @template_path_exclusions = template_path_exclusions || {} @group_variable_name = group_variable_name || DEFAULT_GROUP_VARIABLE_NAME end |
Instance Attribute Details
#group_variable_name ⇒ Object (readonly)
Returns the value of attribute group_variable_name.
9 10 11 |
# File 'lib/kubernetes_template_rendering/deploy_grouped_resource.rb', line 9 def group_variable_name @group_variable_name end |
#groups_to_render ⇒ Object (readonly)
Returns the value of attribute groups_to_render.
9 10 11 |
# File 'lib/kubernetes_template_rendering/deploy_grouped_resource.rb', line 9 def groups_to_render @groups_to_render end |
#output_directory ⇒ Object (readonly)
Returns the value of attribute output_directory.
9 10 11 |
# File 'lib/kubernetes_template_rendering/deploy_grouped_resource.rb', line 9 def output_directory @output_directory end |
#template_path ⇒ Object (readonly)
Returns the value of attribute template_path.
9 10 11 |
# File 'lib/kubernetes_template_rendering/deploy_grouped_resource.rb', line 9 def template_path @template_path end |
#template_path_exclusions ⇒ Object (readonly)
Returns the value of attribute template_path_exclusions.
9 10 11 |
# File 'lib/kubernetes_template_rendering/deploy_grouped_resource.rb', line 9 def template_path_exclusions @template_path_exclusions end |
#variables ⇒ Object (readonly)
Returns the value of attribute variables.
9 10 11 |
# File 'lib/kubernetes_template_rendering/deploy_grouped_resource.rb', line 9 def variables @variables end |
Instance Method Details
#render(args) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/kubernetes_template_rendering/deploy_grouped_resource.rb', line 21 def render(args) @resources = groups_to_render.map do |deploy_group| if template_is_excluded?(deploy_group) puts "Skipping #{Color.magenta(template_path_basename)} for #{deploy_group} deploy group due to it being " \ "excluded within the deploy group config\n\n" nil else vars = variables.merge(group_variable_name => deploy_group) filename = filename_for_deploy_group(deploy_group) Resource.new(template_path: template_path, definitions_path: @definitions_path, variables: vars, output_directory: output_directory, output_filename: filename).tap do |resource| resource.render(args) if args.render_files? end end end.compact end |