mirror of
https://git.sr.ht/~goorzhel/turboprop
synced 2024-12-15 17:50:52 +00:00
57 lines
1.2 KiB
Nix
57 lines
1.2 KiB
Nix
{
|
|
builders,
|
|
charts,
|
|
pkgs,
|
|
}: 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 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,
|
|
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 =
|
|
mkImageAttrs mainImage;
|
|
}
|
|
values;
|
|
};
|
|
}
|