---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: bloxclusters.bloxcd.dev
spec:
  group: bloxcd.dev
  names:
    categories:
    - blox
    kind: BloxCluster
    plural: bloxclusters
    shortNames:
    - bxc
    singular: bloxcluster
  scope: Cluster
  versions:
  - additionalPrinterColumns:
    - jsonPath: .status.conditions[?(@.type=="Connected")].status
      name: Connected
      type: string
    - jsonPath: .status.kubernetesVersion
      name: Kubernetes
      type: string
    - jsonPath: .status.conditions[?(@.type=="Connected")].message
      name: Status
      priority: 1
      type: string
    - jsonPath: .metadata.creationTimestamp
      name: Age
      type: date
    name: v1alpha1
    schema:
      openAPIV3Schema:
        description: A BloxCluster registers a member cluster with a blox hub. Blox targets select clusters by their labels.
        properties:
          spec:
            description: 'Desired state of a `BloxCluster`: how the hub reaches the member cluster.'
            properties:
              connection:
                description: How the hub reaches this cluster. Exactly one of `agent` or `kubeconfigSecretRef`.
                properties:
                  agent:
                    description: The cluster runs `bloxd --mode=agent`, which connects to the hub (recommended).
                    nullable: true
                    type: object
                  kubeconfigSecretRef:
                    description: The hub applies to the cluster directly with this kubeconfig (push mode).
                    nullable: true
                    properties:
                      key:
                        description: Key holding the kubeconfig. Defaults to `value`, as Cluster API writes it.
                        nullable: true
                        type: string
                      name:
                        type: string
                      namespace:
                        type: string
                    required:
                    - name
                    - namespace
                    type: object
                type: object
                x-kubernetes-validations:
                - message: set exactly one of connection.agent or connection.kubeconfigSecretRef
                  rule: has(self.agent) != has(self.kubeconfigSecretRef)
            required:
            - connection
            type: object
          status:
            nullable: true
            properties:
              agentVersion:
                description: Version of `bloxd` running as this cluster's agent.
                nullable: true
                type: string
              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
              kubernetesVersion:
                description: Kubernetes version of the member cluster, e.g. `v1.34.1`.
                nullable: true
                type: string
              lastHeartbeat:
                description: When the hub last heard from the cluster.
                format: date-time
                nullable: true
                type: string
            type: object
        required:
        - spec
        title: BloxCluster
        type: object
        x-kubernetes-validations:
        - message: the name local is reserved for the hub's own cluster
          rule: self.metadata.name != 'local'
        - message: name must be at most 50 lowercase letters, digits and '-' (it names the cluster's namespace on the hub, blox-cluster-<name>)
          rule: self.metadata.name.size() <= 50 && self.metadata.name.matches('^[a-z0-9]([-a-z0-9]*[a-z0-9])?$')
    served: true
    storage: true
    subresources:
      status: {}
