Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ignore unmapped build time properties in KubernetesServiceBindingConfig #34792

Merged
merged 1 commit into from
Jul 18, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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