mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
feat(lib): add mkValueOrSecretOption
This commit is contained in:
parent
cbf84e25a5
commit
30c9de967f
3 changed files with 36 additions and 8 deletions
25
lib.nix
25
lib.nix
|
|
@ -29,4 +29,29 @@ rec {
|
|||
toBase64 = value:
|
||||
builtins.readFile
|
||||
(pkgs.runCommand "value-to-b64" {} "echo '${value}' | ${pkgs.coreutils}/bin/base64 -w0 > $out");
|
||||
|
||||
mkValueOrSecretOption = {...}@options: mkOption ({
|
||||
type = types.either types.str (types.submodule {
|
||||
options.secret = mkOption {
|
||||
description = "Name of the secret where password is stored";
|
||||
type = types.str;
|
||||
};
|
||||
|
||||
options.key = mkOption {
|
||||
description = "Name of the key where password is stored";
|
||||
type = types.str;
|
||||
default = "password";
|
||||
};
|
||||
});
|
||||
|
||||
apply = value:
|
||||
if isAttrs value
|
||||
then {
|
||||
valueFrom.secretKeyRef = {
|
||||
name = value.secret;
|
||||
key = value.key;
|
||||
};
|
||||
}
|
||||
else {inherit value;};
|
||||
} // options);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue