@@ -43,6 +43,7 @@ const portIterator = (async function* (): AsyncIterableIterator<number> {
4343interface RedisServerDockerConfig {
4444 image : string ;
4545 version : string ;
46+ env ?: Map < string , string > ;
4647}
4748
4849interface SentinelConfig {
@@ -63,7 +64,7 @@ export interface RedisServerDocker {
6364}
6465
6566async function spawnRedisServerDocker (
66- options : RedisServerDockerOptions , serverArguments : Array < string > , dockerEnv ?: Map < string , string > ) : Promise < RedisServerDocker > {
67+ options : RedisServerDockerOptions , serverArguments : Array < string > ) : Promise < RedisServerDocker > {
6768 let port ;
6869 if ( options . mode == "sentinel" ) {
6970 port = options . port ;
@@ -85,7 +86,7 @@ options: RedisServerDockerOptions, serverArguments: Array<string>, dockerEnv?: M
8586 } ) ;
8687 }
8788
88- dockerEnv ?. forEach ( ( key : string , value : string ) => {
89+ options . env ?. forEach ( ( key : string , value : string ) => {
8990 dockerArgs . push ( '-e' , `${ key } :${ value } ` ) ;
9091 } ) ;
9192
@@ -338,22 +339,24 @@ export async function spawnRedisSentinel(
338339 if ( runningNodes ) {
339340 return runningNodes ;
340341 }
341-
342- const dockerEnv : Map < string , string > = new Map ( ) ;
343342
344343 if ( password !== undefined ) {
345- dockerEnv . set ( "REDIS_PASSWORD" , password ) ;
344+ if ( ! dockerConfigs . env ) {
345+ dockerConfigs . env = new Map ( ) ;
346+ }
347+
348+ dockerConfigs . env . set ( "REDIS_PASSWORD" , password ) ;
346349 serverArguments . push ( "--requirepass" , password )
347350 }
348351
349- const master = await spawnRedisServerDocker ( dockerConfigs , serverArguments , dockerEnv ) ;
352+ const master = await spawnRedisServerDocker ( dockerConfigs , serverArguments ) ;
350353 const redisNodes : Array < RedisServerDocker > = [ master ] ;
351354 const replicaPromises : Array < Promise < RedisServerDocker > > = [ ] ;
352355
353356 const replicasCount = 2 ;
354357 for ( let i = 0 ; i < replicasCount ; i ++ ) {
355358 replicaPromises . push ( ( async ( ) => {
356- const replica = await spawnRedisServerDocker ( dockerConfigs , serverArguments , dockerEnv ) ;
359+ const replica = await spawnRedisServerDocker ( dockerConfigs , serverArguments ) ;
357360 const client = createClient ( {
358361 socket : {
359362 port : replica . port
@@ -407,7 +410,7 @@ sentinel failover-timeout mymaster 6000
407410 mode : "sentinel" ,
408411 mounts : [ `${ dir } /redis.conf:/redis/config/node-sentinel-1/redis.conf` ] ,
409412 port : port ,
410- } , serverArguments , dockerEnv ) ;
413+ } , serverArguments ) ;
411414 } ) ( ) ) ;
412415 }
413416
0 commit comments