From b8db5123fe597ca63c77210c0375ef12e13747af Mon Sep 17 00:00:00 2001 From: Guillaume Smet Date: Sat, 20 Jul 2024 14:01:59 +0200 Subject: [PATCH] Use @ConfigMapping in Elasticsearch client deployment module We are already using @ConfigMapping in the runtime module so let's try to be consistent. Not strictly necessary for the new annotation processor as the rule is per module but still good cleanup. --- .../deployment/ElasticsearchBuildTimeConfig.java | 14 +++++++++----- .../ElasticsearchLowLevelClientProcessor.java | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/extensions/elasticsearch-rest-client/deployment/src/main/java/io/quarkus/elasticsearch/restclient/lowlevel/deployment/ElasticsearchBuildTimeConfig.java b/extensions/elasticsearch-rest-client/deployment/src/main/java/io/quarkus/elasticsearch/restclient/lowlevel/deployment/ElasticsearchBuildTimeConfig.java index 9889677867ad5..934cf6bbf8dd8 100644 --- a/extensions/elasticsearch-rest-client/deployment/src/main/java/io/quarkus/elasticsearch/restclient/lowlevel/deployment/ElasticsearchBuildTimeConfig.java +++ b/extensions/elasticsearch-rest-client/deployment/src/main/java/io/quarkus/elasticsearch/restclient/lowlevel/deployment/ElasticsearchBuildTimeConfig.java @@ -1,14 +1,18 @@ package io.quarkus.elasticsearch.restclient.lowlevel.deployment; -import io.quarkus.runtime.annotations.ConfigItem; import io.quarkus.runtime.annotations.ConfigPhase; import io.quarkus.runtime.annotations.ConfigRoot; +import io.smallrye.config.ConfigMapping; +import io.smallrye.config.WithDefault; +import io.smallrye.config.WithName; -@ConfigRoot(name = "elasticsearch", phase = ConfigPhase.BUILD_TIME) -public class ElasticsearchBuildTimeConfig { +@ConfigMapping(prefix = "quarkus.elasticsearch") +@ConfigRoot(phase = ConfigPhase.BUILD_TIME) +public interface ElasticsearchBuildTimeConfig { /** * Whether a health check is published in case the smallrye-health extension is present. */ - @ConfigItem(name = "health.enabled", defaultValue = "true") - public boolean healthEnabled; + @WithName("health.enabled") + @WithDefault("true") + boolean healthEnabled(); } diff --git a/extensions/elasticsearch-rest-client/deployment/src/main/java/io/quarkus/elasticsearch/restclient/lowlevel/deployment/ElasticsearchLowLevelClientProcessor.java b/extensions/elasticsearch-rest-client/deployment/src/main/java/io/quarkus/elasticsearch/restclient/lowlevel/deployment/ElasticsearchLowLevelClientProcessor.java index d49dc837f811b..688f6c28ca1c8 100644 --- a/extensions/elasticsearch-rest-client/deployment/src/main/java/io/quarkus/elasticsearch/restclient/lowlevel/deployment/ElasticsearchLowLevelClientProcessor.java +++ b/extensions/elasticsearch-rest-client/deployment/src/main/java/io/quarkus/elasticsearch/restclient/lowlevel/deployment/ElasticsearchLowLevelClientProcessor.java @@ -41,7 +41,7 @@ void elasticsearchClientConfigSupport(BuildProducer add @BuildStep HealthBuildItem addHealthCheck(ElasticsearchBuildTimeConfig buildTimeConfig) { return new HealthBuildItem("io.quarkus.elasticsearch.restclient.lowlevel.runtime.health.ElasticsearchHealthCheck", - buildTimeConfig.healthEnabled); + buildTimeConfig.healthEnabled()); } @BuildStep