1
0
Fork 0
mirror of https://git.sr.ht/~goorzhel/turboprop synced 2024-12-14 11:37:37 +00:00
turboprop/lib/app-template.nix
2024-04-09 21:36:33 -07:00

56 lines
1.2 KiB
Nix

{
builders,
pkgs,
}: rec {
mkImageAttrs = image:
with builtins; let
vals = pkgs.lib.strings.splitString ":" image;
# Tag may contain ":", such as `rolling@sha256:...`. Or it may not.
# This contortion deals with both scenarios using `sublist`.
tag = with builtins;
concatStringsSep ":"
(filter (x: typeOf x != "list")
(pkgs.lib.lists.sublist 1 2 vals));
in {
repository = elemAt vals 0;
inherit tag;
};
mkExistingClaim = {
mountPath,
pvc,
subPath,
readOnly ? true,
}: {
enabled = true;
existingClaim = pvc;
advancedMounts.main.main = [
{
path = mountPath;
inherit readOnly subPath;
}
];
};
build = {
namespace,
name,
mainImage,
chart,
values ? {},
kubeVersion ? pkgs.kubernetes.version,
apiVersions ? [],
extraOpts ? [],
}:
builders.helmChart {
inherit name namespace chart kubeVersion apiVersions extraOpts;
values =
pkgs.lib.attrsets.recursiveUpdate
{
controllers.main.containers.main.image =
mkImageAttrs mainImage;
}
values;
};
}