Skip to content

Commit

Permalink
Merge pull request #34792 from radcortez/fix-34759
Browse files Browse the repository at this point in the history
Ignore unmapped build time properties in KubernetesServiceBindingConfig
  • Loading branch information
geoand authored Jul 18, 2023
2 parents 581cec3 + bec7a73 commit be46227
Showing 1 changed file with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<KubernetesServiceBindingConfig> {
public class KubernetesServiceBindingConfigSourceFactory implements ConfigSourceFactory {

private static final Logger log = Logger.getLogger(KubernetesServiceBindingConfigSourceFactory.class);

@Override
public Iterable<ConfigSource> getConfigSources(final ConfigSourceContext context,
final KubernetesServiceBindingConfig config) {
if (!config.enabled()) {
public Iterable<ConfigSource> 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<ServiceBinding> serviceBindings = getServiceBindings(config.root().get());
List<ServiceBinding> serviceBindings = getServiceBindings(kubernetesServiceBindingConfig.root().get());
if (serviceBindings.isEmpty()) {
return emptyList();
}
Expand Down

0 comments on commit be46227

Please sign in to comment.