Sha256: 744f48b2f237ccd7e8b4d70a4b8e1e220c38b642b0319bb5cfcc12e5a125d2e0

Contents?: true

Size: 911 Bytes

Versions: 4

Compression:

Stored size: 911 Bytes

Contents

# frozen_string_literal: true

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

      attr_accessor :role_ref, :subjects, :role

      alias roleRef role_ref

      def initialize(name, role)
        super(name)
        @api_version = "rbac.authorization.k8s.io/v1"
        @role = role
        @role_ref = {
          kind: "ClusterRole",
          name: role.respond_to?(:name) ? role.name : role,
          apiGroup: "rbac.authorization.k8s.io"
        }
        @subjects = []
      end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
metatron-0.8.2 lib/metatron/templates/cluster_role_binding.rb
metatron-0.8.0 lib/metatron/templates/cluster_role_binding.rb
metatron-0.7.0 lib/metatron/templates/cluster_role_binding.rb
metatron-0.6.1 lib/metatron/templates/cluster_role_binding.rb