spring-cloud-kubernetes: `use-name-as-prefix` does not work as expected
Describe the bug
When importing Kubernetes secrets with use-name-as-prefix, I would expect the prefix to be the name of the secret. This does not work when using a label selector with duplicate keys:
application.yaml
spring:
config:
import: "kubernetes:"
cloud:
kubernetes:
secrets:
enable-api: true
sources:
- labels:
load: "true"
use-name-as-prefix: true
k8s-secrets.yaml
---
apiVersion: v1
kind: Secret
metadata:
name: client-1
labels:
load: "true"
stringData:
client-id: client-1
client-secret: S3cr371!
---
apiVersion: v1
kind: Secret
metadata:
name: client-2
labels:
load: "true"
stringData:
client-id: client-2
client-secret: S3cr372!
will result in these properties:
client-1.client-2.client-secret: S3cr372!
client-1.client-2.client-id: client-2
Expected result:
client-1.client-secret: S3cr371!
client-1.client-id: client-1
client-2.client-secret: S3cr372!
client-2.client-id: client-2
Spring Cloud: 2023.0.3
Sample
I built an example application here: https://github.com/jnodorp-jaconi/spring-cloud-kubernetes-reproducer
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 18 (14 by maintainers)
Commits related to this issue
- Merge pull request #1914 from wind57/fix-1757 Fix #1757 — committed to spring-cloud/spring-cloud-kubernetes by ryanjbaxter 2 years ago
Thank you! I reviewed the PR and it should fix the issue we face.
I created #1911 as a draft. I adjusted the behavior the way I would expect it to work. I also adjusted all affected test cases. I did not yet update the documentation. If you’re happy with the general direction I’ll update the docs as well.
ok, I’ll give this one a spin over the weekend to see where it takes me… thx for the feedback.
I also agree with the OP