Sha256: 06da10f91eb9f44e8055c6b5a7e509e9dadc8748950de38452e4bb3cf12c86db

Contents?: true

Size: 935 Bytes

Versions: 11

Compression:

Stored size: 935 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: { "#{label_namespace}/name": name }.merge(additional_labels)
          }.merge(formatted_annotations).compact,
          roleRef:,
          subjects:
        }.compact
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
metatron-0.6.0 lib/metatron/templates/cluster_role_binding.rb
metatron-0.5.0 lib/metatron/templates/cluster_role_binding.rb
metatron-0.4.2 lib/metatron/templates/cluster_role_binding.rb
metatron-0.4.1 lib/metatron/templates/cluster_role_binding.rb
metatron-0.4.0 lib/metatron/templates/cluster_role_binding.rb
metatron-0.3.4 lib/metatron/templates/cluster_role_binding.rb
metatron-0.3.3 lib/metatron/templates/cluster_role_binding.rb
metatron-0.3.2 lib/metatron/templates/cluster_role_binding.rb
metatron-0.3.1 lib/metatron/templates/cluster_role_binding.rb
metatron-0.3.0 lib/metatron/templates/cluster_role_binding.rb
metatron-0.2.8 lib/metatron/templates/cluster_role_binding.rb