{
  "description": "HealthCheck is the Schema for the HealthCheck 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": "HealthCheckSpec defines the desired state of HealthCheck",
      "properties": {
        "collectResources": {
          "default": false,
          "description": "CollectResources indicates whether matching resources need\nto be collected and added to HealthReport.",
          "type": "boolean"
        },
        "evaluateHealth": {
          "description": "The EvaluateHealth field specifies a Lua function responsible for evaluating the\nhealth of the resources selected by resourceSelectors.\nThis function can assess the health of each resource independently or consider inter-resource relationships.\nThe function must be named *evaluate* and can access all objects identified by resourceSelectors using\nthe *resources* variable. It should return an array of structured instances, each containing the following fields:\n- resource: The resource being evaluated\n- healthStatus: The health status of the resource, which can be one of \"Healthy\", \"Progressing\", \"Degraded\", or \"Suspended\"\n- message: An optional message providing additional information about the health status\n- reEvaluate: If set to true, this healthCheck instances will be re-evaluated in 10 seconds",
          "minLength": 1,
          "type": "string"
        },
        "evaluateIndependently": {
          "default": true,
          "description": "EvaluateIndependently indicates whether matching resources can be evaluated\nin smaller batches to save memory.\nSet this to true if the Lua script evaluates each resource independently.\nSet this to false if the Lua script needs to compare all selected resources",
          "type": "boolean"
        },
        "resourceSelectors": {
          "description": "ResourceSelectors identifies what resources to select to evaluate health",
          "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": [
        "evaluateHealth",
        "resourceSelectors"
      ],
      "type": "object",
      "additionalProperties": false
    }
  },
  "type": "object"
}
