---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  name: objectsyncs.sync.rustrial.org
spec:
  group: sync.rustrial.org
  names:
    kind: ObjectSync
    plural: objectsyncs
    singular: objectsync
  scope: Namespaced
  versions:
    - additionalPrinterColumns:
        - description: Whether ObjectSync is ready or not. It is considered ready if there were no errors while synchronizing the resource.
          jsonPath: ".status.conditions[?(@.type==\"Ready\")].status"
          name: Ready
          type: string
        - description: Whether all destination objects are in sync or not.
          jsonPath: ".status.conditions[?(@.type==\"InSync\")].status"
          name: InSync
          type: string
      name: v1alpha1
      schema:
        openAPIV3Schema:
          description: "Auto-generated derived type for ObjectSyncSpec via `CustomResource`"
          properties:
            spec:
              description: "Kubernetes object synchronization specification, defining how a single source object should be replicated and synced to multiple destination objects."
              properties:
                destinations:
                  description: The destinations to sync the source object to.
                  items:
                    description: Synchronization target configuration.
                    properties:
                      name:
                        description: "Optional new name for the destination object, defaults to the name of the source object."
                        nullable: true
                        type: string
                      namespace:
                        description: "The destination (target) namespace, if empty `\"\"` or `\"*\"` the source object is synced to all namespaces."
                        type: string
                      strategy:
                        description: "The sync strategy to use for this destination, defaults to \"apply\" (server side apply)."
                        enum:
                          - apply
                          - replace
                        nullable: true
                        type: string
                    required:
                      - namespace
                    type: object
                  type: array
                source:
                  description: "The \"original\" source object to be synced."
                  properties:
                    group:
                      description: The Kubernetes API Group name (without the version part).
                      type: string
                    kind:
                      description: The Kubernetes API Kind name.
                      type: string
                    name:
                      description: "The Kubernetes object's name (`metadata.name`)"
                      type: string
                    namespace:
                      description: "The Kubernetes object's namespace (`metadata.namespace`) defaults to the namespace of the `ObjectSync` object."
                      nullable: true
                      type: string
                    version:
                      description: "The Kubernetes API version, defaults to the preferred version of the API Group."
                      nullable: true
                      type: string
                  required:
                    - group
                    - kind
                    - name
                  type: object
              required:
                - destinations
                - source
              type: object
            status:
              nullable: true
              properties:
                conditions:
                  items:
                    description: We maintain our own copy of Condition as the one from k8s_openapi does not implement JsonSchema.
                    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."
                        nullable: true
                        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
                        nullable: true
                        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:
                      - message
                      - reason
                      - status
                      - type
                    type: object
                  nullable: true
                  type: array
                destinations:
                  description: "As Kubernetes does not support cross-namespace OwnerReferences and automatic garbage collection of owned objects, we keep track of all synced destination objects in the status sub-resource."
                  items:
                    description: "Synchronization target status, used to track synchronized objects."
                    properties:
                      group:
                        description: Kubernetes API Group name of the synchronization target.
                        type: string
                      kind:
                        description: Kubernetes API Kind name of the synchronization target.
                        type: string
                      name:
                        description: "Kubernetes object's name of the synchronization target."
                        type: string
                      namespace:
                        description: "Kubernetes object's namespace of the synchronization target."
                        type: string
                      sourceVersion:
                        description: The last source version observed.
                        nullable: true
                        properties:
                          resource_version:
                            description: "The Kubernetes object's `resourceVersion`."
                            nullable: true
                            type: string
                          uid:
                            description: "The Kubernetes object's `UID`."
                            nullable: true
                            type: string
                        type: object
                      strategy:
                        description: "The [`SyncStrategy`] applied to this destination."
                        enum:
                          - apply
                          - replace
                        nullable: true
                        type: string
                      syncedVersion:
                        description: "The last source version syced, `None` if not yet synced."
                        nullable: true
                        properties:
                          resource_version:
                            description: "The Kubernetes object's `resourceVersion`."
                            nullable: true
                            type: string
                          uid:
                            description: "The Kubernetes object's `UID`."
                            nullable: true
                            type: string
                        type: object
                      version:
                        description: Kubernetes API Group version of the synchronization target.
                        type: string
                    required:
                      - group
                      - kind
                      - name
                      - namespace
                      - version
                    type: object
                  nullable: true
                  type: array
              type: object
          required:
            - spec
          title: ObjectSync
          type: object
      served: true
      storage: true
      subresources:
        status: {}

