Sha256: bc1c1f9edc2501a98eb7e7b5b34745f3ca475e8e85ef85db56c63ee9cf2b5662

Contents?: true

Size: 885 Bytes

Versions: 1

Compression:

Stored size: 885 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(name)
        @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

1 entries across 1 versions & 1 rubygems

Version Path
metatron-0.7.0 lib/metatron/templates/network_policy.rb