From 0def1fd560485e71e3290b4a0f22ee1fb04a77b8 Mon Sep 17 00:00:00 2001 From: Kalle Fagerberg Date: Tue, 12 Aug 2025 21:46:20 +0200 Subject: [PATCH] helm-schema: init at 2.3.0 Latest release of the 'helm schema' plugin: https://github.com/losisin/helm-values-schema-json/releases/tag/v2.2.1 Co-authored-by: Yiyu Zhou Co-authored-by: SuperSandro2000 --- .../cluster/helm/plugins/default.nix | 2 + .../cluster/helm/plugins/helm-schema.nix | 66 +++++++++++++++++++ 2 files changed, 68 insertions(+) create mode 100644 pkgs/applications/networking/cluster/helm/plugins/helm-schema.nix diff --git a/pkgs/applications/networking/cluster/helm/plugins/default.nix b/pkgs/applications/networking/cluster/helm/plugins/default.nix index a1ecfaa07c21..ebb1f42cedcf 100644 --- a/pkgs/applications/networking/cluster/helm/plugins/default.nix +++ b/pkgs/applications/networking/cluster/helm/plugins/default.nix @@ -15,5 +15,7 @@ helm-secrets = callPackage ./helm-secrets.nix { }; + helm-schema = callPackage ./helm-schema.nix { }; + helm-unittest = callPackage ./helm-unittest.nix { }; } diff --git a/pkgs/applications/networking/cluster/helm/plugins/helm-schema.nix b/pkgs/applications/networking/cluster/helm/plugins/helm-schema.nix new file mode 100644 index 000000000000..29bcb9a701a0 --- /dev/null +++ b/pkgs/applications/networking/cluster/helm/plugins/helm-schema.nix @@ -0,0 +1,66 @@ +{ + buildGoModule, + fetchFromGitHub, + lib, + versionCheckHook, + nix-update-script, +}: + +buildGoModule (finalAttrs: { + pname = "helm-schema"; + version = "2.3.0"; + + src = fetchFromGitHub { + owner = "losisin"; + repo = "helm-values-schema-json"; + tag = "v${finalAttrs.version}"; + hash = "sha256-q5A+tCnuHTtUyejP4flID7XhsoBfWGge2jCgsL0uEOc="; + }; + + vendorHash = "sha256-xmj2i1WNI/9ItbxRk8mPIygjq83xuvNu6THyPqZsysY="; + + ldflags = [ + "-s" + "-w" + "-X 'main.Version=v${finalAttrs.version}'" + ]; + + postPatch = '' + # Remove the install and upgrade hooks + sed -i '/^hooks:/,+2 d' plugin.yaml + + substituteInPlace {plugin.yaml,plugin.complete} \ + --replace-fail '$HELM_PLUGIN_DIR' '${placeholder "out"}/${finalAttrs.pname}/bin' + ''; + + postInstall = '' + install -D plugin.complete -t $out/helm-schema/ + install -m644 plugin.yaml -t $out/helm-schema/ + mv $out/bin/{helm-values-schema-json,schema} + mv $out/bin $out/helm-schema + ''; + + # Unit tests try to open web server on port 0 + __darwinAllowLocalNetworking = true; + + doInstallCheck = true; + nativeInstallCheckInputs = [ versionCheckHook ]; + versionCheckProgram = "${placeholder "out"}/helm-schema/bin/schema"; + versionCheckProgramArg = "--version"; + + passthru.updateScript = nix-update-script { }; + + meta = { + mainProgram = "schema"; + description = "Helm plugin for generating values.schema.json from multiple values files"; + longDescription = '' + Helm plugin for generating `values.schema.json` from single or + multiple values files. Schema can be enriched by reading + annotations from comments. Works only with Helm3 charts. + ''; + homepage = "https://github.com/losisin/helm-values-schema-json"; + changelog = "https://github.com/losisin/helm-values-schema-json/releases/tag/v${finalAttrs.version}"; + maintainers = with lib.maintainers; [ applejag ]; + license = lib.licenses.mit; + }; +})