mirror of
https://github.com/TECHNOFAB11/kubenix.git
synced 2025-12-12 16:10:05 +01:00
fix(lib): mkSecretOption allow to pass null
This commit is contained in:
parent
e682e31dcf
commit
73b1713fd0
2 changed files with 7 additions and 9 deletions
8
lib.nix
8
lib.nix
|
|
@ -57,16 +57,16 @@ rec {
|
||||||
type = types.str;
|
type = types.str;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
} // optionalAttrs (hasAttr "default" options && options.default != null) {
|
||||||
config = mkIf (hasAttr "default" options) (mkAllDefault options.default 1000);
|
config = mkAllDefault options.default 1000;
|
||||||
});
|
});
|
||||||
|
|
||||||
apply = value: {
|
apply = value: if value == null then null else {
|
||||||
valueFrom.secretKeyRef = {
|
valueFrom.secretKeyRef = {
|
||||||
inherit (value) name key;
|
inherit (value) name key;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
default = {};
|
default = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -15,10 +15,7 @@ with lib;
|
||||||
|
|
||||||
password = mkSecretOption {
|
password = mkSecretOption {
|
||||||
description = "Nginx simple auth credentials";
|
description = "Nginx simple auth credentials";
|
||||||
default = {
|
default = null;
|
||||||
name = "test";
|
|
||||||
key = "password";
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -32,7 +29,7 @@ with lib;
|
||||||
containerPort = config.port;
|
containerPort = config.port;
|
||||||
};
|
};
|
||||||
|
|
||||||
spec.template.spec.containers.nginx.env.name = config.password;
|
spec.template.spec.containers.nginx.env.name = mkIf (config.password != null) config.password;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
@ -53,6 +50,7 @@ with lib;
|
||||||
kubernetes.modules.app-v1 = {
|
kubernetes.modules.app-v1 = {
|
||||||
module = "nginx";
|
module = "nginx";
|
||||||
configuration.password.name = "test2";
|
configuration.password.name = "test2";
|
||||||
|
configuration.password.key = "password";
|
||||||
};
|
};
|
||||||
kubernetes.modules.app-v2 = {
|
kubernetes.modules.app-v2 = {
|
||||||
module = "nginx";
|
module = "nginx";
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue