Sha256: ef45b27e0fc572cbadbd27e93ff148a2274a65b6e6efcc392e74e188dbb937f7

Contents?: true

Size: 770 Bytes

Versions: 2

Compression:

Stored size: 770 Bytes

Contents

# frozen_string_literal: true

module Metatron
  module Templates
    # Template for basic Role k8s resource
    class Role < Template
      include Concerns::Annotated
      include Concerns::Namespaced

      attr_accessor :rules

      def initialize(name)
        super(name)
        @api_version = "rbac.authorization.k8s.io/v1"
        @rules = []
      end

      def render
        {
          apiVersion:,
          kind:,
          metadata: {
            name:,
            labels: base_labels.merge(additional_labels)
          }.merge(formatted_annotations).merge(formatted_namespace).compact,
          rules: formatted_rules
        }.compact
      end

      def formatted_rules = rules.map { _1.respond_to?(:render) ? _1.render : _1 }
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
metatron-0.7.0 lib/metatron/templates/role.rb
metatron-0.6.1 lib/metatron/templates/role.rb