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} No Example:: {blank}
== services.<name>.service.healthcheck.interval == services.<name>.service.healthcheck.interval

View file

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