mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
fix(lib/k8s): mkSecretOption, improve errors if name or key not passed
This commit is contained in:
parent
dc200f8484
commit
c8c2f69cc4
1 changed files with 12 additions and 10 deletions
22
lib/k8s.nix
22
lib/k8s.nix
|
|
@ -3,27 +3,29 @@
|
|||
with lib;
|
||||
|
||||
rec {
|
||||
# TODO: refactor into mkOptionType
|
||||
mkSecretOption = {description ? "", default ? {}, allowNull ? true}: mkOption {
|
||||
inherit description;
|
||||
type = (if allowNull then types.nullOr else id) (types.submodule {
|
||||
options = {
|
||||
name = mkOption {
|
||||
name = mkOption ({
|
||||
description = "Name of the secret where secret is stored";
|
||||
type = types.str;
|
||||
default = default.name or null;
|
||||
};
|
||||
default = default.name;
|
||||
} // (optionalAttrs (default ? "name") {
|
||||
default = default.name;
|
||||
}));
|
||||
|
||||
key = mkOption {
|
||||
key = mkOption ({
|
||||
description = "Name of the key where secret is stored";
|
||||
type = types.str;
|
||||
default = default.key or null;
|
||||
};
|
||||
} // (optionalAttrs (default ? "key") {
|
||||
default = default.key;
|
||||
}));
|
||||
};
|
||||
});
|
||||
default = {};
|
||||
} // (optionalAttrs (default == null) {
|
||||
default = null;
|
||||
}));
|
||||
default = if default == null then null else {};
|
||||
};
|
||||
|
||||
secretToEnv = value: {
|
||||
valueFrom.secretKeyRef = {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue