Unverified Commit 7e26c8d0 authored by Arnout Engelen's avatar Arnout Engelen
Browse files

prometheus-exporter-nextcloud: support for auth tokens

Fixes #176849
parent 408c0e8c
Loading
Loading
Loading
Loading
+15 −4
Original line number Diff line number Diff line
@@ -33,6 +33,15 @@ in
        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 {
      type = types.str;
      default = "5s";
@@ -47,12 +56,14 @@ in
      ExecStart = ''
        ${pkgs.prometheus-nextcloud-exporter}/bin/nextcloud-exporter \
          --addr ${cfg.listenAddress}:${toString cfg.port} \
          --username ${cfg.username} \
          --timeout ${cfg.timeout} \
          --server ${cfg.url} \
          ${if cfg.tokenFile == "" then ''
            --username ${cfg.username} \
            --password ${escapeShellArg "@${cfg.passwordFile}"} \
          ${concatStringsSep " \\\n  " cfg.extraFlags}
      '';
         '' else ''
            --auth-token ${escapeShellArg "@${cfg.tokenFile}"} \
         ''} ${concatStringsSep " \\\n  " cfg.extraFlags}'';
    };
  };
}