Sha256: ecfee4a3a375cab9d611a006b329dd7c06264a6272d5e944f4f2febb94b3e3a4

Contents?: true

Size: 952 Bytes

Versions: 4

Compression:

Stored size: 952 Bytes

Contents

# frozen_string_literal: true

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

      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: "Role",
          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).merge(formatted_namespace).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/role_binding.rb
metatron-0.8.0 lib/metatron/templates/role_binding.rb
metatron-0.7.0 lib/metatron/templates/role_binding.rb
metatron-0.6.1 lib/metatron/templates/role_binding.rb