Class: Metatron::Template
- Inherits:
-
Object
- Object
- Metatron::Template
- Defined in:
- lib/metatron/template.rb
Overview
Base class for templating Kubernetes resources
Direct Known Subclasses
Metatron::Templates::ClusterRole, Metatron::Templates::ClusterRoleBinding, Metatron::Templates::ConfigMap, Metatron::Templates::CronJob, Metatron::Templates::DaemonSet, Metatron::Templates::Deployment, Metatron::Templates::Ingress, Metatron::Templates::Job, Metatron::Templates::Namespace, Metatron::Templates::NetworkPolicy, Metatron::Templates::PersistentVolumeClaim, Metatron::Templates::Pod, Metatron::Templates::ReplicaSet, Metatron::Templates::Role, Metatron::Templates::RoleBinding, Metatron::Templates::Secret, Metatron::Templates::Service, Metatron::Templates::ServiceAccount, Metatron::Templates::StatefulSet
Class Attribute Summary collapse
Instance Attribute Summary collapse
-
#additional_labels ⇒ Object
Returns the value of attribute additional_labels.
-
#api_version ⇒ Object
(also: #apiVersion)
Returns the value of attribute api_version.
-
#kind ⇒ Object
readonly
Returns the value of attribute kind.
-
#label_namespace ⇒ Object
readonly
Returns the value of attribute label_namespace.
-
#name ⇒ Object
Returns the value of attribute name.
Class Method Summary collapse
- .initializer(*args) ⇒ Object
- .initializers ⇒ Object
- .metatron_template_class? ⇒ Boolean
- .nearest_metatron_ancestor ⇒ Object
Instance Method Summary collapse
- #base_labels ⇒ Object
-
#initialize(name) ⇒ Template
constructor
A new instance of Template.
Constructor Details
#initialize(name) ⇒ Template
Returns a new instance of Template.
39 40 41 42 43 44 45 46 |
# File 'lib/metatron/template.rb', line 39 def initialize(name) @name = name @label_namespace = self.class.label_namespace @api_version = "v1" @kind = find_kind @additional_labels = {} run_initializers end |
Class Attribute Details
.label_namespace ⇒ Object
12 13 14 |
# File 'lib/metatron/template.rb', line 12 def label_namespace @label_namespace ||= "metatron.therubyist.org" end |
Instance Attribute Details
#additional_labels ⇒ Object
Returns the value of attribute additional_labels.
6 7 8 |
# File 'lib/metatron/template.rb', line 6 def additional_labels @additional_labels end |
#api_version ⇒ Object Also known as: apiVersion
Returns the value of attribute api_version.
6 7 8 |
# File 'lib/metatron/template.rb', line 6 def api_version @api_version end |
#kind ⇒ Object (readonly)
Returns the value of attribute kind.
7 8 9 |
# File 'lib/metatron/template.rb', line 7 def kind @kind end |
#label_namespace ⇒ Object (readonly)
Returns the value of attribute label_namespace.
7 8 9 |
# File 'lib/metatron/template.rb', line 7 def label_namespace @label_namespace end |
#name ⇒ Object
Returns the value of attribute name.
6 7 8 |
# File 'lib/metatron/template.rb', line 6 def name @name end |
Class Method Details
.initializer(*args) ⇒ Object
16 17 18 19 |
# File 'lib/metatron/template.rb', line 16 def initializer(*args) @initializers ||= [] @initializers += args end |
.initializers ⇒ Object
21 22 23 |
# File 'lib/metatron/template.rb', line 21 def initializers @initializers ||= [] end |
.metatron_template_class? ⇒ Boolean
31 32 33 34 35 36 |
# File 'lib/metatron/template.rb', line 31 def return true if name == "Metatron::Template" return false if name.start_with?("Metatron::Templates::Concerns") name.start_with?("Metatron::Templates::") end |
.nearest_metatron_ancestor ⇒ Object
25 26 27 28 29 |
# File 'lib/metatron/template.rb', line 25 def return self if ancestors.find { _1.respond_to?(:metatron_template_class?) && _1. } end |
Instance Method Details
#base_labels ⇒ Object
50 |
# File 'lib/metatron/template.rb', line 50 def base_labels = { "#{label_namespace}/name": name } |