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

47 lines
1 KiB
Nix
Raw Normal View History

{
builders,
charts,
pkgs,
2023-11-23 18:34:53 +00:00
}: rec {
mkImageAttrs = image:
with builtins; let
vals = pkgs.lib.strings.splitString ":" image;
# Tag may contain ":", such as `rolling@sha256:...`.
# Or it may not. So this contortion deal 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 = pvc: subPath: {
existingClaim = pvc;
inherit subPath;
};
build = {
namespace,
name,
mainImage,
values ? {},
apiVersions ? [],
kubeVersion ? pkgs.kubernetes.version,
}:
builders.helmChart {
inherit name namespace apiVersions;
chart = charts.bjw-s.app-template;
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
}