Skip to content

cluster-role resource

Description

ClusterRoleResource manages a cluster-scoped RBAC ClusterRole with JSON Patch. Writes refresh remote values without waiting for aggregation controllers. Delete returns after the API accepts the request. Each operation has a 20-minute deadline, subject to an earlier caller deadline or cancellation.

Source: internal/api/rbac/v1/cluster_role_rsrc.go:27

Example usage:

imports: {
  kubernetes-rbac-v1: 'github.com/cloudboss/unobin-library-kubernetes//api/rbac/v1'
}

resources: {
  example: kubernetes-rbac-v1.cluster-role {
    # Set input fields here.
  }
}

Inputs

metadata

object
object({
  name: optional(string)
  generate-name: optional(string)
  annotations: optional(map(string))
  labels: optional(map(string))
})

required

Metadata selects immutable name or generated-name prefix and managed maps.

rule

optional(list(object))
optional(
  list(
    object({
      verbs: list(string)
      api-groups: optional(list(string))
      resources: optional(list(string))
      resource-names: optional(list(string))
      non-resource-urls: optional(list(string))
    })
  )
)

Rule preserves order and duplicates. Omission or an empty list leaves existing rules unmanaged and exposes remote rules, including aggregation.

aggregation-rule

optional(object)
optional(
  object({
    cluster-role-selectors: optional(
      list(
        object({
          match-labels: optional(map(string))
          match-expressions: optional(
            list(
              object({
                key: optional(string)
                operator: optional(string)
                values: optional(list(string))
              })
            )
          )
        })
      )
    )
  })
)

AggregationRule selects ClusterRoles whose permissions a controller combines. Removing it replaces the remote aggregation with an empty object.

ignore-annotations

optional(list(string))

IgnoreAnnotations filters untracked annotation keys during reads.

ignore-labels

optional(list(string))

IgnoreLabels filters untracked label keys during reads.

Input Constraints

Metadata rules

Exactly one of metadata.name or metadata.generate-name.

metadata.name must not be empty.

Rule logic
When
input.metadata.name != null
Require
@core.length(input.metadata.name) >= 1

metadata.generate-name must not be empty.

Rule logic
When
input.metadata.generate-name != null
Require
@core.length(input.metadata.generate-name) >= 1

metadata.name must be an RBAC path segment.

Rule logic
Require
@core.is-match(input.metadata.name, '^[^/%]*$')
&& !(input.metadata.name == '.' || input.metadata.name == '..')

metadata.generate-name must be an RBAC path segment.

Rule logic
Require
@core.is-match(input.metadata.generate-name, '^[^/%]*$')
&& !(input.metadata.generate-name == '.' || input.metadata.generate-name == '..')

metadata.labels keys must be Kubernetes qualified names.

Rule logic
For each
input.metadata.labels ?? {}
Require
@core.is-match(@each.key, '^([a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*/)?[A-Za-z0-9]([-A-Za-z0-9_.]{0,61}[A-Za-z0-9])?$')
&& @core.is-match(@each.key, '^([^/]{1,253}/)?[^/]+$')

metadata.labels values must be valid Kubernetes label values.

Rule logic
For each
input.metadata.labels ?? {}
Require
@core.is-match(@each.value, '^([A-Za-z0-9]([-A-Za-z0-9_.]{0,61}[A-Za-z0-9])?)?$')

metadata.annotations keys must be qualified names after lowercasing.

Rule logic
For each
input.metadata.annotations ?? {}
Require
@core.is-match(@each.key, '^([A-Za-z0-9İK]([-A-Za-z0-9İK]*[A-Za-z0-9İK])?(\\.[A-Za-z0-9İK]([-A-Za-z0-9İK]*[A-Za-z0-9İK])?)*/)?[A-Za-z0-9İK]([-A-Za-z0-9İK_.]{0,61}[A-Za-z0-9İK])?$')
&& @core.is-match(@each.key, '^([^/]{1,253}/)?[^/]+$')

Ignore annotations rules

ignore-annotations entries must be valid regular expressions.

Rule logic
For each
input.ignore-annotations ?? []
Require
@core.is-format(@each.value, 'regex')

Ignore labels rules

ignore-labels entries must be valid regular expressions.

Rule logic
For each
input.ignore-labels ?? []
Require
@core.is-format(@each.value, 'regex')

Rule rules

Conditional requirement.

Rule logic
For each
input.rule ?? []
When
@each.value.api-groups != null
Require
@core.length(@each.value.api-groups) >= 1

Outputs

server

string

api-version

string

kind

string

name

string

uid

string

metadata

object
object({
  name: string
  generate-name: string
  annotations: map(string)
  labels: map(string)
})

rule

list(object)
list(
  object({
    verbs: list(string)
    api-groups: list(string)
    resources: list(string)
    resource-names: list(string)
    non-resource-urls: list(string)
  })
)

aggregation-rule

optional(object)
optional(
  object({
    cluster-role-selectors: list(
      object({
        match-labels: map(string)
        match-expressions: list(
          object({
            key: string
            operator: string
            values: list(string)
          })
        )
      })
    )
  })
)