Skip to content

validating-admission-policy-binding resource

Description

ValidatingAdmissionPolicyBindingResource connects an admission policy to matching requests and optional parameter objects. It is cluster-scoped and does not create its policy or parameter objects. Validation actions are Deny, Warn and Audit; Deny and Warn cannot be combined.

Source: internal/api/admissionregistration/v1/validating_admission_policy_binding_rsrc.go:27

Example usage:

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

resources: {
  example: kubernetes-admissionregistration-v1.validating-admission-policy-binding {
    # Set input fields here.
  }
}

Inputs

metadata

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

required

spec

object
object({
  policy-name: string
  validation-actions: list(string)
  match-resources: optional(
    object({
      match-policy: optional(string)
      namespace-selector: optional(
        object({
          match-labels: optional(map(string))
          match-expressions: optional(
            list(
              object({
                key: string
                operator: string
                values: optional(list(string))
              })
            )
          )
        })
      )
      object-selector: optional(
        object({
          match-labels: optional(map(string))
          match-expressions: optional(
            list(
              object({
                key: string
                operator: string
                values: optional(list(string))
              })
            )
          )
        })
      )
      resource-rules: optional(
        list(
          object({
            api-groups: list(string)
            api-versions: list(string)
            operations: list(string)
            resources: list(string)
            resource-names: optional(list(string))
            scope: optional(string)
          })
        )
      )
      exclude-resource-rules: optional(
        list(
          object({
            api-groups: list(string)
            api-versions: list(string)
            operations: list(string)
            resources: list(string)
            resource-names: optional(list(string))
            scope: optional(string)
          })
        )
      )
    })
  )
  param-ref: optional(
    object({
      name: optional(string)
      selector: optional(
        object({
          match-labels: optional(map(string))
          match-expressions: optional(
            list(
              object({
                key: string
                operator: string
                values: optional(list(string))
              })
            )
          )
        })
      )
      namespace: optional(string)
      parameter-not-found-action: string
    })
  )
})

required

Input Constraints

Metadata rules

metadata.namespace is forbidden for this cluster-scoped binding.

Rule logic
Require
!@core.has-key(input.metadata, 'namespace')

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

Spec rules

spec.policy-name must not be empty.

Rule logic
Require
@core.length(input.spec.policy-name) >= 1

spec.validation-actions must not be empty.

Rule logic
Require
@core.length(input.spec.validation-actions) >= 1

spec.validation-actions must be unique.

Rule logic
Require
@core.is-unique(input.spec.validation-actions)

spec.validation-actions must not combine Deny and Warn.

Rule logic
Require
!(@core.has-item(input.spec.validation-actions, 'Deny') && @core.has-item(input.spec.validation-actions, 'Warn'))

invalid spec.validation-actions item.

Rule logic
For each
input.spec.validation-actions
Require
@each.value == 'Deny'
|| @each.value == 'Warn'
|| @each.value == 'Audit'

spec.param-ref requires exactly one name or selector.

Rule logic
When
input.spec.param-ref != null
Require
((input.spec.param-ref.name != null) && (input.spec.param-ref.selector == null))
|| ((input.spec.param-ref.name == null) && (input.spec.param-ref.selector != null))

spec.param-ref.name must not be empty.

Rule logic
When
input.spec.param-ref.name != null
Require
@core.length(input.spec.param-ref.name) >= 1

spec.param-ref.parameter-not-found-action must be Allow or Deny.

Rule logic
When
input.spec.param-ref != null
Require
input.spec.param-ref.parameter-not-found-action == 'Allow'
|| input.spec.param-ref.parameter-not-found-action == 'Deny'

spec.match-resources.match-policy must be Exact or Equivalent.

Rule logic
When
input.spec.match-resources.match-policy != null
Require
input.spec.match-resources.match-policy == 'Exact'
|| input.spec.match-resources.match-policy == 'Equivalent'

selector key must not be empty.

Rule logic
For each
input.spec.match-resources.namespace-selector.match-expressions ?? []
Require
@core.length(@each.value.key) >= 1

invalid selector operator.

Rule logic
For each
input.spec.match-resources.namespace-selector.match-expressions ?? []
Require
@each.value.operator == 'In'
|| @each.value.operator == 'NotIn'
|| @each.value.operator == 'Exists'
|| @each.value.operator == 'DoesNotExist'

selector operator requires values.

Rule logic
For each
input.spec.match-resources.namespace-selector.match-expressions ?? []
When
@each.value.operator == 'In'
|| @each.value.operator == 'NotIn'
Require
@core.length(@each.value.values ?? []) >= 1

selector operator forbids values.

Rule logic
For each
input.spec.match-resources.namespace-selector.match-expressions ?? []
When
@each.value.operator == 'Exists'
|| @each.value.operator == 'DoesNotExist'
Require
@core.length(@each.value.values ?? []) <= 0

selector key must not be empty.

Rule logic
For each
input.spec.match-resources.object-selector.match-expressions ?? []
Require
@core.length(@each.value.key) >= 1

invalid selector operator.

Rule logic
For each
input.spec.match-resources.object-selector.match-expressions ?? []
Require
@each.value.operator == 'In'
|| @each.value.operator == 'NotIn'
|| @each.value.operator == 'Exists'
|| @each.value.operator == 'DoesNotExist'

selector operator requires values.

Rule logic
For each
input.spec.match-resources.object-selector.match-expressions ?? []
When
@each.value.operator == 'In'
|| @each.value.operator == 'NotIn'
Require
@core.length(@each.value.values ?? []) >= 1

selector operator forbids values.

Rule logic
For each
input.spec.match-resources.object-selector.match-expressions ?? []
When
@each.value.operator == 'Exists'
|| @each.value.operator == 'DoesNotExist'
Require
@core.length(@each.value.values ?? []) <= 0

selector key must not be empty.

Rule logic
For each
input.spec.param-ref.selector.match-expressions ?? []
Require
@core.length(@each.value.key) >= 1

invalid selector operator.

Rule logic
For each
input.spec.param-ref.selector.match-expressions ?? []
Require
@each.value.operator == 'In'
|| @each.value.operator == 'NotIn'
|| @each.value.operator == 'Exists'
|| @each.value.operator == 'DoesNotExist'

selector operator requires values.

Rule logic
For each
input.spec.param-ref.selector.match-expressions ?? []
When
@each.value.operator == 'In'
|| @each.value.operator == 'NotIn'
Require
@core.length(@each.value.values ?? []) >= 1

selector operator forbids values.

Rule logic
For each
input.spec.param-ref.selector.match-expressions ?? []
When
@each.value.operator == 'Exists'
|| @each.value.operator == 'DoesNotExist'
Require
@core.length(@each.value.values ?? []) <= 0

rule.api-groups must not be empty.

Rule logic
For each
input.spec.match-resources.resource-rules ?? []
Require
@core.length(@each.value.api-groups) >= 1

rule.api-versions must not be empty.

Rule logic
For each
input.spec.match-resources.resource-rules ?? []
Require
@core.length(@each.value.api-versions) >= 1

rule.operations must not be empty.

Rule logic
For each
input.spec.match-resources.resource-rules ?? []
Require
@core.length(@each.value.operations) >= 1

rule.resources must not be empty.

Rule logic
For each
input.spec.match-resources.resource-rules ?? []
Require
@core.length(@each.value.resources) >= 1

rule.api-groups wildcard must be the only item.

Rule logic
For each
input.spec.match-resources.resource-rules ?? []
When
@core.has-item(@each.value.api-groups, '*')
Require
@core.length(@each.value.api-groups) <= 1

rule.api-versions wildcard must be the only item.

Rule logic
For each
input.spec.match-resources.resource-rules ?? []
When
@core.has-item(@each.value.api-versions, '*')
Require
@core.length(@each.value.api-versions) <= 1

rule.operations wildcard must be the only item.

Rule logic
For each
input.spec.match-resources.resource-rules ?? []
When
@core.has-item(@each.value.operations, '*')
Require
@core.length(@each.value.operations) <= 1

invalid rule.scope.

Rule logic
For each
input.spec.match-resources.resource-rules ?? []
When
@each.value.scope != null
Require
@each.value.scope == 'Cluster'
|| @each.value.scope == 'Namespaced'
|| @each.value.scope == '*'

invalid rule.operations item.

Rule logic
For each
@rule in input.spec.match-resources.resource-rules ?? []
@operation in @rule.value.operations
Require
@operation.value == 'CREATE'
|| @operation.value == 'UPDATE'
|| @operation.value == 'DELETE'
|| @operation.value == 'CONNECT'
|| @operation.value == '*'

rule.api-versions item must not be empty.

Rule logic
For each
@rule in input.spec.match-resources.resource-rules ?? []
@item in @rule.value.api-versions
Require
@core.length(@item.value) >= 1

rule.resources item must not be empty.

Rule logic
For each
@rule in input.spec.match-resources.resource-rules ?? []
@item in @rule.value.resources
Require
@core.length(@item.value) >= 1

rule.api-groups must not be empty.

Rule logic
For each
input.spec.match-resources.exclude-resource-rules ?? []
Require
@core.length(@each.value.api-groups) >= 1

rule.api-versions must not be empty.

Rule logic
For each
input.spec.match-resources.exclude-resource-rules ?? []
Require
@core.length(@each.value.api-versions) >= 1

rule.operations must not be empty.

Rule logic
For each
input.spec.match-resources.exclude-resource-rules ?? []
Require
@core.length(@each.value.operations) >= 1

rule.resources must not be empty.

Rule logic
For each
input.spec.match-resources.exclude-resource-rules ?? []
Require
@core.length(@each.value.resources) >= 1

rule.api-groups wildcard must be the only item.

Rule logic
For each
input.spec.match-resources.exclude-resource-rules ?? []
When
@core.has-item(@each.value.api-groups, '*')
Require
@core.length(@each.value.api-groups) <= 1

rule.api-versions wildcard must be the only item.

Rule logic
For each
input.spec.match-resources.exclude-resource-rules ?? []
When
@core.has-item(@each.value.api-versions, '*')
Require
@core.length(@each.value.api-versions) <= 1

rule.operations wildcard must be the only item.

Rule logic
For each
input.spec.match-resources.exclude-resource-rules ?? []
When
@core.has-item(@each.value.operations, '*')
Require
@core.length(@each.value.operations) <= 1

invalid rule.scope.

Rule logic
For each
input.spec.match-resources.exclude-resource-rules ?? []
When
@each.value.scope != null
Require
@each.value.scope == 'Cluster'
|| @each.value.scope == 'Namespaced'
|| @each.value.scope == '*'

invalid rule.operations item.

Rule logic
For each
@rule in input.spec.match-resources.exclude-resource-rules ?? []
@operation in @rule.value.operations
Require
@operation.value == 'CREATE'
|| @operation.value == 'UPDATE'
|| @operation.value == 'DELETE'
|| @operation.value == 'CONNECT'
|| @operation.value == '*'

rule.api-versions item must not be empty.

Rule logic
For each
@rule in input.spec.match-resources.exclude-resource-rules ?? []
@item in @rule.value.api-versions
Require
@core.length(@item.value) >= 1

rule.resources item must not be empty.

Rule logic
For each
@rule in input.spec.match-resources.exclude-resource-rules ?? []
@item in @rule.value.resources
Require
@core.length(@item.value) >= 1

Outputs

server

string

api-version

string

kind

string

name

string

uid

string

metadata

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

spec

object
object({
  policy-name: string
  validation-actions: list(string)
  match-resources: optional(
    object({
      match-policy: optional(string)
      namespace-selector: optional(
        object({
          match-labels: optional(map(string))
          match-expressions: optional(
            list(
              object({
                key: string
                operator: string
                values: optional(list(string))
              })
            )
          )
        })
      )
      object-selector: optional(
        object({
          match-labels: optional(map(string))
          match-expressions: optional(
            list(
              object({
                key: string
                operator: string
                values: optional(list(string))
              })
            )
          )
        })
      )
      resource-rules: optional(
        list(
          object({
            api-groups: list(string)
            api-versions: list(string)
            operations: list(string)
            resources: list(string)
            resource-names: optional(list(string))
            scope: optional(string)
          })
        )
      )
      exclude-resource-rules: optional(
        list(
          object({
            api-groups: list(string)
            api-versions: list(string)
            operations: list(string)
            resources: list(string)
            resource-names: optional(list(string))
            scope: optional(string)
          })
        )
      )
    })
  )
  param-ref: optional(
    object({
      name: optional(string)
      selector: optional(
        object({
          match-labels: optional(map(string))
          match-expressions: optional(
            list(
              object({
                key: string
                operator: string
                values: optional(list(string))
              })
            )
          )
        })
      )
      namespace: optional(string)
      parameter-not-found-action: string
    })
  )
})