Class: Metatron::Templates::ResourceQuota

Inherits:
Metatron::Template show all
Includes:
Concerns::Annotated, Concerns::Namespaced
Defined in:
lib/metatron/templates/resource_quota.rb

Overview

Template for basic Role k8s resource

Instance Attribute Summary collapse

Attributes inherited from Metatron::Template

#api_version, #base_labels, #kind, #name

Instance Method Summary collapse

Methods included from Concerns::Namespaced

#formatted_namespace, included, #namespaced_initialize

Methods included from Concerns::Annotated

#annotated_initialize, #formatted_annotations, included

Methods inherited from Metatron::Template

initializer, initializers, metatron_template_class?, nearest_metatron_ancestor

Constructor Details

#initialize(name) ⇒ ResourceQuota

Returns a new instance of ResourceQuota.



12
13
14
15
16
# File 'lib/metatron/templates/resource_quota.rb', line 12

def initialize(name)
  super
  @additional_labels = {}
  @spec = {}
end

Instance Attribute Details

#additional_labelsObject

Returns the value of attribute additional_labels.



10
11
12
# File 'lib/metatron/templates/resource_quota.rb', line 10

def additional_labels
  @additional_labels
end

#specObject

Returns the value of attribute spec.



10
11
12
# File 'lib/metatron/templates/resource_quota.rb', line 10

def spec
  @spec
end

Instance Method Details

#formatted_specObject



29
# File 'lib/metatron/templates/resource_quota.rb', line 29

def formatted_spec = (@spec || {}).empty? ? {} : { spec: }

#renderObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/metatron/templates/resource_quota.rb', line 18

def render
  {
    apiVersion:,
    kind:,
    metadata: {
      name:,
      labels: base_labels.merge(additional_labels)
    }.merge(formatted_annotations).merge(formatted_namespace).compact
  }.merge(formatted_spec)
end