Skip to content

Commit

Permalink
Ignore unmapped build time properties in KubernetesServiceBindingConfig
Browse files Browse the repository at this point in the history
  • Loading branch information
radcortez committed Jul 17, 2023
1 parent d903356 commit bec7a73
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 bec7a73

Please sign in to comment.