{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://catalog.lintel.tools/schemas/schemastore/rancher-fleet/versions/0.8.json",
  "title": "fleet.yaml",
  "description": "The driving file of a Fleet bundle",
  "x-lintel": {
    "source": "https://www.schemastore.org/rancher-fleet-0.8.json",
    "sourceSha256": "b70e662ec3b4de833ae5f69e3fcde3258d9e83803f7f44568fb05598940512af",
    "fileMatch": [
      "fleet.yaml"
    ],
    "parsers": [
      "yaml"
    ]
  },
  "type": "object",
  "properties": {
    "defaultNamespace": {
      "$ref": "https://catalog.lintel.tools/schemas/schemastore/rancher-fleet/_shared/latest--base.json#/$defs/nullable-string",
      "description": "The default namespace to be applied to resources. This field is not used to enforce or lock down the deployment to a specific namespace, but instead provide the default value of the namespace field if one is not specified in the manifests. Default: default"
    },
    "dependsOn": {
      "description": "An array of dependencies to other Bundles.",
      "items": {
        "properties": {
          "name": {
            "type": "string",
            "description": "Format: <GITREPO-NAME>-<BUNDLE_PATH> with all path separators replaced by \"-\". Example: A Gitrepo named \"one\", with a Bundle path \"/multi-cluster/hello-world\" => \"one-multi-cluster-hello-world\""
          },
          "selector": {
            "$ref": "#/$defs/selector"
          }
        },
        "type": "object"
      },
      "type": [
        "array",
        "null"
      ]
    },
    "diff": {
      "$ref": "#/$defs/diff"
    },
    "helm": {
      "$ref": "#/$defs/helm",
      "description": "Helm overrides for the bundle. When changes are applied to the values.yaml from multiple sources at the same time, the values will update in the following order: helm.values -> helm.valuesFiles -> helm.valuesFrom"
    },
    "kustomize": {
      "$ref": "#/$defs/kustomize",
      "description": "Kustomize options for the bundle."
    },
    "labels": {
      "$ref": "https://catalog.lintel.tools/schemas/schemastore/rancher-fleet/_shared/latest--base.json#/$defs/nullable-object",
      "description": "Labels to apply to the bundle. These labels can be used to select bundles by using the dependsOn keyword"
    },
    "namespace": {
      "$ref": "https://catalog.lintel.tools/schemas/schemastore/rancher-fleet/_shared/latest--base.json#/$defs/nullable-string",
      "description": "All resources will be assigned to this namespace and if any cluster scoped resource exists the deployment will fail. Default: \"\""
    },
    "namespaceAnnotations": {
      "description": "Annotations to apply to the namespace created by Fleet",
      "type": "object"
    },
    "namespaceLabels": {
      "description": "Labels to apply to the namespace created by Fleet",
      "type": "object"
    },
    "paused": {
      "$ref": "https://catalog.lintel.tools/schemas/schemastore/rancher-fleet/_shared/latest--base.json#/$defs/nullable-boolean",
      "description": " A paused bundle will not update downstream clusters but instead mark the bundle as OutOfSync. One can then manually confirm that a bundle should be deployed to the downstream clusters. Default: false"
    },
    "rolloutStrategy": {
      "properties": {
        "autoPartitionSize": {
          "type": "string",
          "description": "A number of percentage of how to automatically partition clusters if not specific partitioning strategy is configured. Default: 25%"
        },
        "maxUnavailable": {
          "type": "string",
          "description": "A number or percentage of clusters that can be unavailable during an update of a bundle. This follows the same basic approach as a deployment rollout strategy. Once the number of clusters meets unavailable state update will be  paused. Default value is 100% which doesn't take effect on update. Default: 100%"
        },
        "maxUnavailablePartitions": {
          "type": "string",
          "description": "A number or percentage of cluster partitions that can be unavailable during an update of a bundle. Default: 0"
        },
        "partitions": {
          "description": "An array of definitions of partitions. If any target clusters do not match the configuration they are added to partitions at the end following the autoPartitionSize",
          "items": {
            "properties": {
              "clusterGroup": {
                "description": "A cluster group name to include in this partition",
                "type": "string"
              },
              "clusterGroupSelector": {
                "$ref": "#/$defs/selector",
                "description": "Selector matching cluster group labels to include in this partition"
              },
              "clusterName": {
                "description": "A cluster name to include in this partition",
                "type": "string"
              },
              "clusterSelector": {
                "$ref": "#/$defs/selector",
                "description": "Selector matching cluster labels to include in this partition"
              },
              "maxUnavailable": {
                "description": "A number or percentage of clusters that can be unavailable in this partition before this partition is treated as done.Default: 10%",
                "type": "string"
              },
              "name": {
                "description": "A user friend name given to the partition used for Display (optional). Default: \"\"",
                "type": "string"
              }
            },
            "type": "object"
          },
          "type": "array"
        }
      },
      "type": [
        "object",
        "null"
      ]
    },
    "serviceAccount": {
      "$comment": "Undocumented field in the fleet docs.",
      "$ref": "https://catalog.lintel.tools/schemas/schemastore/rancher-fleet/_shared/latest--base.json#/$defs/nullable-string",
      "description": "The Service account which will be used for the BundleDeployments. Default: \"\""
    },
    "targetCustomizations": {
      "description": "Target customization are used to determine how resources should be modified per target. Targets are evaluated in order and the first one to match a cluster is used for that cluster",
      "items": {
        "properties": {
          "clusterGroup": {
            "description": "A cluster group name to select",
            "type": "string"
          },
          "clusterGroupSelector": {
            "$ref": "#/$defs/selector",
            "description": "Selector matching cluster group labels to select"
          },
          "clusterSelector": {
            "$ref": "#/$defs/selector",
            "description": "Selector matching cluster labels to select"
          },
          "defaultNamespace": {
            "description": "Custom defaultNamespace value overriding the value at the root",
            "type": "string"
          },
          "diff": {
            "$ref": "#/$defs/diff"
          },
          "doNotDeploy": {
            "description": "Resources will not be deployed in the matched clusters if doNotDeploy is true. Default: false",
            "type": "boolean"
          },
          "helm": {
            "$ref": "#/$defs/helm",
            "description": "Custom helm options overriding the options at the root"
          },
          "kustomize": {
            "$ref": "#/$defs/kustomize",
            "description": "Custom kustomize options overriding the options at the root"
          },
          "name": {
            "description": "The name of target. If not specified a default name of the format \"target000\" will be used. This value is mostly for display",
            "type": "string"
          },
          "namespace": {
            "description": "Custom namespace value overriding the value at the root",
            "type": "string"
          },
          "serviceAccount": {
            "description": "Custom serviceAccount value overriding the value at the root",
            "type": "string"
          },
          "yaml": {
            "description": "If using raw YAML these are names that map to overlays/{name} that will be used to replace or patch a resource. If you wish to customize the file ./subdir/resource.yaml then a file ./overlays/myoverlay/subdir/resource.yaml will replace the base file. A file named ./overlays/myoverlay/subdir/resource_patch.yaml will patch the base file. A patch can in JSON Patch or JSON Merge format or a strategic merge patch for builtin Kubernetes types. Refer to \"Raw YAML Resource Customization\" (https://fleet.rancher.io/next/gitrepo-structure#raw-yaml-resource-customization) for more information",
            "properties": {
              "overlays": {
                "description": "An array of overlays to apply to the resource. The overlays are applied in the order they are listed",
                "items": {
                  "description": "An overlay to apply to the resource. The overlay can be a patch or a replacement. It should point to the folder containing the overlay file(s)",
                  "type": "string"
                },
                "type": "array"
              }
            },
            "type": "object"
          }
        },
        "type": "object"
      },
      "type": [
        "array",
        "null"
      ]
    },
    "imageScans": {
      "description": "ImageScans is An array of images repositories to scan for, so the corresponding repositories may be automatically updated with the specified image",
      "items": {
        "properties": {
          "image": {
            "description": "The image to scan for",
            "type": "string"
          },
          "interval": {
            "description": "The scan interval",
            "examples": [
              "5m"
            ],
            "type": "string"
          },
          "policy": {
            "description": "An array of policies on how to retrieve the latest image. Can be semver or alphabetical",
            "properties": {
              "alphabetical": {
                "description": "The alphabetical policy specifics",
                "properties": {
                  "order": {
                    "description": "The order of the images to use. Can be ascending or descending",
                    "type": "string"
                  }
                },
                "type": "object"
              },
              "semver": {
                "description": "The semver policy specifics",
                "properties": {
                  "range": {
                    "description": "Semver string to evaluate latest image. For more details on how to use semver, see <https://github.com/Masterminds/semver>",
                    "type": "string"
                  }
                },
                "type": "object"
              }
            },
            "type": "object"
          },
          "secretRef": {
            "description": "The secret reference to use for the image repository",
            "properties": {
              "name": {
                "description": "The name of the secret. It must be located in the same namespace as the GitRepo",
                "type": "string"
              }
            },
            "type": "object"
          },
          "tagName": {
            "description": "The tag name used in the manifest files, to be replaced with the latest image. Must be unique per Bundle",
            "type": "string"
          }
        },
        "type": "object"
      },
      "type": [
        "array",
        "null"
      ]
    },
    "ignore": {
      "description": "Ignore options when monitoring a Bundle. This can be used when Fleet thinks some conditions in Custom Resources makes the Bundle to be in an error state when it shouldn't.",
      "type": "object",
      "properties": {
        "conditions": {
          "description": "Conditions to be ignored",
          "type": "array"
        }
      }
    },
    "overrideTargets": {
      "description": "Override targets defined in the GitRepo. The Bundle will not have any targets from the GitRepo if overrideTargets is provided.",
      "type": "array",
      "items": {
        "$ref": "#/$defs/selector"
      }
    }
  },
  "$defs": {
    "selector": {
      "description": "A selector is a label query over a set of resources. The result of matchLabels and matchExpressions are ANDed. An empty selector matches all objects",
      "properties": {
        "matchExpressions": {
          "description": "matchExpressions is An array of label selector requirements. The requirements are ANDed",
          "items": {
            "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",
                "items": {
                  "description": "The value of the label that must be compared to according to the selected operator",
                  "type": "string"
                },
                "type": "array"
              }
            },
            "type": "object"
          },
          "type": "array"
        },
        "matchLabels": {
          "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",
          "additionalProperties": {
            "type": "string"
          }
        }
      },
      "type": [
        "object",
        "null"
      ]
    },
    "diff": {
      "description": "An array of diff options to consider when comparing the current state of the bundle to the desired one.",
      "properties": {
        "comparePatches": {
          "description": "An array of compare patches; how the diff should be calculated and eventually ignored. See ref: <https://fleet.rancher.io/next/ref-crds#comparepatch>",
          "items": {
            "properties": {
              "apiVersion": {
                "description": "The apiVersion of the resource to compare",
                "type": "string"
              },
              "jsonPointers": {
                "description": "An array of custom JSONPointers. See ref: <https://jsonpatch.com/#json-pointer>",
                "items": {
                  "type": "string"
                },
                "type": "array"
              },
              "kind": {
                "description": "The kind of the resource to compare",
                "type": "string"
              },
              "name": {
                "description": "The name of the resource to compare",
                "type": "string"
              },
              "namespace": {
                "description": "The namespace of the resource to compare",
                "type": "string"
              },
              "operations": {
                "description": "An array of operations to consider when comparing the current state of the resource to the desired one. See example: <https://fleet.rancher.io/next/bundle-diffs#combining-it-all-together>",
                "items": {
                  "properties": {
                    "op": {
                      "description": "The operation to perform. See ref: <https://jsonpatch.com/#operations>",
                      "type": "string"
                    },
                    "path": {
                      "description": "The path to the field to compare. See ref: <https://jsonpatch.com/#json-pointer>",
                      "type": "string"
                    },
                    "value": {
                      "description": "The value to add or replace",
                      "type": "string"
                    }
                  },
                  "type": "object"
                },
                "type": "array"
              }
            },
            "type": "object"
          },
          "type": "array"
        }
      },
      "type": "object"
    },
    "helm": {
      "properties": {
        "atomic": {
          "description": "Set the Helm --atomic flag when upgrading. Default: false",
          "type": "boolean"
        },
        "chart": {
          "description": "Use a custom location for the Helm chart. This can refer to any go-getter URL, OCI registry based helm chart URL e.g. \"oci://ghcr.io/fleetrepoci/guestbook\" or a local/remote tgz file. This allows one to download charts from most any location.  Also know that go-getter URL supports adding a digest to validate the download. If repo is set below this field is the name of the chart to lookup",
          "type": "string"
        },
        "disablePreProcess": {
          "description": "Disable go template pre-processing on the fleet values. Default: false",
          "type": "boolean"
        },
        "force": {
          "description": "Set the Helm --force flag when upgrading. This could be dangerous (sic). Default: false",
          "type": "boolean"
        },
        "maxHistory": {
          "description": "Set the Helm --max-history flag when upgrading",
          "type": "integer"
        },
        "releaseName": {
          "description": "A custom release name to deploy the chart as. If not specified a release name will be generated by combining the invoking GitRepo.name + GitRepo.path",
          "type": "string",
          "maxLength": 53,
          "pattern": "^[a-z0-9]([-a-z0-9]*[a-z0-9])?(\\.[a-z0-9]([-a-z0-9]*[a-z0-9])?)*$"
        },
        "repo": {
          "description": "A https URL to a Helm repo to download the chart from. If repo is used the value of `chart` will be used as the chart name to lookup in the Helm repository",
          "examples": [
            "https://charts.rancher.io"
          ],
          "type": "string"
        },
        "takeOwnership": {
          "description": "Makes helm skip the check for its own annotations. Default: false",
          "default": false,
          "type": "boolean"
        },
        "timeoutSeconds": {
          "description": "Set the Helm --timeout flag when upgrading.",
          "type": "integer"
        },
        "values": {
          "description": "Any values that should be placed in the `values.yaml` and passed to helm during install. Cluster labels can also be used here, see <https://fleet.rancher.io/next/gitrepo-structure#reference> for more info",
          "examples": [
            "{\"replicaCount\": 2}",
            "{\"replicaCount\": 2, \"image\": {\"tag\": \"v1.0.0\"}}"
          ],
          "type": "object"
        },
        "valuesFiles": {
          "description": "Path to any values files that need to be passed to helm during install",
          "items": {
            "description": "Path to the value file",
            "type": "string"
          },
          "type": "array"
        },
        "valuesFrom": {
          "description": "An array of of configmap or secrets references defined in the downstream clusters to get values for the chart.",
          "items": {
            "properties": {
              "configMapKeyRef": {
                "description": "A reference to a configmap key",
                "properties": {
                  "key": {
                    "description": "The key to get from the configmap",
                    "type": "string"
                  },
                  "name": {
                    "description": "The name of the configmap",
                    "type": "string"
                  },
                  "namespace": {
                    "description": "The namespace of the configmap",
                    "type": "string"
                  }
                },
                "type": "object"
              },
              "secretKeyRef": {
                "description": "A reference to a secret key",
                "properties": {
                  "key": {
                    "description": "The key to get from the secret",
                    "type": "string"
                  },
                  "name": {
                    "description": "The name of the secret",
                    "type": "string"
                  },
                  "namespace": {
                    "description": "The namespace of the secret",
                    "type": "string"
                  }
                },
                "type": "object"
              }
            },
            "type": "object"
          },
          "type": "array"
        },
        "version": {
          "description": "The version of the chart or semver constraint of the chart to find. If a constraint is specified it is evaluated each time git changes. The version also determines which chart to download from OCI registries",
          "type": "string"
        },
        "waitForJobs": {
          "description": "Wait for all jobs to complete before marking the GitRepo as ready. A timeoutSeconds duration must be set when using. Default: true",
          "type": "boolean"
        }
      },
      "type": [
        "object",
        "null"
      ]
    },
    "kustomize": {
      "properties": {
        "dir": {
          "type": "string",
          "description": "Custom folder for kustomize resources. This folder must contain a kustomization.yaml file. Path is relative to repository root"
        }
      },
      "type": [
        "object",
        "null"
      ]
    }
  },
  "additionalProperties": false
}
