Class: Metatron::Templates::NetworkPolicy
- Inherits:
-
Metatron::Template
- Object
- Metatron::Template
- Metatron::Templates::NetworkPolicy
- Includes:
- Concerns::Annotated, Concerns::Namespaced
- Defined in:
- lib/metatron/templates/network_policy.rb
Overview
Instance Attribute Summary collapse
-
#egress ⇒ Object
Returns the value of attribute egress.
-
#ingress ⇒ Object
Returns the value of attribute ingress.
-
#pod_selector ⇒ Object
(also: #podSelector)
Returns the value of attribute pod_selector.
Attributes inherited from Metatron::Template
#additional_labels, #api_version, #base_labels, #kind, #name
Instance Method Summary collapse
-
#initialize(name) ⇒ NetworkPolicy
constructor
A new instance of NetworkPolicy.
- #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) ⇒ NetworkPolicy
Returns a new instance of NetworkPolicy.
14 15 16 17 18 19 |
# File 'lib/metatron/templates/network_policy.rb', line 14 def initialize(name) super @pod_selector = pod_selector @ingress = ingress @egress = egress end |
Instance Attribute Details
#egress ⇒ Object
Returns the value of attribute egress.
10 11 12 |
# File 'lib/metatron/templates/network_policy.rb', line 10 def egress @egress end |
#ingress ⇒ Object
Returns the value of attribute ingress.
10 11 12 |
# File 'lib/metatron/templates/network_policy.rb', line 10 def ingress @ingress end |
#pod_selector ⇒ Object Also known as: podSelector
Returns the value of attribute pod_selector.
10 11 12 |
# File 'lib/metatron/templates/network_policy.rb', line 10 def pod_selector @pod_selector end |
Instance Method Details
#render ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/metatron/templates/network_policy.rb', line 21 def render { apiVersion:, kind:, metadata: { labels: base_labels.merge(additional_labels), name: }.merge(formatted_annotations).merge(formatted_namespace), spec: { podSelector: }.merge(ingress ? { ingress: } : {}).merge(egress ? { egress: } : {}) } end |