{ 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; }; }