Merge pull request #242942 from raboof/prometheus-nextcloud-auth-token

prometheus-exporter-nextcloud: support for auth tokens
This commit is contained in:
Arnout Engelen 2023-08-25 09:54:23 +02:00 committed by GitHub
commit 4dcaa04151
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -33,6 +33,15 @@ in
Make sure that this file is readable by the exporter user. Make sure that this file is readable by the exporter user.
''; '';
}; };
tokenFile = mkOption {
type = types.path;
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.
'';
};
timeout = mkOption { timeout = mkOption {
type = types.str; type = types.str;
default = "5s"; default = "5s";
@ -47,12 +56,14 @@ in
ExecStart = '' ExecStart = ''
${pkgs.prometheus-nextcloud-exporter}/bin/nextcloud-exporter \ ${pkgs.prometheus-nextcloud-exporter}/bin/nextcloud-exporter \
--addr ${cfg.listenAddress}:${toString cfg.port} \ --addr ${cfg.listenAddress}:${toString cfg.port} \
--username ${cfg.username} \
--timeout ${cfg.timeout} \ --timeout ${cfg.timeout} \
--server ${cfg.url} \ --server ${cfg.url} \
--password ${escapeShellArg "@${cfg.passwordFile}"} \ ${if cfg.tokenFile == "" then ''
${concatStringsSep " \\\n " cfg.extraFlags} --username ${cfg.username} \
''; --password ${escapeShellArg "@${cfg.passwordFile}"} \
'' else ''
--auth-token ${escapeShellArg "@${cfg.tokenFile}"} \
''} ${concatStringsSep " \\\n " cfg.extraFlags}'';
}; };
}; };
} }