diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 463e0b387..9e4a62342 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -4,6 +4,11 @@ repos: - repo: local hooks: + - id: schema-chart + name: schema-chart + entry: make schema-chart + language: system + files: "^charts/cluster-api-runtime-extensions-nutanix/values.yaml$" - id: golangci-lint name: golangci-lint entry: make go-generate lint diff --git a/charts/cluster-api-runtime-extensions-nutanix/values.schema.json b/charts/cluster-api-runtime-extensions-nutanix/values.schema.json index 1f34dd598..5cc9b2610 100644 --- a/charts/cluster-api-runtime-extensions-nutanix/values.schema.json +++ b/charts/cluster-api-runtime-extensions-nutanix/values.schema.json @@ -1,166 +1,483 @@ { - "$schema": "http://json-schema.org/schema#", - "type": "object", - "properties": { - "certificates": { - "type": "object", - "properties": { - "issuer": { - "type": "object", - "properties": { - "kind": { - "type": "string", - "enum": ["Issuer", "ClusterIssuer"], - "default": "Issuer" + "$schema": "https://json-schema.org/draft/2020-12/schema", + "properties": { + "certificates": { + "properties": { + "issuer": { + "properties": { + "kind": { + "type": "string" + }, + "name": { + "type": "string" + }, + "selfSigned": { + "type": "boolean" + } + }, + "type": "object" + } }, - "name": { - "type": "string" + "type": "object" + }, + "deployDefaultClusterClasses": { + "type": "boolean" + }, + "deployment": { + "properties": { + "replicas": { + "type": "integer" + } }, - "selfSigned": { - "type": "boolean" - } - } - } - } - }, - "controllers": { - "type": "object", - "properties": { - "enableLeaderElection": { - "type": "boolean", - "default": true - } - } - }, - "deployDefaultClusterClasses": { - "type": "boolean", - "default": true - }, - "deployment": { - "type": "object", - "properties": { - "replicas": { - "type": "integer", - "minimum": 0 - } - } - }, - "env": { - "type": "object", - "additionalProperties": { "type": "string" } - }, - "image": { - "type": "object", - "properties": { - "pullPolicy": { - "type": "string", - "default": "IfNotPresent", - "enum": ["IfNotPresent", "Always", "Never"] + "type": "object" }, - "repository": { - "type": "string" + "env": { + "properties": {}, + "type": "object" }, - "tag": { - "type": "string" - } - } - }, - "imagePullSecrets": { - "type": "array", - "items": { - "type": "object", - "properties": { - "name": { + "helmAddonsConfigMap": { "type": "string" - } }, - "required": ["name"] - } - }, - "nodeSelector": { - "type": "object", - "additionalProperties": { "type": "string" } - }, - "priorityClassName": { - "type": "string" - }, - "resources": { - "type": "object", - "properties": { - "limits": { - "type": "object", - "properties": { - "cpu": { - "type": "string" + "helmRepositoryImage": { + "properties": { + "pullPolicy": { + "type": "string" + }, + "repository": { + "type": "string" + }, + "tag": { + "type": "string" + } }, - "memory": { - "type": "string" - } - } + "type": "object" }, - "requests": { - "type": "object", - "properties": { - "cpu": { - "type": "string" + "hooks": { + "properties": { + "ccm": { + "properties": { + "nutanix": { + "properties": { + "helmAddonStrategy": { + "properties": { + "defaultValueTemplateConfigMap": { + "properties": { + "create": { + "type": "boolean" + }, + "name": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "clusterAutoscaler": { + "properties": { + "crsStrategy": { + "properties": { + "defaultInstallationConfigMap": { + "properties": { + "name": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "helmAddonStrategy": { + "properties": { + "defaultValueTemplateConfigMap": { + "properties": { + "create": { + "type": "boolean" + }, + "name": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "cni": { + "properties": { + "calico": { + "properties": { + "crsStrategy": { + "properties": { + "defaultInstallationConfigMaps": { + "properties": { + "AWSCluster": { + "properties": { + "configMap": { + "properties": { + "content": { + "type": "string" + }, + "name": { + "type": "string" + } + }, + "type": "object" + }, + "create": { + "type": "boolean" + } + }, + "type": "object" + }, + "DockerCluster": { + "properties": { + "configMap": { + "properties": { + "content": { + "type": "string" + }, + "name": { + "type": "string" + } + }, + "type": "object" + }, + "create": { + "type": "boolean" + } + }, + "type": "object" + }, + "NutanixCluster": { + "properties": { + "configMap": { + "properties": { + "content": { + "type": "string" + }, + "name": { + "type": "string" + } + }, + "type": "object" + }, + "create": { + "type": "boolean" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "defaultTigeraOperatorConfigMap": { + "properties": { + "name": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "defaultPodSubnet": { + "type": "string" + }, + "helmAddonStrategy": { + "properties": { + "defaultValueTemplatesConfigMaps": { + "properties": { + "AWSCluster": { + "properties": { + "create": { + "type": "boolean" + }, + "name": { + "type": "string" + } + }, + "type": "object" + }, + "DockerCluster": { + "properties": { + "create": { + "type": "boolean" + }, + "name": { + "type": "string" + } + }, + "type": "object" + }, + "NutanixCluster": { + "properties": { + "create": { + "type": "boolean" + }, + "name": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "cilium": { + "properties": { + "crsStrategy": { + "properties": { + "defaultCiliumConfigMap": { + "properties": { + "name": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "helmAddonStrategy": { + "properties": { + "defaultValueTemplateConfigMap": { + "properties": { + "create": { + "type": "boolean" + }, + "name": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "csi": { + "properties": { + "nutanix": { + "properties": { + "helmAddonStrategy": { + "properties": { + "defaultValueTemplateConfigMap": { + "properties": { + "create": { + "type": "boolean" + }, + "name": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "nfd": { + "properties": { + "crsStrategy": { + "properties": { + "defaultInstallationConfigMap": { + "properties": { + "name": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "helmAddonStrategy": { + "properties": { + "defaultValueTemplateConfigMap": { + "properties": { + "create": { + "type": "boolean" + }, + "name": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "serviceLoadBalancer": { + "properties": { + "metalLB": { + "properties": { + "defaultValueTemplateConfigMap": { + "properties": { + "create": { + "type": "boolean" + }, + "name": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "virtualIP": { + "properties": { + "kubeVip": { + "properties": { + "defaultTemplateConfigMap": { + "properties": { + "create": { + "type": "boolean" + }, + "name": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + } + }, + "type": "object" + } }, - "memory": { - "type": "string" - } - } - } - } - }, - "securityContext": { - "type": "object", - "properties": { - "runAsUser": { - "type": "integer" - } - } - }, - "service": { - "type": "object", - "properties": { - "annotations": { - "type": "object", - "additionalProperties": { "type": "string" } + "type": "object" }, - "port": { - "type": "integer", - "minimum": 1, - "maximum": 65535 + "image": { + "properties": { + "pullPolicy": { + "type": "string" + }, + "repository": { + "type": "string" + }, + "tag": { + "type": "string" + } + }, + "type": "object" }, - "type": { - "type": "string" - } - } - }, - "tolerations": { - "type": "array", - "items": { - "type": "object", - "properties": { - "effect": { - "type": "string", - "enum": ["NoSchedule", "PreferNoSchedule", "NoExecute"] - }, - "key": { - "type": "string" - }, - "operator": { - "type": "string", - "enum": ["Exists", "Equal"] - }, - "tolerationSeconds": { - "type": "integer" - }, - "value": { + "imagePullSecrets": { + "type": "array" + }, + "nodeSelector": { + "properties": {}, + "type": "object" + }, + "priorityClassName": { "type": "string" - } }, - "required": ["effect", "key", "operator"] - } - } - } + "resources": { + "properties": { + "limits": { + "properties": { + "cpu": { + "type": "string" + }, + "memory": { + "type": "string" + } + }, + "type": "object" + }, + "requests": { + "properties": { + "cpu": { + "type": "string" + }, + "memory": { + "type": "string" + } + }, + "type": "object" + } + }, + "type": "object" + }, + "securityContext": { + "properties": { + "runAsUser": { + "type": "integer" + } + }, + "type": "object" + }, + "selfHostedRegistry": { + "type": "boolean" + }, + "service": { + "properties": { + "annotations": { + "properties": {}, + "type": "object" + }, + "port": { + "type": "integer" + }, + "type": { + "type": "string" + } + }, + "type": "object" + }, + "tolerations": { + "items": { + "properties": { + "effect": { + "type": "string" + }, + "key": { + "type": "string" + }, + "operator": { + "type": "string" + } + }, + "type": "object" + }, + "type": "array" + } + }, + "type": "object" } diff --git a/devbox.json b/devbox.json index 587faf8a6..2106df97e 100644 --- a/devbox.json +++ b/devbox.json @@ -22,7 +22,6 @@ "ko@latest", "kubebuilder@latest", "kubectl@latest", - "kubernetes-helm@latest", "kustomize@latest", "pre-commit@latest", "rsync@latest", @@ -35,6 +34,7 @@ "path:./hack/flakes#go-mod-upgrade", "path:./hack/flakes#golangci-lint", "path:./hack/flakes#goprintconst", + "path:./hack/flakes#helm-with-plugins", "path:./hack/flakes#release-please", "path:./hack/flakes#setup-envtest" ], diff --git a/devbox.lock b/devbox.lock index c34cf03c5..b975b2357 100644 --- a/devbox.lock +++ b/devbox.lock @@ -1233,54 +1233,6 @@ } } }, - "kubernetes-helm@latest": { - "last_modified": "2024-05-29T10:04:41Z", - "resolved": "github:NixOS/nixpkgs/ac82a513e55582291805d6f09d35b6d8b60637a1#kubernetes-helm", - "source": "devbox-search", - "version": "3.15.1", - "systems": { - "aarch64-darwin": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/nipci6fqwxvyz3bcq63mz4svi5bvcpb6-kubernetes-helm-3.15.1", - "default": true - } - ], - "store_path": "/nix/store/nipci6fqwxvyz3bcq63mz4svi5bvcpb6-kubernetes-helm-3.15.1" - }, - "aarch64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/axp4ixbbbxhg8f630cj6rvxjdjbx99pw-kubernetes-helm-3.15.1", - "default": true - } - ], - "store_path": "/nix/store/axp4ixbbbxhg8f630cj6rvxjdjbx99pw-kubernetes-helm-3.15.1" - }, - "x86_64-darwin": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/rvdcn0nsid05i4ardmvgn38bd1fkk9rw-kubernetes-helm-3.15.1", - "default": true - } - ], - "store_path": "/nix/store/rvdcn0nsid05i4ardmvgn38bd1fkk9rw-kubernetes-helm-3.15.1" - }, - "x86_64-linux": { - "outputs": [ - { - "name": "out", - "path": "/nix/store/i24nairmnj41aq4w6x7fp8wjrcd15i13-kubernetes-helm-3.15.1", - "default": true - } - ], - "store_path": "/nix/store/i24nairmnj41aq4w6x7fp8wjrcd15i13-kubernetes-helm-3.15.1" - } - } - }, "kustomize@latest": { "last_modified": "2024-06-08T17:34:36Z", "resolved": "github:NixOS/nixpkgs/cd18e2ae9ab8e2a0a8d715b60c91b54c0ac35ff9#kustomize", diff --git a/hack/flakes/flake.nix b/hack/flakes/flake.nix index ae46e0840..8c2fc13b6 100644 --- a/hack/flakes/flake.nix +++ b/hack/flakes/flake.nix @@ -129,6 +129,44 @@ "-X ${t}.gitVersion=v${version}" ]; }; + + helm-schema = buildGo122Module rec { + pname = "helm-schema"; + version = "1.4.1"; + + src = fetchFromGitHub { + owner = "losisin"; + repo = "helm-values-schema-json"; + rev = "v${version}"; + hash = "sha256-pi/Xp4t8UFgdFvU2De2Uo/gVsVltan4iSw2XGEtynuw="; + }; + doCheck = false; + vendorHash = "sha256-F2mT36aYkLjUZbV5GQH8mNMZjGi/70dTENU2rRhAJq4="; + ldflags = let t = "main"; in [ + "-s" + "-w" + "-X ${t}.BuildDate=19700101-00:00:00" + "-X ${t}.GitCommit=v${version}" + "-X ${t}.Version=v${version}" + ]; + + postPatch = '' + sed -i '/^hooks:/,+2 d' plugin.yaml + sed -i 's#command: "$HELM_PLUGIN_DIR/schema"#command: "$HELM_PLUGIN_DIR/helm-values-schema-json"#' plugin.yaml + ''; + + postInstall = '' + install -dm755 $out/${pname} + mv $out/bin/* $out/${pname}/ + install -m644 -Dt $out/${pname} plugin.yaml + ''; + }; + + helm-with-plugins = wrapHelm kubernetes-helm { + plugins = [ + helm-schema + ]; + }; }; formatter = alejandra; diff --git a/make/helm.mk b/make/helm.mk index c2cc372e7..9422f660c 100644 --- a/make/helm.mk +++ b/make/helm.mk @@ -16,3 +16,10 @@ lint-and-install-chart: ## Lints and installs helm chart lint-and-install-chart: ct lint-and-install --config charts/ct-config.yaml ct lint-and-install --config charts/ct-config.yaml --upgrade + +.PHONY: schema-chart +schema-chart: ## Updates helm values JSON schema +schema-chart: + helm schema \ + --input charts/cluster-api-runtime-extensions-nutanix/values.yaml \ + --output charts/cluster-api-runtime-extensions-nutanix/values.schema.json