-
Feature
-
Resolution: Done
-
Minor
-
None
-
None
-
False
-
False
Following https://github.com/quarkusio/quarkus/pull/21776.
In order for Test Container's shared network to be used for containers launched by DevServices I need to set the property quarkus.datasource.devservices.use-test-containers-shared-network to true. This works fine when I add it to the end application's application.properties file however the property is really only needed for when the application is using an extension (as it is the extension itself that needs containers launched by DevServices to join Test Container's shared network) so I'd like to "black box" setting the property to the scope of the extension.
I see something similar done for Quarkus's Hibernate ORM support in DevMode here so I tried a similar approach.
I wrote a BuildStep that did the following (trying every way possible to set a property I could find):
... devServicesConfigResultBuildItemBuildProducer.produce(new DevServicesConfigResultBuildItem( UseTestContainersSharedNetwork.getPropertyName(), "true")); runTimeConfigurationDefaultBuildItemBuildProducer.produce(new RunTimeConfigurationDefaultBuildItem( UseTestContainersSharedNetwork.getPropertyName(), "true")); systemPropertyBuildItemBuildProducer.produce(new SystemPropertyBuildItem( UseTestContainersSharedNetwork.getPropertyName(), "true")); ...
However the lookup of the property in DevServicesDatasourceProcessor always returns the default value and not that set in my BuildStep. I checked both the injected configuration object and "dynamic" lookup as follows:
log.info("============> USE (injected): " + dataSourceBuildTimeConfig.devservices.useTestContainersSharedNetwork); log.info("============> USE (lookup): " + ConfigProvider.getConfig().getConfigValue("quarkus.datasource.devservices.use-test-containers-shared-network"));
So... armed with the advice from gandrian@redhat.com that "...extensions "communicate" via build items..." I set about a different approach.
I created a new BuildItem called DevServicesUseTestContainersSharedNetworkBuildItem that signals the need to use Test Containers shared network. I added it as Optional<DevServicesUseTestContainersSharedNetworkBuildItem> step to DevServicesDatasourceProcessor.launchDatabases(..). If it is present I start data sources sharing Test Containers network otherwise I don't.
Then.. in my extension I create the BuildItem and everything works as needed; but it makes the property completely redundant.
So.. the reason for this JIRA is really to discuss how I should be handling the scenario of an extension used by an application needing to set a property. Should I ditch the property all together and use the BuildItem or is there a preferred approach?
- blocks
-
FAI-681 Integrate TrustyService with Quarkus DevServices services
- Done
- is related to
-
QUARKUS-1501 DevServicesKafkaProcessor: Always expose to Docker host network
- Closed