micronaut-kubernetes
micronaut-kubernetes copied to clipboard
Kubernetes ConfigMap with single key value should not be parsed as a file reference
Expected Behavior
I created a config map with a single key value: "datasources.default.url=jdbc:postgresql://...."
18:20:58.743 [OkHttp https://100.64.0.1/...] TRACE i.m.kubernetes.util.KubernetesUtils - Processing PropertySources for ConfigMap: class V1ConfigMap {
apiVersion: null
binaryData: null
data: {datasources.default.url=jdbc:postgresql://REDACTED}
immutable: null
...
I'd expect that "datasources.default.url" property will be available in the application, but it is not.
Actual Behaviour
KubernetesUtils decides that this is not a map of key values but a "single file???"
if (data.size() > 1 || !getExtension(entry.getKey()).isPresent()) {
if (LOG.isTraceEnabled()) {
LOG.trace("Considering this ConfigMap as containing multiple literal key/values");
}
...
} else {
if (LOG.isTraceEnabled()) {
LOG.trace("Considering this ConfigMap as containing values from a single file");
}
...
}
data.size() > 1 will be false and getExtension will return with "url" for the key "datasources.default.url" which means the second condition will be false too.
This logic should be at least documented as it is hidden now but I think getExtension should return something only for well known configuration extensions like yaml or properties.
Steps To Reproduce
Call KubernetesUtils.getExtension("datasources.default.url") and it will return url OR call KubernetesUtils.configMapAsPropertySource with a single key value config map where the key contains a dot.
Environment Information
No response
Example Application
No response
Version
3.2.7