Class: Metatron::Templates::Gateway
- Inherits:
-
Metatron::Template
- Object
- Metatron::Template
- Metatron::Templates::Gateway
- Includes:
- Concerns::Annotated, Concerns::Namespaced
- Defined in:
- lib/metatron/templates/gateway.rb,
lib/metatron/templates/gateway/listener.rb
Overview
Template for Gateway k8s resource (Gateway API)
Defined Under Namespace
Classes: Listener
Instance Attribute Summary collapse
-
#additional_labels ⇒ Object
Returns the value of attribute additional_labels.
-
#gateway_class_name ⇒ Object
Returns the value of attribute gateway_class_name.
-
#listeners ⇒ Object
readonly
Returns the value of attribute listeners.
Attributes inherited from Metatron::Template
#api_version, #base_labels, #kind, #name
Instance Method Summary collapse
- #add_listener(listener = nil, **attrs) ⇒ Object
-
#initialize(name, gateway_class_name:) ⇒ Gateway
constructor
A new instance of Gateway.
- #render ⇒ Object
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, gateway_class_name:) ⇒ Gateway
Returns a new instance of Gateway.
13 14 15 16 17 18 19 |
# File 'lib/metatron/templates/gateway.rb', line 13 def initialize(name, gateway_class_name:) super(name) @gateway_class_name = gateway_class_name @api_version = "gateway.networking.k8s.io/v1" @additional_labels = {} @listeners = [] end |
Instance Attribute Details
#additional_labels ⇒ Object
Returns the value of attribute additional_labels.
10 11 12 |
# File 'lib/metatron/templates/gateway.rb', line 10 def additional_labels @additional_labels end |
#gateway_class_name ⇒ Object
Returns the value of attribute gateway_class_name.
10 11 12 |
# File 'lib/metatron/templates/gateway.rb', line 10 def gateway_class_name @gateway_class_name end |
#listeners ⇒ Object (readonly)
Returns the value of attribute listeners.
11 12 13 |
# File 'lib/metatron/templates/gateway.rb', line 11 def listeners @listeners end |
Instance Method Details
#add_listener(listener = nil, **attrs) ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/metatron/templates/gateway.rb', line 21 def add_listener(listener = nil, **attrs) @listeners << if listener.is_a?(Listener) listener else Listener.new(attrs.delete(:name), **attrs) end end |
#render ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/metatron/templates/gateway.rb', line 29 def render { apiVersion:, kind:, metadata: { name:, labels: base_labels.merge(additional_labels) }.merge(formatted_annotations).merge(formatted_namespace), spec: { gatewayClassName: gateway_class_name, listeners: listeners.map(&:render) } } end |