---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
  annotations:
    controller-gen.kubebuilder.io/version: v0.16.0
  name: resourceoverridesnapshots.placement.kubernetes-fleet.io
spec:
  group: placement.kubernetes-fleet.io
  names:
    categories:
    - fleet
    - fleet-placement
    kind: ResourceOverrideSnapshot
    listKind: ResourceOverrideSnapshotList
    plural: resourceoverridesnapshots
    singular: resourceoverridesnapshot
  scope: Namespaced
  versions:
  - name: v1alpha1
    schema:
      openAPIV3Schema:
        description: |-
          ResourceOverrideSnapshot is used to store a snapshot of ResourceOverride.
          Its spec is immutable.
          We assign an ever-increasing index for snapshots.
          The naming convention of a ResourceOverrideSnapshot is {ResourceOverride}-{resourceIndex}.
          resourceIndex will begin with 0.
          Each snapshot MUST have the following labels:
            - `OverrideTrackingLabel` which points to its owner ResourceOverride.
            - `IsLatestSnapshotLabel` which indicates whether the snapshot is the latest one.
        properties:
          apiVersion:
            description: |-
              APIVersion defines the versioned schema of this representation of an object.
              Servers should convert recognized schemas to the latest internal value, and
              may reject unrecognized values.
              More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
            type: string
          kind:
            description: |-
              Kind is a string value representing the REST resource this object represents.
              Servers may infer this from the endpoint the client submits requests to.
              Cannot be updated.
              In CamelCase.
              More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
            type: string
          metadata:
            type: object
          spec:
            description: The desired state of ResourceOverrideSnapshot.
            properties:
              overrideHash:
                description: OverrideHash is the sha-256 hash value of the OverrideSpec
                  field.
                format: byte
                type: string
              overrideSpec:
                description: OverrideSpec stores the spec of ResourceOverride.
                properties:
                  placement:
                    description: |-
                      Placement defines whether the override is applied to a specific placement or not.
                      If set, the override will trigger the placement rollout immediately when the rollout strategy type is RollingUpdate.
                      Otherwise, it will be applied to the next rollout.
                      The recommended way is to set the placement so that the override can be rolled out immediately.
                    properties:
                      name:
                        description: Name is the reference to the name of placement.
                        type: string
                    required:
                    - name
                    type: object
                  policy:
                    description: Policy defines how to override the selected resources
                      on the target clusters.
                    properties:
                      overrideRules:
                        description: |-
                          OverrideRules defines an array of override rules to be applied on the selected resources.
                          The order of the rules determines the override order.
                          When there are two rules selecting the same fields on the target cluster, the last one will win.
                          You can have 1-20 rules.
                        items:
                          description: OverrideRule defines how to override the selected
                            resources on the target clusters.
                          properties:
                            clusterSelector:
                              description: |-
                                ClusterSelectors selects the target clusters.
                                The resources will be overridden before applying to the matching clusters.
                                An empty clusterSelector selects ALL the member clusters.
                                A nil clusterSelector selects NO member clusters.
                                For now, only labelSelector is supported.
                              properties:
                                clusterSelectorTerms:
                                  description: ClusterSelectorTerms is a list of cluster
                                    selector terms. The terms are `ORed`.
                                  items:
                                    properties:
                                      labelSelector:
                                        description: |-
                                          LabelSelector is a label query over all the joined member clusters. Clusters matching
                                          the query are selected.

                                          If you specify both label and property selectors in the same term, the results are AND'd.
                                        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
                                                  x-kubernetes-list-type: atomic
                                              required:
                                              - key
                                              - operator
                                              type: object
                                            type: array
                                            x-kubernetes-list-type: atomic
                                          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
                                        x-kubernetes-map-type: atomic
                                      propertySelector:
                                        description: |-
                                          PropertySelector is a property query over all joined member clusters. Clusters matching
                                          the query are selected.

                                          If you specify both label and property selectors in the same term, the results are AND'd.

                                          At this moment, PropertySelector can only be used with
                                          `RequiredDuringSchedulingIgnoredDuringExecution` affinity terms.

                                          This field is beta-level; it is for the property-based scheduling feature and is only
                                          functional when a property provider is enabled in the deployment.
                                        properties:
                                          matchExpressions:
                                            description: MatchExpressions is an array
                                              of PropertySelectorRequirements. The
                                              requirements are AND'd.
                                            items:
                                              description: |-
                                                PropertySelectorRequirement is a specific property requirement when picking clusters for
                                                resource placement.
                                              properties:
                                                name:
                                                  description: Name is the name of
                                                    the property; it should be a Kubernetes
                                                    label name.
                                                  type: string
                                                operator:
                                                  description: |-
                                                    Operator specifies the relationship between a cluster's observed value of the specified
                                                    property and the values given in the requirement.
                                                  type: string
                                                values:
                                                  description: |-
                                                    Values are a list of values of the specified property which Fleet will compare against
                                                    the observed values of individual member clusters in accordance with the given
                                                    operator.

                                                    At this moment, each value should be a Kubernetes quantity. For more information, see
                                                    https://pkg.go.dev/k8s.io/apimachinery/pkg/api/resource#Quantity.

                                                    If the operator is Gt (greater than), Ge (greater than or equal to), Lt (less than),
                                                    or `Le` (less than or equal to), Eq (equal to), or Ne (ne), exactly one value must be
                                                    specified in the list.
                                                  items:
                                                    type: string
                                                  maxItems: 1
                                                  type: array
                                              required:
                                              - name
                                              - operator
                                              - values
                                              type: object
                                            type: array
                                        required:
                                        - matchExpressions
                                        type: object
                                      propertySorter:
                                        description: |-
                                          PropertySorter sorts all matching clusters by a specific property and assigns different weights
                                          to each cluster based on their observed property values.

                                          At this moment, PropertySorter can only be used with
                                          `PreferredDuringSchedulingIgnoredDuringExecution` affinity terms.

                                          This field is beta-level; it is for the property-based scheduling feature and is only
                                          functional when a property provider is enabled in the deployment.
                                        properties:
                                          name:
                                            description: Name is the name of the property
                                              which Fleet sorts clusters by.
                                            type: string
                                          sortOrder:
                                            description: |-
                                              SortOrder explains how Fleet should perform the sort; specifically, whether Fleet should
                                              sort in ascending or descending order.
                                            type: string
                                        required:
                                        - name
                                        - sortOrder
                                        type: object
                                    type: object
                                  maxItems: 10
                                  type: array
                              required:
                              - clusterSelectorTerms
                              type: object
                            jsonPatchOverrides:
                              description: |-
                                JSONPatchOverrides defines a list of JSON patch override rules.
                                This field is only allowed when OverrideType is JSONPatch.
                              items:
                                description: JSONPatchOverride applies a JSON patch
                                  on the selected resources following [RFC 6902](https://datatracker.ietf.org/doc/html/rfc6902).
                                properties:
                                  op:
                                    description: Operator defines the operation on
                                      the target field.
                                    enum:
                                    - add
                                    - remove
                                    - replace
                                    type: string
                                  path:
                                    description: |-
                                      Path defines the target location.
                                      Note: override will fail if the resource path does not exist.
                                    type: string
                                  value:
                                    description: |-
                                      Value defines the content to be applied on the target location.
                                      Value should be empty when operator is `remove`.
                                      We have reserved a few variables in this field that will be replaced by the actual values.
                                      Those variables all start with `$` and are case sensitive.
                                      Here is the list of currently supported variables:
                                      `${MEMBER-CLUSTER-NAME}`:  this will be replaced by the name of the memberCluster CR that represents this cluster.
                                    x-kubernetes-preserve-unknown-fields: true
                                required:
                                - op
                                - path
                                type: object
                              maxItems: 20
                              minItems: 1
                              type: array
                            overrideType:
                              default: JSONPatch
                              description: OverrideType defines the type of the override
                                rules.
                              enum:
                              - JSONPatch
                              - Delete
                              type: string
                          type: object
                        maxItems: 20
                        minItems: 1
                        type: array
                    required:
                    - overrideRules
                    type: object
                  resourceSelectors:
                    description: |-
                      ResourceSelectors is an array of selectors used to select namespace scoped resources. The selectors are `ORed`.
                      You can have 1-20 selectors.
                    items:
                      description: |-
                        ResourceSelector is used to select namespace scoped resources as the target resources to be placed.
                        All the fields are `ANDed`. In other words, a resource must match all the fields to be selected.
                        The resource namespace will inherit from the parent object scope.
                      properties:
                        group:
                          description: |-
                            Group name of the namespace-scoped resource.
                            Use an empty string to select resources under the core API group (e.g., services).
                          type: string
                        kind:
                          description: Kind of the namespace-scoped resource.
                          type: string
                        name:
                          description: Name of the namespace-scoped resource.
                          type: string
                        version:
                          description: Version of the namespace-scoped resource.
                          type: string
                      required:
                      - group
                      - kind
                      - name
                      - version
                      type: object
                    maxItems: 20
                    minItems: 1
                    type: array
                required:
                - policy
                - resourceSelectors
                type: object
            required:
            - overrideHash
            - overrideSpec
            type: object
        required:
        - spec
        type: object
    served: true
    storage: true
