mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-13 20:29:34 +00:00
feat: added support for redis read replica and updated doc
This commit is contained in:
@@ -57,6 +57,22 @@ const envSchema = z
|
||||
.optional()
|
||||
.describe("Comma-separated list of Redis Cluster host:port pairs. Eg: 192.168.65.254:6379,192.168.65.254:6380")
|
||||
),
|
||||
REDIS_READ_REPLICAS: zpStr(
|
||||
z
|
||||
.string()
|
||||
.optional()
|
||||
.describe(
|
||||
"Comma-separated list of Redis read replicas host:port pairs. Eg: 192.168.65.254:6379,192.168.65.254:6380"
|
||||
)
|
||||
),
|
||||
REDIS_CLUSTER_ENABLE_TLS: z
|
||||
.enum(["true", "false"])
|
||||
.default("false")
|
||||
.transform((el) => el === "true"),
|
||||
REDIS_CLUSTER_AWS_ELASTICACHE_DNS_LOOKUP_MODE: z
|
||||
.enum(["true", "false"])
|
||||
.default("false")
|
||||
.transform((el) => el === "true"),
|
||||
HOST: zpStr(z.string().default("localhost")),
|
||||
DB_CONNECTION_URI: zpStr(z.string().describe("Postgres database connection string")).default(
|
||||
`postgresql://${process.env.DB_USER}:${process.env.DB_PASSWORD}@${process.env.DB_HOST}:${process.env.DB_PORT}/${process.env.DB_NAME}`
|
||||
@@ -377,6 +393,12 @@ const envSchema = z
|
||||
const [host, port] = el.trim().split(":");
|
||||
return { host: host.trim(), port: Number(port.trim()) };
|
||||
}),
|
||||
REDIS_READ_REPLICAS: data.REDIS_READ_REPLICAS?.trim()
|
||||
?.split(",")
|
||||
.map((el) => {
|
||||
const [host, port] = el.trim().split(":");
|
||||
return { host: host.trim(), port: Number(port.trim()) };
|
||||
}),
|
||||
isSecretScanningConfigured:
|
||||
Boolean(data.SECRET_SCANNING_GIT_APP_ID) &&
|
||||
Boolean(data.SECRET_SCANNING_PRIVATE_KEY) &&
|
||||
|
||||
@@ -6,12 +6,17 @@ export type TRedisConfigKeys = Partial<{
|
||||
REDIS_PASSWORD: string;
|
||||
|
||||
REDIS_CLUSTER_HOSTS: { host: string; port: number }[];
|
||||
REDIS_CLUSTER_ENABLE_TLS: boolean;
|
||||
// ref: https://github.com/redis/ioredis?tab=readme-ov-file#special-note-aws-elasticache-clusters-with-tls
|
||||
REDIS_CLUSTER_AWS_ELASTICACHE_DNS_LOOKUP_MODE: boolean;
|
||||
|
||||
REDIS_SENTINEL_HOSTS: { host: string; port: number }[];
|
||||
REDIS_SENTINEL_MASTER_NAME: string;
|
||||
REDIS_SENTINEL_ENABLE_TLS: boolean;
|
||||
REDIS_SENTINEL_USERNAME: string;
|
||||
REDIS_SENTINEL_PASSWORD: string;
|
||||
|
||||
REDIS_READ_REPLICAS: { host: string; port: number }[];
|
||||
}>;
|
||||
|
||||
export const buildRedisFromConfig = (cfg: TRedisConfigKeys) => {
|
||||
@@ -19,9 +24,13 @@ export const buildRedisFromConfig = (cfg: TRedisConfigKeys) => {
|
||||
|
||||
if (cfg.REDIS_CLUSTER_HOSTS) {
|
||||
return new Redis.Cluster(cfg.REDIS_CLUSTER_HOSTS, {
|
||||
dnsLookup: cfg.REDIS_CLUSTER_AWS_ELASTICACHE_DNS_LOOKUP_MODE
|
||||
? (address, callback) => callback(null, address)
|
||||
: undefined,
|
||||
redisOptions: {
|
||||
username: cfg.REDIS_USERNAME,
|
||||
password: cfg.REDIS_PASSWORD
|
||||
password: cfg.REDIS_PASSWORD,
|
||||
tls: cfg?.REDIS_CLUSTER_ENABLE_TLS ? {} : undefined
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user