@@ -72,19 +72,16 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
7272		indexStorageMode : MemoryOptimized ,
7373	}
7474
75- 	moduleOpts  :=  []testcontainers.ContainerCustomizer {
76- 		testcontainers .WithExposedPorts (MGMT_PORT + "/tcp" , MGMT_SSL_PORT + "/tcp" ),
77- 	}
78- 
79- 	serviceCustomizers  :=  make ([]testcontainers.ContainerCustomizer , 0 , len (initialServices ))
75+ 	// Process custom options first to extract config 
76+ 	// Start with initial services 
77+ 	allCustomizers  :=  make ([]testcontainers.ContainerCustomizer , 0 , len (initialServices )+ len (opts ))
8078	for  _ , srv  :=  range  initialServices  {
81- 		serviceCustomizers  =  append (serviceCustomizers , withService (srv ))
79+ 		allCustomizers  =  append (allCustomizers , withService (srv ))
8280	}
81+ 	allCustomizers  =  append (allCustomizers , opts ... )
8382
84- 	serviceCustomizers  =  append (serviceCustomizers , opts ... )
85- 
86- 	// transfer options to the config 
87- 	for  _ , opt  :=  range  serviceCustomizers  {
83+ 	// Transfer custom options to the config 
84+ 	for  _ , opt  :=  range  allCustomizers  {
8885		if  bucketCustomizer , ok  :=  opt .(bucketCustomizer ); ok  {
8986			// If the option is a bucketCustomizer, we need to add the buckets to the request 
9087			config .buckets  =  append (config .buckets , bucketCustomizer .buckets ... )
@@ -100,12 +97,18 @@ func Run(ctx context.Context, img string, opts ...testcontainers.ContainerCustom
10097			config .password  =  credentialsCustomizer .password 
10198
10299			if  len (credentialsCustomizer .password ) <  6  {
103- 				return  nil , errors .New ("admin password must be at most  6 characters long" )
100+ 				return  nil , errors .New ("admin password must be at least  6 characters long" )
104101			}
105102		}
106103	}
107104
108- 	moduleOpts  =  append (moduleOpts , serviceCustomizers ... )
105+ 	// Build moduleOpts with defaults 
106+ 	moduleOpts  :=  []testcontainers.ContainerCustomizer {
107+ 		testcontainers .WithExposedPorts (MGMT_PORT + "/tcp" , MGMT_SSL_PORT + "/tcp" ),
108+ 	}
109+ 
110+ 	// Append all customizers (initial services + user opts) 
111+ 	moduleOpts  =  append (moduleOpts , allCustomizers ... )
109112
110113	ctr , err  :=  testcontainers .Run (ctx , img , moduleOpts ... )
111114	var  couchbaseContainer  * CouchbaseContainer 
0 commit comments