Sha256: 4bd3cfeebe58fa2651d25ac5dea068e5ac68888c1e6ae6eebb2f5024733d6670

Contents?: true

Size: 839 Bytes

Versions: 6

Compression:

Stored size: 839 Bytes

Contents

# frozen_string_literal: true

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

      attr_accessor :rules, :aggregation_rule

      alias aggregationRule aggregation_rule

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

      def render
        {
          apiVersion:,
          kind:,
          metadata: {
            name:,
            labels: { "#{label_namespace}/name": name }.merge(additional_labels)
          }.merge(formatted_annotations).compact,
          aggregationRule:,
          rules: formatted_rules
        }.compact
      end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
metatron-0.6.0 lib/metatron/templates/cluster_role.rb
metatron-0.5.0 lib/metatron/templates/cluster_role.rb
metatron-0.4.2 lib/metatron/templates/cluster_role.rb
metatron-0.4.1 lib/metatron/templates/cluster_role.rb
metatron-0.4.0 lib/metatron/templates/cluster_role.rb
metatron-0.3.4 lib/metatron/templates/cluster_role.rb