Class: Metatron::Templates::NetworkPolicy

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

Overview

Instance Attribute Summary collapse

Attributes inherited from Metatron::Template

#additional_labels, #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) ⇒ 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

#egressObject

Returns the value of attribute egress.



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

def egress
  @egress
end

#ingressObject

Returns the value of attribute ingress.



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

def ingress
  @ingress
end

#pod_selectorObject 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

#renderObject



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