Skip to content

Commit

Permalink
Merge pull request #1425 from mapped/logs_auth
Browse files Browse the repository at this point in the history
Use general Redis auth when also using the general Redis host
  • Loading branch information
Page- authored Sep 20, 2023
2 parents 3fb309f + 9d8252d commit ab97d17
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/lib/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,11 +170,13 @@ function redisOpts(prefix: string): RedisOpts;
function redisOpts(
prefix: string,
defaultHosts: HostPort[],
defaultAuth: RedisAuth,
defaultIsCluster: boolean,
): RedisOpts;
function redisOpts(
prefix: string,
defaultHosts?: HostPort[],
defaultAuth?: RedisAuth,
defaultIsCluster?: boolean,
): RedisOpts {
const hostVarName = `${prefix}_HOST`;
Expand All @@ -183,7 +185,7 @@ function redisOpts(
const roAuthVarName = `${prefix}_RO_AUTH`;
const isCluster = boolVar(`${prefix}_IS_CLUSTER`, defaultIsCluster);
const hosts = hostPortsVar(hostVarName, defaultHosts);
const auth = redisAuthVar(authVarName);
const auth = redisAuthVar(authVarName, defaultAuth);
if (isCluster == null) {
throw new Error(`Missing env: '${prefix}_IS_CLUSTER'`);
}
Expand Down Expand Up @@ -229,7 +231,12 @@ if (generalRedis.isCluster) {

export const REDIS = {
general: generalRedis,
logs: redisOpts('REDIS_LOGS', [generalRedis.host], generalRedis.isCluster),
logs: redisOpts(
'REDIS_LOGS',
[generalRedis.host],
generalRedis.auth,
generalRedis.isCluster,
),
};
export const REDIS_LOGS_SHARDED_PUBSUB = boolVar(
'REDIS_LOGS_SHARDED_PUBSUB',
Expand Down

0 comments on commit ab97d17

Please sign in to comment.