Sha256: b12d6139c468f5a5936541338f191511b9133f96b82671bb840d990d679bf141

Contents?: true

Size: 879 Bytes

Versions: 2

Compression:

Stored size: 879 Bytes

Contents

# frozen_string_literal: true

module Metatron
  module Templates
    # https://kubernetes.io/docs/concepts/services-networking/network-policies/
    class NetworkPolicy < Template
      include Concerns::Annotated
      include Concerns::Namespaced

      attr_accessor :pod_selector, :ingress, :egress

      alias podSelector pod_selector

      def initialize(name)
        super
        @pod_selector = pod_selector
        @ingress = ingress
        @egress = egress
      end

      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
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metatron-0.8.2 lib/metatron/templates/network_policy.rb
metatron-0.8.0 lib/metatron/templates/network_policy.rb