Move healthcheck options to healthcheck submodule

This commit is contained in:
t4ccer 2022-04-27 19:43:16 -06:00
parent 69b9109dea
commit fb5ab7b76f
No known key found for this signature in database
GPG key ID: 19E5A2D8B1E43F19
2 changed files with 56 additions and 32 deletions

View file

@ -666,6 +666,18 @@ Default::
----
No Example:: {blank}
== services.<name>.service.healthcheck
None
[discrete]
=== details
Type:: submodule
No Default:: {blank}
No Example:: {blank}
== services.<name>.service.healthcheck.interval

View file

@ -4,7 +4,7 @@
the user-facing options service.image, service.volumes, etc.
*/
{ pkgs, lib, config, ... }:
{ pkgs, lib, config, options, ... }:
let
inherit (lib) mkOption types;
@ -115,35 +115,47 @@ in
default = [];
description = dockerComposeRef "depends_on";
};
service.healthcheck.test = mkOption {
service.healthcheck = mkOption {
type = submodule ({ config, options, ...}: {
options = {
_out = mkOption {
internal = true;
default = lib.optionalAttrs (options.test.highestPrio < 1500) {
inherit (config) test interval timeout start_period retries;
};
};
test = mkOption {
type = nullOr (listOf str);
default = null;
example = [ "CMD" "pg_isready" ];
description = dockerComposeRef "healthcheck";
};
service.healthcheck.interval = mkOption {
interval = mkOption {
type = str;
default = "30s";
example = "1m";
description = dockerComposeRef "healthcheck";
};
service.healthcheck.timeout = mkOption {
timeout = mkOption {
type = str;
default = "30s";
example = "10s";
description = dockerComposeRef "healthcheck";
};
service.healthcheck.start_period = mkOption {
start_period = mkOption {
type = str;
default = "0s";
example = "30s";
description = dockerComposeRef "healthcheck";
};
service.healthcheck.retries = mkOption {
retries = mkOption {
type = int;
default = 3;
description = dockerComposeRef "healthcheck";
};
};
});
};
service.devices = mkOption {
type = listOf str;
default = [];
@ -289,8 +301,8 @@ in
inherit (config.service) container_name;
} // lib.optionalAttrs (config.service.depends_on != []) {
inherit (config.service) depends_on;
} // lib.optionalAttrs (config.service.healthcheck.test != null) {
inherit (config.service) healthcheck;
} // lib.optionalAttrs (options.service.healthcheck.highestPrio < 1500) {
healthcheck = config.service.healthcheck._out;
} // lib.optionalAttrs (config.service.devices != []) {
inherit (config.service) devices;
} // lib.optionalAttrs (config.service.entrypoint != null) {