From 67e1d9846492ca6902643db4c472963e0a547b2a Mon Sep 17 00:00:00 2001 From: Bryton Hall Date: Mon, 12 Jun 2023 02:41:00 -0400 Subject: [PATCH] helm: add noHooks option --- lib/helm/chart2json.nix | 3 +++ modules/helm.nix | 13 ++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/helm/chart2json.nix b/lib/helm/chart2json.nix index 3e3446f..b279ac8 100644 --- a/lib/helm/chart2json.nix +++ b/lib/helm/chart2json.nix @@ -20,6 +20,8 @@ with lib; kubeVersion ? null, # whether to include CRD includeCRDs ? false, + # whether to include hooks + noHooks ? false, }: let valuesJsonFile = builtins.toFile "${name}-values.json" (builtins.toJSON values); in @@ -32,6 +34,7 @@ with lib; ${optionalString (namespace != null) "--namespace ${namespace}"} \ ${optionalString (values != {}) "-f ${valuesJsonFile}"} \ ${optionalString includeCRDs "--include-crds"} \ + ${optionalString noHooks "--no-hooks"} \ ${chart} >resources.yaml # split multy yaml file into multiple files diff --git a/modules/helm.nix b/modules/helm.nix index f54c7f0..3289d3e 100644 --- a/modules/helm.nix +++ b/modules/helm.nix @@ -95,6 +95,17 @@ in { default = false; }; + noHooks = mkOption { + description = '' + Wether to include Helm hooks. + + Without this all hooks run immediately on apply since we are bypassing the Helm CLI. + However, some charts only have minor validation hooks (e.g., upgrade version skew validation) and are safe to ignore. + ''; + type = types.bool; + default = false; + }; + objects = mkOption { description = "Generated kubernetes objects"; type = types.listOf types.attrs; @@ -109,7 +120,7 @@ in { ]; config.objects = importJSON (helm.chart2json { - inherit (config) chart name namespace values kubeVersion includeCRDs; + inherit (config) chart name namespace values kubeVersion includeCRDs noHooks; }); })); default = {};