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::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
-
#initialize(name) ⇒ Template
constructor
A new instance of Template.
Constructor Details
#initialize(name) ⇒ Template
Returns a new instance of Template.
17 18 19 20 21 22 23 24 |
# File 'lib/metatron/template.rb', line 17 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
28 29 30 31 |
# File 'lib/metatron/template.rb', line 28 def self.initializer(*args) @initializers ||= [] @initializers += args end |
.initializers ⇒ Object
33 34 35 |
# File 'lib/metatron/template.rb', line 33 def self.initializers @initializers ||= [] end |
.metatron_template_class? ⇒ Boolean
43 44 45 46 47 48 |
# File 'lib/metatron/template.rb', line 43 def self. 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
37 38 39 40 41 |
# File 'lib/metatron/template.rb', line 37 def self. return self if ancestors.find { _1.respond_to?(:metatron_template_class?) && _1. } end |