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;
@ -115,35 +115,47 @@ in
default = []; default = [];
description = dockerComposeRef "depends_on"; 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); type = nullOr (listOf str);
default = null; default = null;
example = [ "CMD" "pg_isready" ]; example = [ "CMD" "pg_isready" ];
description = dockerComposeRef "healthcheck"; description = dockerComposeRef "healthcheck";
}; };
service.healthcheck.interval = mkOption { interval = mkOption {
type = str; type = str;
default = "30s"; default = "30s";
example = "1m"; example = "1m";
description = dockerComposeRef "healthcheck"; description = dockerComposeRef "healthcheck";
}; };
service.healthcheck.timeout = mkOption { timeout = mkOption {
type = str; type = str;
default = "30s"; default = "30s";
example = "10s"; example = "10s";
description = dockerComposeRef "healthcheck"; description = dockerComposeRef "healthcheck";
}; };
service.healthcheck.start_period = mkOption { start_period = mkOption {
type = str; type = str;
default = "0s"; default = "0s";
example = "30s"; example = "30s";
description = dockerComposeRef "healthcheck"; description = dockerComposeRef "healthcheck";
}; };
service.healthcheck.retries = mkOption { retries = mkOption {
type = int; type = int;
default = 3; default = 3;
description = dockerComposeRef "healthcheck"; description = dockerComposeRef "healthcheck";
}; };
};
});
};
service.devices = mkOption { service.devices = mkOption {
type = listOf str; type = listOf str;
default = []; default = [];
@ -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) {