Skip to content

Using profile-specific ConfigMap-entry leads to duplicate key-exception #1564

Closed
@stoetti

Description

Hi!

I am in the process of migrating to kubernetes-config for our Spring Boot applications. We are relying on profile-specific configurations which might override some default values based on activated profiles.
My understanding from the documentation was that I could defined a ConfigMap like this

apiVersion: v1
kind: ConfigMap
metadata:
  name: test-application
data:
  test-application.properties: |
    key=value1
  test-application-profileA.properties: |
    key=value2

If the application with the name test-application is started with only default-profiles active the value for property key should be value1 and if started with the profile profileA active the key should have value2.
The current implementation throws a duplicate key error when trying to combine the two "properties-files" into a single map ignoring the fact that one should, at lease in my opinion, take precedence over the other. The exception is thrown here

return input.entrySet().stream().map(e -> extractProperties(e.getKey(), e.getValue(), fileNames, environment))

For reproduction I created a small sample-project including a unit-test the demonstrates the behavior https://github.com/stoetti/spring-cloud-kubernetes-config-profile

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions