-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do not include in the list of property names Kubernetes config fallbacks
(cherry picked from commit 31e7755)
- Loading branch information
Showing
2 changed files
with
38 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 19 additions & 16 deletions
35
.../runtime/src/main/java/io/quarkus/kubernetes/runtime/config/KubernetesConfigFallback.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,30 @@ | ||
package io.quarkus.kubernetes.runtime.config; | ||
|
||
import java.util.Iterator; | ||
import java.util.function.Function; | ||
|
||
import io.smallrye.config.ConfigSourceInterceptorContext; | ||
import io.smallrye.config.FallbackConfigSourceInterceptor; | ||
|
||
public class KubernetesConfigFallback extends FallbackConfigSourceInterceptor { | ||
private static final String QUARKUS_KUBERNETES_CONFIG_PREFIX = "quarkus.kubernetes."; | ||
private static final String QUARKUS_OPENSHIFT_CONFIG_PREFIX = "quarkus.openshift."; | ||
private static final int OPENSHIFT_CONFIG_NAME_BEGIN = QUARKUS_OPENSHIFT_CONFIG_PREFIX.length(); | ||
private static final String QUARKUS_KNATIVE_CONFIG_PREFIX = "quarkus.knative."; | ||
private static final int KNATIVE_CONFIG_NAME_BEGIN = QUARKUS_KNATIVE_CONFIG_PREFIX.length(); | ||
|
||
public KubernetesConfigFallback() { | ||
super(new Function<String, String>() { | ||
@Override | ||
public String apply(final String name) { | ||
if (name.startsWith(QUARKUS_OPENSHIFT_CONFIG_PREFIX)) { | ||
return QUARKUS_KUBERNETES_CONFIG_PREFIX + name.substring(OPENSHIFT_CONFIG_NAME_BEGIN); | ||
} else if (name.startsWith(QUARKUS_KNATIVE_CONFIG_PREFIX)) { | ||
return QUARKUS_KUBERNETES_CONFIG_PREFIX + name.substring(KNATIVE_CONFIG_NAME_BEGIN); | ||
} | ||
return name; | ||
super(new FallbackToKubernetesConfig()); | ||
} | ||
|
||
@Override | ||
public Iterator<String> iterateNames(final ConfigSourceInterceptorContext context) { | ||
return context.iterateNames(); | ||
} | ||
|
||
private static class FallbackToKubernetesConfig implements Function<String, String> { | ||
@Override | ||
public String apply(final String name) { | ||
if (name.startsWith("quarkus.openshift.")) { | ||
return "quarkus.kubernetes." + name.substring(18); | ||
} else if (name.startsWith("quarkus.knative.")) { | ||
return "quarkus.kubernetes." + name.substring(16); | ||
} | ||
}); | ||
return name; | ||
} | ||
} | ||
} |