diff options
author | Arnout Engelen <arnout@bzzt.net> | 2023-09-11 16:00:51 +0200 |
---|---|---|
committer | Arnout Engelen <arnout@bzzt.net> | 2023-09-19 13:19:54 +0200 |
commit | 1bf360af285fc9fd6407c2bead296e3d0d5b6549 (patch) | |
tree | facea94baeb1049b7ac1f8ddbb6d82424494d0f8 /nixos/modules/services/monitoring/prometheus/exporters | |
parent | 3a2786eea085f040a66ecde1bc3ddc7099f6dbeb (diff) |
prometheus-exporter-nextcloud: require either tokenFile or passwordFile
follow-up on 28b3156bc6774f11e203151094bade34cba11fef which broke when tokenFile was left empty. Making both options nullable also allows us to provide a more meaningful error message when neither authentication method is configured.
Diffstat (limited to 'nixos/modules/services/monitoring/prometheus/exporters')
-rw-r--r-- | nixos/modules/services/monitoring/prometheus/exporters/nextcloud.nix | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/nixos/modules/services/monitoring/prometheus/exporters/nextcloud.nix b/nixos/modules/services/monitoring/prometheus/exporters/nextcloud.nix index 28add020f5cc3..28a3eb6a134c0 100644 --- a/nixos/modules/services/monitoring/prometheus/exporters/nextcloud.nix +++ b/nixos/modules/services/monitoring/prometheus/exporters/nextcloud.nix @@ -23,10 +23,12 @@ in description = lib.mdDoc '' Username for connecting to Nextcloud. Note that this account needs to have admin privileges in Nextcloud. + Unused when using token authentication. ''; }; passwordFile = mkOption { - type = types.path; + type = types.nullOr types.path; + default = null; example = "/path/to/password-file"; description = lib.mdDoc '' File containing the password for connecting to Nextcloud. @@ -34,9 +36,9 @@ in ''; }; tokenFile = mkOption { - type = types.path; + type = types.nullOr types.path; + default = null; example = "/path/to/token-file"; - default = ""; description = lib.mdDoc '' File containing the token for connecting to Nextcloud. Make sure that this file is readable by the exporter user. @@ -58,12 +60,13 @@ in --addr ${cfg.listenAddress}:${toString cfg.port} \ --timeout ${cfg.timeout} \ --server ${cfg.url} \ - ${if cfg.tokenFile == "" then '' + ${if cfg.passwordFile != null then '' --username ${cfg.username} \ --password ${escapeShellArg "@${cfg.passwordFile}"} \ - '' else '' + '' else '' --auth-token ${escapeShellArg "@${cfg.tokenFile}"} \ - ''} ${concatStringsSep " \\\n " cfg.extraFlags}''; + ''} \ + ${concatStringsSep " \\\n " cfg.extraFlags}''; }; }; } |