Skip to content

Commit

Permalink
helm: add noHooks option
Browse files Browse the repository at this point in the history
  • Loading branch information
hall committed Jun 12, 2023
1 parent 9492528 commit 67e1d98
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions lib/helm/chart2json.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
13 changes: 12 additions & 1 deletion modules/helm.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 = {};
Expand Down

0 comments on commit 67e1d98

Please sign in to comment.