mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
feat(lib): add octalToDecimal
This commit is contained in:
parent
c3b31f0161
commit
663138ae4c
2 changed files with 9 additions and 1 deletions
|
|
@ -14,7 +14,7 @@ let
|
||||||
args = {
|
args = {
|
||||||
inherit pkgs;
|
inherit pkgs;
|
||||||
name = "default";
|
name = "default";
|
||||||
k8s = { inherit loadJSON loadYAML toBase64 mkValueOrSecretOption; };
|
k8s = { inherit loadJSON loadYAML toBase64 octalToDecimal mkValueOrSecretOption; };
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
8
lib.nix
8
lib.nix
|
|
@ -30,6 +30,14 @@ rec {
|
||||||
builtins.readFile
|
builtins.readFile
|
||||||
(pkgs.runCommand "value-to-b64" {} "echo '${value}' | ${pkgs.coreutils}/bin/base64 -w0 > $out");
|
(pkgs.runCommand "value-to-b64" {} "echo '${value}' | ${pkgs.coreutils}/bin/base64 -w0 > $out");
|
||||||
|
|
||||||
|
exp = base: exp: foldr (value: acc: acc * base) 1 (range 1 exp);
|
||||||
|
|
||||||
|
octalToDecimal = value:
|
||||||
|
(foldr (char: acc: {
|
||||||
|
i = acc.i + 1;
|
||||||
|
value = acc.value + (toInt char) * (exp 8 acc.i);
|
||||||
|
}) {i = 0; value = 0;} (stringToCharacters value)).value;
|
||||||
|
|
||||||
mkValueOrSecretOption = {...}@options: mkOption ({
|
mkValueOrSecretOption = {...}@options: mkOption ({
|
||||||
type = types.nullOr (types.either types.str (types.submodule {
|
type = types.nullOr (types.either types.str (types.submodule {
|
||||||
options.secret = mkOption {
|
options.secret = mkOption {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue