---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: bloxes.bloxcd.dev
spec:
  group: bloxcd.dev
  names:
    categories:
    - blox
    kind: Blox
    plural: bloxes
    shortNames:
    - bx
    singular: blox
  scope: Namespaced
  versions:
  - additionalPrinterColumns:
    - jsonPath: .status.conditions[?(@.type=="Ready")].status
      name: Ready
      type: string
    - jsonPath: .status.lastAppliedRevision
      name: Revision
      type: string
    - jsonPath: .status.conditions[?(@.type=="Ready")].message
      name: Status
      priority: 1
      type: string
    - jsonPath: .spec.suspend
      name: Suspended
      type: boolean
    - jsonPath: .metadata.creationTimestamp
      name: Age
      type: date
    name: v1alpha1
    schema:
      openAPIV3Schema:
        description: A Blox fetches manifests from a source, renders them, and keeps them applied to one or more clusters.
        properties:
          spec:
            description: |-
              Desired state of a `Blox`: where manifests come from, how to render them,
              and where to apply them.
            properties:
              dependsOn:
                description: Other `Blox` objects that must be `Ready` before this one is applied.
                items:
                  properties:
                    name:
                      type: string
                    namespace:
                      description: Defaults to the namespace of the depending `Blox`.
                      nullable: true
                      type: string
                  required:
                  - name
                  type: object
                type: array
              interval:
                default: 5m
                description: How often to check the source and correct drift, e.g. `5m`, `1h`.
                type: string
              notify:
                description: |-
                  Notification sinks to tell when this Blox fails, recovers or applies
                  a new revision. Sinks are named in bloxd's configuration by its admin.
                items:
                  type: string
                type: array
              prune:
                default: false
                description: Delete objects that disappear from the source (and everything on `Blox` deletion).
                type: boolean
              render:
                default: {}
                description: How to turn the source into manifests. Defaults to `plain`.
                properties:
                  helm:
                    description: |-
                      Renders a Helm chart with `helm template`; blox applies the result like
                      any other manifests (no Helm release storage, as in Argo CD). The chart
                      comes from `source.helm`, or from a directory in `source.git`. The release
                      namespace is `spec.targetNamespace`, or the Blox's own namespace.
                    nullable: true
                    properties:
                      releaseName:
                        description: Helm release name, used by most charts to name objects. Defaults to the Blox's name.
                        nullable: true
                        type: string
                      values:
                        description: Inline chart values, merged over `valuesFrom`.
                        type: object
                        x-kubernetes-preserve-unknown-fields: true
                      valuesFrom:
                        description: ConfigMaps or Secrets (in the Blox's namespace) holding values, merged in order.
                        items:
                          properties:
                            kind:
                              description: '`ConfigMap` or `Secret`.'
                              type: string
                            name:
                              type: string
                            optional:
                              description: Skip this reference if the object or key doesn't exist, instead of failing.
                              type: boolean
                            valuesKey:
                              description: Key holding the values. Defaults to `values.yaml`.
                              nullable: true
                              type: string
                          required:
                          - kind
                          - name
                          type: object
                          x-kubernetes-validations:
                          - message: valuesFrom kind must be ConfigMap or Secret
                            rule: self.kind == 'ConfigMap' || self.kind == 'Secret'
                        type: array
                    type: object
                  kustomize:
                    nullable: true
                    properties:
                      patches:
                        items:
                          properties:
                            patch:
                              description: Strategic-merge or JSON6902 patch, as in a kustomization.yaml.
                              type: string
                            target:
                              nullable: true
                              properties:
                                annotationSelector:
                                  nullable: true
                                  type: string
                                group:
                                  nullable: true
                                  type: string
                                kind:
                                  nullable: true
                                  type: string
                                labelSelector:
                                  nullable: true
                                  type: string
                                name:
                                  nullable: true
                                  type: string
                                namespace:
                                  nullable: true
                                  type: string
                                version:
                                  nullable: true
                                  type: string
                              type: object
                          required:
                          - patch
                          type: object
                        type: array
                      substitute:
                        additionalProperties:
                          type: string
                        description: Values for `${VAR}` placeholders, applied after `kustomize build`.
                        type: object
                    type: object
                  plain:
                    nullable: true
                    properties:
                      substitute:
                        additionalProperties:
                          type: string
                        description: Values for `${VAR}` placeholders in the manifests.
                        type: object
                    type: object
                type: object
                x-kubernetes-validations:
                - message: set at most one of render.plain, render.kustomize or render.helm
                  rule: '[has(self.plain), has(self.kustomize), has(self.helm)].filter(x, x).size() <= 1'
              retryInterval:
                description: How soon to retry after a failure. Defaults to `interval`.
                nullable: true
                type: string
              rollout:
                description: |-
                  Roll changes out to the placed clusters wave by wave instead of all
                  at once (needs `bloxd --mode=hub` and `wait`). A new revision or spec
                  edit reaches a wave only once every cluster in the waves before it
                  runs it and is healthy; a failure halts the rollout where it is.
                nullable: true
                properties:
                  maxUnavailableClusters:
                    default: 1
                    description: How many clusters may be updating or failing at once. Defaults to 1.
                    format: int32
                    minimum: 1.0
                    type: integer
                  waves:
                    description: |-
                      Clusters in rollout order, by label. A cluster goes in the first wave
                      that matches it; placed clusters matching none, and the hub's own
                      cluster (which has no labels), form a last wave. `{}` matches all.
                    items:
                      description: A label selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty label selector matches all objects. A null label selector matches no objects.
                      properties:
                        matchExpressions:
                          description: matchExpressions is a list of label selector requirements. The requirements are ANDed.
                          items:
                            description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.
                            properties:
                              key:
                                description: key is the label key that the selector applies to.
                                type: string
                              operator:
                                description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.
                                type: string
                              values:
                                description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.
                                items:
                                  type: string
                                type: array
                            required:
                            - key
                            - operator
                            type: object
                          type: array
                        matchLabels:
                          additionalProperties:
                            type: string
                          description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.
                          type: object
                      type: object
                    type: array
                type: object
              serviceAccountName:
                description: ServiceAccount (in this namespace) to impersonate when applying.
                nullable: true
                type: string
              source:
                description: Where the manifests come from. Exactly one of `git`, `oci` or `helm`.
                properties:
                  git:
                    nullable: true
                    properties:
                      path:
                        description: Directory inside the repository to render. Defaults to the root.
                        nullable: true
                        type: string
                      ref:
                        default: {}
                        description: Which revision to check out. Defaults to the remote HEAD.
                        properties:
                          branch:
                            description: Follow the tip of this branch, e.g. `main`.
                            nullable: true
                            type: string
                          commit:
                            description: Pin to this commit (full SHA-1).
                            nullable: true
                            type: string
                          semver:
                            description: |-
                              Follow the highest tag in this semver range, as in Flux, e.g.
                              `>=1.4.0 <2.0.0`, `1.x` or `~1.4`. Tags may have a `v` prefix. A bare
                              version (`1.4.2`) matches only that version; pre-releases only match a
                              range that names one.
                            nullable: true
                            type: string
                          tag:
                            description: Pin to this tag, e.g. `v1.4.2`.
                            nullable: true
                            type: string
                        type: object
                        x-kubernetes-validations:
                        - message: set at most one of branch, tag, semver or commit
                          rule: '[has(self.branch), has(self.tag), has(self.semver), has(self.commit)].filter(x, x).size() <= 1'
                      secretRef:
                        description: Secret with `username` and `password` (or token) for HTTPS.
                        nullable: true
                        properties:
                          name:
                            description: 'Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
                            type: string
                        required:
                        - name
                        type: object
                      url:
                        description: |-
                          `https://` repository URL. SSH isn't supported; use HTTPS with a
                          read-only token (every forge offers one).
                        type: string
                    required:
                    - url
                    type: object
                  helm:
                    description: |-
                      A chart from a Helm repository. Rendered with `render.helm`, which is
                      implied and may be left out.
                    nullable: true
                    properties:
                      chart:
                        description: Chart name, e.g. `podinfo`.
                        type: string
                      repo:
                        description: 'Chart repository: `https://…` (with an `index.yaml`) or `oci://registry/path`.'
                        type: string
                      secretRef:
                        description: Secret with `username`/`password` for the repository or registry.
                        nullable: true
                        properties:
                          name:
                            description: 'Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
                            type: string
                        required:
                        - name
                        type: object
                      version:
                        description: Exact version or semver range, e.g. `6.7.0` or `>=6.7.0 <7.0.0`. Defaults to the latest.
                        nullable: true
                        type: string
                    required:
                    - chart
                    - repo
                    type: object
                  oci:
                    description: |-
                      Manifests packaged as an OCI artifact, in the format `flux push artifact`
                      produces: one `application/vnd.cncf.flux.content.v1.tar+gzip` layer
                      holding a directory tree.
                    nullable: true
                    properties:
                      insecure:
                        description: Talk to the registry over plain HTTP. Only for registries inside the cluster.
                        type: boolean
                      path:
                        description: Directory inside the artifact to render. Defaults to the root.
                        nullable: true
                        type: string
                      ref:
                        default: {}
                        description: Which artifact to pull. Defaults to the `latest` tag.
                        properties:
                          digest:
                            description: Pin to this manifest digest, e.g. `sha256:f74f…`.
                            nullable: true
                            type: string
                          semver:
                            description: |-
                              Pull the highest tag in this semver range, with the same syntax as
                              `source.git.ref.semver`. Tags that aren't versions are ignored.
                            nullable: true
                            type: string
                          tag:
                            description: Pull this tag, e.g. `6.7.0`.
                            nullable: true
                            type: string
                        type: object
                        x-kubernetes-validations:
                        - message: set at most one of tag, semver or digest
                          rule: '[has(self.tag), has(self.semver), has(self.digest)].filter(x, x).size() <= 1'
                      secretRef:
                        description: |-
                          Secret with `username`/`password`, or a `kubernetes.io/dockerconfigjson`
                          Secret (as Flux uses) with an entry for the registry.
                        nullable: true
                        properties:
                          name:
                            description: 'Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
                            type: string
                        required:
                        - name
                        type: object
                      url:
                        description: Artifact repository, e.g. `oci://ghcr.io/org/manifests/app` (without a tag).
                        type: string
                      verify:
                        description: |-
                          Refuse the artifact unless it carries a valid signature. Same shape
                          as Flux's `OCIRepository.spec.verify`.
                        nullable: true
                        properties:
                          matchOIDCIdentity:
                            description: |-
                              Keyless (Sigstore Fulcio and Rekor): accept a signature whose
                              certificate matches any of these identities.
                            items:
                              description: Regular expressions for a keyless signer's identity.
                              properties:
                                issuer:
                                  description: The OIDC issuer, e.g. `^https://token\\.actions\\.githubusercontent\\.com$`.
                                  type: string
                                subject:
                                  description: 'The certificate subject: a workflow URL or an email address.'
                                  type: string
                              required:
                              - issuer
                              - subject
                              type: object
                            type: array
                          provider:
                            default: cosign
                            description: Signature format. Only `cosign` so far.
                            type: string
                          secretRef:
                            description: |-
                              Secret with cosign public keys: every key ending in `.pub`. A
                              signature by any of them is accepted.
                            nullable: true
                            properties:
                              name:
                                description: 'Name of the referent. This field is effectively required, but due to backwards compatibility is allowed to be empty. Instances of this type with an empty value here are almost certainly wrong. More info: https://kubernetes.io/docs/concepts/overview/working-with-objects/names/#names'
                                type: string
                            required:
                            - name
                            type: object
                        type: object
                        x-kubernetes-validations:
                        - message: verify.provider must be cosign (notation isn't supported yet)
                          rule: self.provider == 'cosign'
                        - message: verify needs a secretRef with cosign public keys, or matchOIDCIdentity for keyless signatures
                          rule: has(self.secretRef) || (has(self.matchOIDCIdentity) && size(self.matchOIDCIdentity) > 0)
                    required:
                    - url
                    type: object
                    x-kubernetes-validations:
                    - message: source.oci.url must start with oci://
                      rule: self.url.startsWith('oci://')
                type: object
                x-kubernetes-validations:
                - message: exactly one of source.git, source.oci or source.helm must be set
                  rule: '[has(self.git), has(self.oci), has(self.helm)].filter(x, x).size() == 1'
              suspend:
                default: false
                description: Stop reconciling without deleting anything.
                type: boolean
              targetNamespace:
                description: |-
                  Put every namespaced object in this namespace, overriding what the
                  manifests say. Same meaning as Flux's `targetNamespace`. The namespace
                  must exist or be created by the source.
                nullable: true
                type: string
              targets:
                description: Which clusters to apply to. Defaults to the local cluster.
                items:
                  properties:
                    clusterSelector:
                      description: |-
                        Apply to every `BloxCluster` whose labels match (needs `bloxd --mode=hub`).
                        An empty selector (`{}`) matches every cluster. A cluster matched by
                        several targets gets the first one's overrides.
                      nullable: true
                      properties:
                        matchExpressions:
                          description: matchExpressions is a list of label selector requirements. The requirements are ANDed.
                          items:
                            description: A label selector requirement is a selector that contains values, a key, and an operator that relates the key and values.
                            properties:
                              key:
                                description: key is the label key that the selector applies to.
                                type: string
                              operator:
                                description: operator represents a key's relationship to a set of values. Valid operators are In, NotIn, Exists and DoesNotExist.
                                type: string
                              values:
                                description: values is an array of string values. If the operator is In or NotIn, the values array must be non-empty. If the operator is Exists or DoesNotExist, the values array must be empty. This array is replaced during a strategic merge patch.
                                items:
                                  type: string
                                type: array
                            required:
                            - key
                            - operator
                            type: object
                          type: array
                        matchLabels:
                          additionalProperties:
                            type: string
                          description: matchLabels is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value". The requirements are ANDed.
                          type: object
                      type: object
                    local:
                      default: false
                      description: Apply to the cluster `bloxd` runs in.
                      type: boolean
                    patches:
                      description: Per-target Kustomize patches, applied after `render.kustomize.patches`.
                      items:
                        properties:
                          patch:
                            description: Strategic-merge or JSON6902 patch, as in a kustomization.yaml.
                            type: string
                          target:
                            nullable: true
                            properties:
                              annotationSelector:
                                nullable: true
                                type: string
                              group:
                                nullable: true
                                type: string
                              kind:
                                nullable: true
                                type: string
                              labelSelector:
                                nullable: true
                                type: string
                              name:
                                nullable: true
                                type: string
                              namespace:
                                nullable: true
                                type: string
                              version:
                                nullable: true
                                type: string
                            type: object
                        required:
                        - patch
                        type: object
                      type: array
                    substitute:
                      additionalProperties:
                        type: string
                      description: |-
                        Per-target `${VAR}` overrides, merged over the renderer's `substitute`
                        (plain and kustomize renders).
                      type: object
                    values:
                      description: Per-target Helm values, deep-merged over `render.helm` values.
                      type: object
                      x-kubernetes-preserve-unknown-fields: true
                  type: object
                  x-kubernetes-validations:
                  - message: 'set exactly one of local: true or clusterSelector'
                    rule: self.local != has(self.clusterSelector)
                type: array
              wait:
                description: If set, `Ready` waits for every applied object to become healthy.
                nullable: true
                properties:
                  timeout:
                    description: How long to wait for health before marking `Ready=False`. Defaults to `5m`.
                    nullable: true
                    type: string
                type: object
            required:
            - source
            type: object
          status:
            nullable: true
            properties:
              clusters:
                items:
                  description: 'One placed cluster: `local`, or the name of a `BloxCluster`.'
                  properties:
                    inventory:
                      description: |-
                        Objects applied to this cluster, for clusters the hub applies to
                        directly. The local cluster's are in `status.inventory`.
                      nullable: true
                      properties:
                        configMapRef:
                          nullable: true
                          type: string
                        count:
                          format: int64
                          type: integer
                        entries:
                          description: Applied objects. Moves to a ConfigMap (see `configMapRef`) once large (RFC §5.3).
                          items:
                            description: One applied object. `id` is `<namespace>_<name>_<group>_<Kind>`, `v` the API version.
                            properties:
                              id:
                                type: string
                              v:
                                type: string
                            required:
                            - id
                            - v
                            type: object
                          type: array
                        hooks:
                          description: |-
                            Hash of the Helm install/upgrade hook objects (`helm.sh/hook`) that were last run. Hooks run
                            again only when this changes, so a Job deleted after it finished isn't started a second time.
                          nullable: true
                          type: string
                      required:
                      - count
                      type: object
                    message:
                      nullable: true
                      type: string
                    name:
                      type: string
                    objects:
                      format: int64
                      type: integer
                    ready:
                      type: boolean
                    release:
                      description: |-
                        With `spec.rollout`: a fingerprint of the spec and revision last
                        applied here, to tell which clusters a rollout has reached.
                      nullable: true
                      type: string
                    revision:
                      description: Revision currently applied on this cluster.
                      nullable: true
                      type: string
                  required:
                  - name
                  - objects
                  - ready
                  type: object
                type: array
              conditions:
                items:
                  description: Condition contains details for one aspect of the current state of this API Resource.
                  properties:
                    lastTransitionTime:
                      description: lastTransitionTime is the last time the condition transitioned from one status to another. This should be when the underlying condition changed.  If that is not known, then using the time when the API field changed is acceptable.
                      format: date-time
                      type: string
                    message:
                      description: message is a human readable message indicating details about the transition. This may be an empty string.
                      type: string
                    observedGeneration:
                      description: observedGeneration represents the .metadata.generation that the condition was set based upon. For instance, if .metadata.generation is currently 12, but the .status.conditions[x].observedGeneration is 9, the condition is out of date with respect to the current state of the instance.
                      format: int64
                      type: integer
                    reason:
                      description: reason contains a programmatic identifier indicating the reason for the condition's last transition. Producers of specific condition types may define expected values and meanings for this field, and whether the values are considered a guaranteed API. The value should be a CamelCase string. This field may not be empty.
                      type: string
                    status:
                      description: status of the condition, one of True, False, Unknown.
                      type: string
                    type:
                      description: type of condition in CamelCase or in foo.example.com/CamelCase.
                      type: string
                  required:
                  - lastTransitionTime
                  - message
                  - reason
                  - status
                  - type
                  type: object
                type: array
              inventory:
                nullable: true
                properties:
                  configMapRef:
                    nullable: true
                    type: string
                  count:
                    format: int64
                    type: integer
                  entries:
                    description: Applied objects. Moves to a ConfigMap (see `configMapRef`) once large (RFC §5.3).
                    items:
                      description: One applied object. `id` is `<namespace>_<name>_<group>_<Kind>`, `v` the API version.
                      properties:
                        id:
                          type: string
                        v:
                          type: string
                      required:
                      - id
                      - v
                      type: object
                    type: array
                  hooks:
                    description: |-
                      Hash of the Helm install/upgrade hook objects (`helm.sh/hook`) that were last run. Hooks run
                      again only when this changes, so a Job deleted after it finished isn't started a second time.
                    nullable: true
                    type: string
                required:
                - count
                type: object
              lastAppliedRevision:
                description: Revision whose manifests are currently applied, e.g. `main@sha1:5e1a2c9`.
                nullable: true
                type: string
              lastAttemptedRevision:
                description: Revision of the most recent attempt, successful or not.
                nullable: true
                type: string
              lastHandledReconcileAt:
                description: Last `bloxcd.dev/reconcile-requested-at` value that was handled.
                nullable: true
                type: string
              observedGeneration:
                format: int64
                nullable: true
                type: integer
              rollout:
                description: Progress of `spec.rollout`.
                nullable: true
                properties:
                  clusters:
                    description: Placed clusters.
                    format: int64
                    type: integer
                  revision:
                    description: The revision being rolled out, or last rolled out.
                    type: string
                  updated:
                    description: Clusters that run the latest spec and revision and are healthy.
                    format: int64
                    type: integer
                  wave:
                    description: Wave in progress, counting from 1. Unset once every wave is done.
                    format: int64
                    nullable: true
                    type: integer
                  waves:
                    description: Number of waves with placed clusters in them.
                    format: int64
                    type: integer
                required:
                - clusters
                - revision
                - updated
                - waves
                type: object
            type: object
        required:
        - spec
        title: Blox
        type: object
        x-kubernetes-validations:
        - message: 'rollout advances wave by wave once clusters are healthy, so it needs wait (e.g. wait: {timeout: 5m})'
          rule: '!has(self.spec.rollout) || has(self.spec.wait)'
    served: true
    storage: true
    subresources:
      status: {}
