fix types of long-syntax secrets: uid/gid should output strings, service secrets lists
This commit is contained in:
parent
f2dc1d0996
commit
5a5ed5202f
3 changed files with 31 additions and 20 deletions
|
@ -22,15 +22,15 @@
|
|||
"ports": [
|
||||
"8080:80"
|
||||
],
|
||||
"secrets": {
|
||||
"foo": {
|
||||
"gid": 123,
|
||||
"secrets": [
|
||||
{
|
||||
"gid": "123",
|
||||
"mode": "0440",
|
||||
"source": "web_cache_redis_secret",
|
||||
"target": "/run/secrets/web_cache_redis_secret",
|
||||
"uid": 123
|
||||
"source": "foo",
|
||||
"target": "/run/secrets/foo",
|
||||
"uid": "123"
|
||||
}
|
||||
},
|
||||
],
|
||||
"sysctls": {},
|
||||
"volumes": []
|
||||
}
|
||||
|
|
|
@ -6,15 +6,15 @@
|
|||
ports = [
|
||||
"8080:80"
|
||||
];
|
||||
secrets = {
|
||||
foo = {
|
||||
source = "web_cache_redis_secret";
|
||||
target = "/run/secrets/web_cache_redis_secret";
|
||||
uid = 123;
|
||||
gid = 123;
|
||||
secrets = [
|
||||
{
|
||||
source = "foo";
|
||||
target = "/run/secrets/foo";
|
||||
uid = "123";
|
||||
gid = "123";
|
||||
mode = "0440";
|
||||
};
|
||||
};
|
||||
}
|
||||
];
|
||||
};
|
||||
secrets.foo.environment = "FOO";
|
||||
}
|
||||
|
|
|
@ -31,12 +31,12 @@ let
|
|||
description = serviceRef "secrets";
|
||||
};
|
||||
uid = mkOption {
|
||||
type = nullOr (either str int);
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = serviceRef "secrets";
|
||||
};
|
||||
gid = mkOption {
|
||||
type = nullOr (either str int);
|
||||
type = nullOr str;
|
||||
default = null;
|
||||
description = serviceRef "secrets";
|
||||
};
|
||||
|
@ -128,7 +128,7 @@ in
|
|||
'';
|
||||
};
|
||||
secrets = mkOption {
|
||||
type = nullOr (either (listOf str) (attrsOf serviceSecretType));
|
||||
type = nullOr (listOf (either str serviceSecretType));
|
||||
default = null;
|
||||
description = ''
|
||||
Build-time secrets exposed to the service.
|
||||
|
@ -138,7 +138,7 @@ in
|
|||
});
|
||||
};
|
||||
service.secrets = mkOption {
|
||||
type = either (listOf str) (attrsOf serviceSecretType);
|
||||
type = nullOr (listOf (either str serviceSecretType));
|
||||
default = [];
|
||||
description = ''
|
||||
Run-time secrets exposed to the service.
|
||||
|
@ -451,7 +451,18 @@ in
|
|||
} // lib.optionalAttrs (config.service.extra_hosts != []) {
|
||||
inherit (config.service) extra_hosts;
|
||||
} // lib.optionalAttrs (config.service.secrets != []) {
|
||||
inherit (config.service) secrets;
|
||||
secrets = lib.lists.map (s: {
|
||||
} // lib.optionalAttrs (s.source != null) {
|
||||
inherit (s) source;
|
||||
} // lib.optionalAttrs (s.target != null) {
|
||||
inherit (s) target;
|
||||
} // lib.optionalAttrs (s.uid != null) {
|
||||
inherit (s) uid;
|
||||
} // lib.optionalAttrs (s.gid != null) {
|
||||
inherit (s) gid;
|
||||
} // lib.optionalAttrs (s.mode != null) {
|
||||
inherit (s) mode;
|
||||
}) config.service.secrets;
|
||||
} // lib.optionalAttrs (config.service.hostname != null) {
|
||||
inherit (config.service) hostname;
|
||||
} // lib.optionalAttrs (config.service.dns != []) {
|
||||
|
|
Loading…
Reference in a new issue