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;
|
with lib;
|
||||||
|
|
||||||
rec {
|
rec {
|
||||||
|
# TODO: refactor into mkOptionType
|
||||||
mkSecretOption = {description ? "", default ? {}, allowNull ? true}: mkOption {
|
mkSecretOption = {description ? "", default ? {}, allowNull ? true}: mkOption {
|
||||||
inherit description;
|
inherit description;
|
||||||
type = (if allowNull then types.nullOr else id) (types.submodule {
|
type = (if allowNull then types.nullOr else id) (types.submodule {
|
||||||
options = {
|
options = {
|
||||||
name = mkOption {
|
name = mkOption ({
|
||||||
description = "Name of the secret where secret is stored";
|
description = "Name of the secret where secret is stored";
|
||||||
type = types.str;
|
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";
|
description = "Name of the key where secret is stored";
|
||||||
type = types.str;
|
type = types.str;
|
||||||
default = default.key or null;
|
} // (optionalAttrs (default ? "key") {
|
||||||
};
|
default = default.key;
|
||||||
|
}));
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
default = {};
|
default = if default == null then null else {};
|
||||||
} // (optionalAttrs (default == null) {
|
};
|
||||||
default = null;
|
|
||||||
}));
|
|
||||||
|
|
||||||
secretToEnv = value: {
|
secretToEnv = value: {
|
||||||
valueFrom.secretKeyRef = {
|
valueFrom.secretKeyRef = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue