{
  "description": "SveltosCluster is the Schema for the SveltosCluster API",
  "properties": {
    "apiVersion": {
      "description": "APIVersion defines the versioned schema of this representation of an object.\nServers should convert recognized schemas to the latest internal value, and\nmay reject unrecognized values.\nMore 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.\nServers may infer this from the endpoint the client submits requests to.\nCannot be updated.\nIn CamelCase.\nMore info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds",
      "type": "string"
    },
    "metadata": {
      "type": "object"
    },
    "spec": {
      "description": "SveltosClusterSpec defines the desired state of SveltosCluster",
      "properties": {
        "activeWindow": {
          "description": "ActiveWindow is an optional field for automatically pausing and unpausing\nthe cluster.\nIf not specified, the cluster will not be paused or unpaused automatically.",
          "properties": {
            "from": {
              "description": "From in Cron format, see https://en.wikipedia.org/wiki/Cron.\nIndicates when to un-pause the cluster (cluster in paused state receives no update from sveltos).",
              "minLength": 1,
              "type": "string"
            },
            "to": {
              "description": "To in Cron format, see https://en.wikipedia.org/Cron.\nIndicates when to pause the cluster (cluster in paused state receives no update from sveltos).",
              "minLength": 1,
              "type": "string"
            }
          },
          "required": [
            "from",
            "to"
          ],
          "type": "object",
          "additionalProperties": false
        },
        "consecutiveFailureThreshold": {
          "default": 3,
          "description": "ConsecutiveFailureThreshold is the maximum number of consecutive connection\nfailures before setting the problem status in Status.ConnectionStatus",
          "type": "integer"
        },
        "data": {
          "additionalProperties": {
            "type": "string"
          },
          "description": "ArbitraryData allows for arbitrary nested structures",
          "type": "object"
        },
        "kubeconfigKeyName": {
          "description": "KubeconfigKeyName specifies the key within the Secret that holds the kubeconfig.\nIf not specified, Sveltos will use first key in the Secret.",
          "type": "string"
        },
        "kubeconfigName": {
          "description": "KubeconfigName allows overriding the default Sveltos convention which expected a valid kubeconfig\nto be hosted in a secret with the pattern ${sveltosClusterName}-sveltos-kubeconfig.\n\nWhen a value is specified, the referenced Kubernetes Secret object must exist,\nand will be used to connect to the Kubernetes cluster.",
          "type": "string"
        },
        "livenessChecks": {
          "description": "LivenessChecks is an optional list of custom checks to verify cluster\nis healthy",
          "items": {
            "properties": {
              "condition": {
                "description": "This field is  used to specify a Lua function that will be used to evaluate\nthis check.\nThe function will receive the array of resources selected by ResourceSelectors.\nThe Lua function name is evaluate and must return a struct with:\n- \"result\" field: boolean indicating whether check passed or failed;\n- \"message\" field: (optional) message.",
                "type": "string"
              },
              "name": {
                "description": "Name of the cluster check.\nMust be a DNS_LABEL and unique within the ClusterChecks.",
                "type": "string"
              },
              "resourceSelectors": {
                "description": "ResourceSelectors identifies what Kubernetes resources to select",
                "items": {
                  "description": "ResourceSelector defines what resources are a match",
                  "properties": {
                    "evaluate": {
                      "description": "Evaluate contains a function \"evaluate\" in lua language.\nThe function will be passed one of the object selected based on\nabove criteria.\nMust return struct with field \"matching\" representing whether\nobject is a match and an optional \"message\" field.",
                      "type": "string"
                    },
                    "evaluateCEL": {
                      "description": "EvaluateCEL contains a list of named CEL (Common Expression Language) rules.\nEach rule will be evaluated in order against each object selected based on\nthe criteria defined above. Each rule's expression must return a boolean value\nindicating whether the object is a match.\n\nEvaluation stops at the first rule that returns true; subsequent\nrules will not be evaluated.",
                      "items": {
                        "description": "CELRule defines a named CEL rule used in EvaluateCEL.",
                        "properties": {
                          "name": {
                            "description": "Name is a human-readable identifier for the rule.",
                            "type": "string"
                          },
                          "rule": {
                            "description": "Rule is the CEL (Common Expression Language) expression to evaluate.\nIt must return a bool",
                            "type": "string"
                          }
                        },
                        "required": [
                          "name",
                          "rule"
                        ],
                        "type": "object",
                        "additionalProperties": false
                      },
                      "type": "array"
                    },
                    "group": {
                      "description": "Group of the resource deployed in the Cluster.",
                      "type": "string"
                    },
                    "kind": {
                      "description": "Kind of the resource deployed in the Cluster.",
                      "minLength": 1,
                      "type": "string"
                    },
                    "labelFilters": {
                      "description": "LabelFilters allows to filter resources based on current labels.",
                      "items": {
                        "properties": {
                          "key": {
                            "description": "Key is the label key",
                            "type": "string"
                          },
                          "operation": {
                            "description": "Operation is the comparison operation",
                            "enum": [
                              "Equal",
                              "Different",
                              "Has",
                              "DoesNotHave"
                            ],
                            "type": "string"
                          },
                          "value": {
                            "description": "Value is the label value",
                            "type": "string"
                          }
                        },
                        "required": [
                          "key",
                          "operation"
                        ],
                        "type": "object",
                        "additionalProperties": false
                      },
                      "type": "array"
                    },
                    "name": {
                      "description": "Name of the resource deployed in the  Cluster.",
                      "type": "string"
                    },
                    "namespace": {
                      "description": "Namespace of the resource deployed in the  Cluster.\nEmpty for resources scoped at cluster level.\nFor namespaced resources, an empty string \"\" indicates all namespaces.",
                      "type": "string"
                    },
                    "selector": {
                      "description": "Selector is a standard Kubernetes label selector. Resources are selected\nif their labels match the selector. This field uses the standard\nKubernetes label matching syntax (e.g., {\"environment\": \"production\"}).\nIf both LabelFilters and Selector are specified, the requirements from\nboth are logically ANDed.",
                      "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\nrelates 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.\nValid 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,\nthe values array must be non-empty. If the operator is Exists or DoesNotExist,\nthe values array must be empty. This array is replaced during a strategic\nmerge patch.",
                                "items": {
                                  "type": "string"
                                },
                                "type": "array",
                                "x-kubernetes-list-type": "atomic"
                              }
                            },
                            "required": [
                              "key",
                              "operator"
                            ],
                            "type": "object",
                            "additionalProperties": false
                          },
                          "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\nmap is equivalent to an element of matchExpressions, whose key field is \"key\", the\noperator is \"In\", and the values array contains only \"value\". The requirements are ANDed.",
                          "type": "object"
                        }
                      },
                      "type": "object",
                      "x-kubernetes-map-type": "atomic",
                      "additionalProperties": false
                    },
                    "version": {
                      "description": "Version of the resource deployed in the Cluster.",
                      "type": "string"
                    }
                  },
                  "required": [
                    "group",
                    "kind",
                    "version"
                  ],
                  "type": "object",
                  "additionalProperties": false
                },
                "type": "array"
              }
            },
            "required": [
              "condition",
              "name",
              "resourceSelectors"
            ],
            "type": "object",
            "additionalProperties": false
          },
          "type": "array"
        },
        "paused": {
          "description": "Paused can be used to prevent controllers from processing the\nSveltosCluster and all its associated objects.",
          "type": "boolean"
        },
        "pullMode": {
          "default": false,
          "description": "PullMode indicates whether the cluster is in pull mode.\nIf true, the agent in the managed cluster will fetch the configuration.\nIf false (default), the management cluster will push the configuration.",
          "type": "boolean",
          "x-kubernetes-validations": [
            {
              "message": "Value is immutable",
              "rule": "self == oldSelf"
            }
          ]
        },
        "readinessChecks": {
          "description": "ReadinessChecks is an optional list of custom checks to verify cluster\nreadiness",
          "items": {
            "properties": {
              "condition": {
                "description": "This field is  used to specify a Lua function that will be used to evaluate\nthis check.\nThe function will receive the array of resources selected by ResourceSelectors.\nThe Lua function name is evaluate and must return a struct with:\n- \"result\" field: boolean indicating whether check passed or failed;\n- \"message\" field: (optional) message.",
                "type": "string"
              },
              "name": {
                "description": "Name of the cluster check.\nMust be a DNS_LABEL and unique within the ClusterChecks.",
                "type": "string"
              },
              "resourceSelectors": {
                "description": "ResourceSelectors identifies what Kubernetes resources to select",
                "items": {
                  "description": "ResourceSelector defines what resources are a match",
                  "properties": {
                    "evaluate": {
                      "description": "Evaluate contains a function \"evaluate\" in lua language.\nThe function will be passed one of the object selected based on\nabove criteria.\nMust return struct with field \"matching\" representing whether\nobject is a match and an optional \"message\" field.",
                      "type": "string"
                    },
                    "evaluateCEL": {
                      "description": "EvaluateCEL contains a list of named CEL (Common Expression Language) rules.\nEach rule will be evaluated in order against each object selected based on\nthe criteria defined above. Each rule's expression must return a boolean value\nindicating whether the object is a match.\n\nEvaluation stops at the first rule that returns true; subsequent\nrules will not be evaluated.",
                      "items": {
                        "description": "CELRule defines a named CEL rule used in EvaluateCEL.",
                        "properties": {
                          "name": {
                            "description": "Name is a human-readable identifier for the rule.",
                            "type": "string"
                          },
                          "rule": {
                            "description": "Rule is the CEL (Common Expression Language) expression to evaluate.\nIt must return a bool",
                            "type": "string"
                          }
                        },
                        "required": [
                          "name",
                          "rule"
                        ],
                        "type": "object",
                        "additionalProperties": false
                      },
                      "type": "array"
                    },
                    "group": {
                      "description": "Group of the resource deployed in the Cluster.",
                      "type": "string"
                    },
                    "kind": {
                      "description": "Kind of the resource deployed in the Cluster.",
                      "minLength": 1,
                      "type": "string"
                    },
                    "labelFilters": {
                      "description": "LabelFilters allows to filter resources based on current labels.",
                      "items": {
                        "properties": {
                          "key": {
                            "description": "Key is the label key",
                            "type": "string"
                          },
                          "operation": {
                            "description": "Operation is the comparison operation",
                            "enum": [
                              "Equal",
                              "Different",
                              "Has",
                              "DoesNotHave"
                            ],
                            "type": "string"
                          },
                          "value": {
                            "description": "Value is the label value",
                            "type": "string"
                          }
                        },
                        "required": [
                          "key",
                          "operation"
                        ],
                        "type": "object",
                        "additionalProperties": false
                      },
                      "type": "array"
                    },
                    "name": {
                      "description": "Name of the resource deployed in the  Cluster.",
                      "type": "string"
                    },
                    "namespace": {
                      "description": "Namespace of the resource deployed in the  Cluster.\nEmpty for resources scoped at cluster level.\nFor namespaced resources, an empty string \"\" indicates all namespaces.",
                      "type": "string"
                    },
                    "selector": {
                      "description": "Selector is a standard Kubernetes label selector. Resources are selected\nif their labels match the selector. This field uses the standard\nKubernetes label matching syntax (e.g., {\"environment\": \"production\"}).\nIf both LabelFilters and Selector are specified, the requirements from\nboth are logically ANDed.",
                      "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\nrelates 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.\nValid 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,\nthe values array must be non-empty. If the operator is Exists or DoesNotExist,\nthe values array must be empty. This array is replaced during a strategic\nmerge patch.",
                                "items": {
                                  "type": "string"
                                },
                                "type": "array",
                                "x-kubernetes-list-type": "atomic"
                              }
                            },
                            "required": [
                              "key",
                              "operator"
                            ],
                            "type": "object",
                            "additionalProperties": false
                          },
                          "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\nmap is equivalent to an element of matchExpressions, whose key field is \"key\", the\noperator is \"In\", and the values array contains only \"value\". The requirements are ANDed.",
                          "type": "object"
                        }
                      },
                      "type": "object",
                      "x-kubernetes-map-type": "atomic",
                      "additionalProperties": false
                    },
                    "version": {
                      "description": "Version of the resource deployed in the Cluster.",
                      "type": "string"
                    }
                  },
                  "required": [
                    "group",
                    "kind",
                    "version"
                  ],
                  "type": "object",
                  "additionalProperties": false
                },
                "type": "array"
              }
            },
            "required": [
              "condition",
              "name",
              "resourceSelectors"
            ],
            "type": "object",
            "additionalProperties": false
          },
          "type": "array"
        },
        "tokenRequestRenewalOption": {
          "description": "TokenRequestRenewalOption contains options describing how to renew TokenRequest",
          "properties": {
            "kubeconfigKeyName": {
              "description": "KubeconfigKeyName is the name of the key in the Secret where the renewed\nkubeconfig will be stored.\nIf nil, Sveltos defaults to \"re-kubeconfig\" and updates SveltosCluster.Spec.KubeconfigKeyName.\nIf set, Sveltos writes to this key. To prevent GitOps drift, set this to the\nsame value as SveltosCluster.Spec.KubeconfigKeyName.",
              "type": "string"
            },
            "renewTokenRequestInterval": {
              "description": "RenewTokenRequestInterval is the interval at which to renew the TokenRequest",
              "type": "string"
            },
            "saName": {
              "description": "SAName is name of the ServiceAccount to renew the token for.\nIf specified, ServiceAccount must exist in the managed cluster.\nIf not specified, sveltos will try to deduce it from current kubeconfig",
              "type": "string"
            },
            "saNamespace": {
              "description": "SANamespace is the namespace of the ServiceAccount to renew the token for.\nIf specified, ServiceAccount must exist in the managed cluster.\nIf not specified, sveltos will try to deduce it from current kubeconfig",
              "type": "string"
            },
            "tokenDuration": {
              "description": "TokenDuration is the duration the requested token will be valid for.\nIf not specified, the value of RenewTokenRequestInterval will be used.\nThis allows the token to remain valid beyond the renewal interval,\nproviding a buffer in case of connectivity loss.\nExample: renew every hour, token lasts 3 hours (buffer for disconnection)\n  renewTokenRequestInterval: 1h\n  tokenDuration: 3h",
              "type": "string"
            }
          },
          "required": [
            "renewTokenRequestInterval"
          ],
          "type": "object",
          "additionalProperties": false
        }
      },
      "type": "object",
      "additionalProperties": false
    },
    "status": {
      "description": "SveltosClusterStatus defines the status of SveltosCluster",
      "properties": {
        "activeWindowHash": {
          "description": "ActiveWindowHash is the hash of the SveltosCluster Spec.ActiveWindow.\nThis is used to detect if the ActiveWindow configuration has changed\nand requires recalculation of NextPause and NextUnpause.",
          "format": "byte",
          "type": "string"
        },
        "agentLastReportTime": {
          "description": "AgentLastReportTime indicates the last time the Sveltos agent in the managed cluster\nsuccessfully reported its status to the management cluster's API server.\nThis field is updated exclusively when Sveltos operates in pull mode,\nserving as a heartbeat from the agent's perspective.",
          "format": "date-time",
          "type": "string"
        },
        "connectionFailures": {
          "default": 0,
          "description": "connectionFailures is the number of consecutive failed attempts to connect\nto the remote cluster.",
          "type": "integer"
        },
        "connectionStatus": {
          "description": "ConnectionStatus indicates whether connection from the management cluster\nto the managed cluster is healthy",
          "enum": [
            "Healthy",
            "Down"
          ],
          "type": "string"
        },
        "failureMessage": {
          "description": "FailureMessage is a human consumable message explaining the\nmisconfiguration",
          "type": "string"
        },
        "lastReconciledTokenRequestAt": {
          "description": "LastReconciledTokenRequestAt is the last time the TokenRequest\nwas renewed.",
          "type": "string"
        },
        "nextPause": {
          "description": "Information when next pause cluster is scheduled",
          "format": "date-time",
          "type": "string"
        },
        "nextUnpause": {
          "description": "Information when next unpause cluster is scheduled",
          "format": "date-time",
          "type": "string"
        },
        "ready": {
          "description": "Ready is the state of the cluster.",
          "type": "boolean"
        },
        "version": {
          "description": "The Kubernetes version of the cluster.",
          "type": "string"
        }
      },
      "type": "object",
      "additionalProperties": false
    }
  },
  "type": "object"
}
