@@ -215,7 +215,7 @@ public override KafkaContainer Build()
215215 KafkaBuilder kafkaBuilder ;
216216
217217 // Instead of this approach, should we consider using a builder for each vendor?
218- var vendorConfiguration = VendorConfigurations . Single ( v => v . Vendor . Equals ( DockerResourceConfiguration . Vendor ) || v . IsImageFromVendor ( DockerResourceConfiguration . Image ) ) ;
218+ var vendorConfiguration = GetVendorConfiguration ( DockerResourceConfiguration ) ;
219219
220220 var defaultConsensusProtocol = vendorConfiguration . GetConsensusProtocol ( DockerResourceConfiguration . Image ) ;
221221
@@ -240,9 +240,7 @@ public override KafkaContainer Build()
240240 // Validate that the configuration is compatible with the vendor's image.
241241 vendorConfiguration . Validate ( kafkaBuilder . DockerResourceConfiguration ) ;
242242
243- var startupKafkaBuilder = kafkaBuilder . WithStartupScript ( container => vendorConfiguration . CreateStartupScript ( kafkaBuilder . DockerResourceConfiguration , container ) ) ;
244-
245- return new KafkaContainer ( startupKafkaBuilder . DockerResourceConfiguration ) ;
243+ return new KafkaContainer ( kafkaBuilder . DockerResourceConfiguration ) ;
246244 }
247245
248246 /// <inheritdoc />
@@ -264,7 +262,8 @@ protected override KafkaBuilder Init()
264262 . WithEnvironment ( "KAFKA_LOG_FLUSH_INTERVAL_MESSAGES" , long . MaxValue . ToString ( ) )
265263 . WithEnvironment ( "KAFKA_GROUP_INITIAL_REBALANCE_DELAY_MS" , "0" )
266264 . WithEnvironment ( "CLUSTER_ID" , ClusterId )
267- . WithConnectionStringProvider ( ( ) => new KafkaConnectionStringProvider ( ) ) ;
265+ . WithConnectionStringProvider ( ( ) => new KafkaConnectionStringProvider ( ) )
266+ . WithStartupScript ( ( container , configuration ) => GetVendorConfiguration ( configuration ) . CreateStartupScript ( configuration , container ) ) ;
268267 }
269268
270269 /// <inheritdoc />
@@ -298,4 +297,14 @@ protected override KafkaBuilder Merge(KafkaConfiguration oldValue, KafkaConfigur
298297 {
299298 return new KafkaBuilder ( new KafkaConfiguration ( oldValue , newValue ) ) ;
300299 }
300+
301+ /// <summary>
302+ /// Gets the vendor configuration that matches the configured vendor or image.
303+ /// </summary>
304+ /// <param name="resourceConfiguration">The resource configuration.</param>
305+ /// <returns>The vendor configuration.</returns>
306+ private static IKafkaVendorConfiguration GetVendorConfiguration ( KafkaConfiguration resourceConfiguration )
307+ {
308+ return VendorConfigurations . Single ( v => v . Vendor . Equals ( resourceConfiguration . Vendor ) || v . IsImageFromVendor ( resourceConfiguration . Image ) ) ;
309+ }
301310}
0 commit comments