From bec7a737c40b41816ad8c11bca9a0a2626a89020 Mon Sep 17 00:00:00 2001 From: Roberto Cortez Date: Mon, 17 Jul 2023 14:03:37 +0100 Subject: [PATCH] Ignore unmapped build time properties in KubernetesServiceBindingConfig --- ...etesServiceBindingConfigSourceFactory.java | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/extensions/kubernetes-service-binding/runtime/src/main/java/io/quarkus/kubernetes/service/binding/runtime/KubernetesServiceBindingConfigSourceFactory.java b/extensions/kubernetes-service-binding/runtime/src/main/java/io/quarkus/kubernetes/service/binding/runtime/KubernetesServiceBindingConfigSourceFactory.java index 44f675d434913..df605dc36335e 100644 --- a/extensions/kubernetes-service-binding/runtime/src/main/java/io/quarkus/kubernetes/service/binding/runtime/KubernetesServiceBindingConfigSourceFactory.java +++ b/extensions/kubernetes-service-binding/runtime/src/main/java/io/quarkus/kubernetes/service/binding/runtime/KubernetesServiceBindingConfigSourceFactory.java @@ -18,28 +18,37 @@ import org.jboss.logging.Logger; import io.smallrye.config.ConfigSourceContext; -import io.smallrye.config.ConfigSourceFactory.ConfigurableConfigSourceFactory; +import io.smallrye.config.ConfigSourceFactory; +import io.smallrye.config.SmallRyeConfig; +import io.smallrye.config.SmallRyeConfigBuilder; -public class KubernetesServiceBindingConfigSourceFactory - implements ConfigurableConfigSourceFactory { +public class KubernetesServiceBindingConfigSourceFactory implements ConfigSourceFactory { private static final Logger log = Logger.getLogger(KubernetesServiceBindingConfigSourceFactory.class); @Override - public Iterable getConfigSources(final ConfigSourceContext context, - final KubernetesServiceBindingConfig config) { - if (!config.enabled()) { + public Iterable getConfigSources(final ConfigSourceContext context) { + SmallRyeConfig config = new SmallRyeConfigBuilder() + .withSources(new ConfigSourceContext.ConfigSourceContextConfigSource(context)) + .withMapping(KubernetesServiceBindingConfig.class) + .withMappingIgnore("quarkus.**") + .build(); + + KubernetesServiceBindingConfig kubernetesServiceBindingConfig = config + .getConfigMapping(KubernetesServiceBindingConfig.class); + + if (!kubernetesServiceBindingConfig.enabled()) { log.debug( "No attempt will be made to bind configuration based on Kubernetes ServiceBinding because the feature was not enabled."); return emptyList(); } - if (config.root().isEmpty()) { + if (kubernetesServiceBindingConfig.root().isEmpty()) { log.debug( "No attempt will be made to bind configuration based on Kubernetes Service Binding because the binding root was not specified."); return emptyList(); } - List serviceBindings = getServiceBindings(config.root().get()); + List serviceBindings = getServiceBindings(kubernetesServiceBindingConfig.root().get()); if (serviceBindings.isEmpty()) { return emptyList(); }