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

56 lines
1.1 KiB
Nix
Raw Normal View History

{
builders,
pkgs,
}: rec {
mkImageAttrs = image:
with builtins; let
vals = pkgs.lib.strings.splitString ":" image;
2023-12-04 05:27:33 +00:00
# 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 ? [],
}:
builders.helmChart {
inherit name namespace chart kubeVersion apiVersions;
values =
pkgs.lib.attrsets.recursiveUpdate
{
controllers.main.containers.main.image =
2023-11-23 18:34:53 +00:00
mkImageAttrs mainImage;
}
2023-11-19 19:46:27 +00:00
values;
};
2023-11-18 10:08:23 +00:00
}