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

v3: Use map[string] for maps when merged keys are also strings #693

Open
wants to merge 1 commit into
base: v3
Choose a base branch
from

Conversation

saracen
Copy link

@saracen saracen commented Jan 16, 2021

The map type is map[string] when all keys in a map are strings. This adds an additional check to ensure that map[string] is also the map type used for merges, providing the map to be merged also only contains string keys.

This was reported by @nervo here: #139 (comment)

For example:

foo:
    &foo
    bar: baz

bar:
    <<: *foo
    baz: qux

At the moment returns a map[interface{}]interface{}, when ideally, it should be a map[string]interface{} because both bar and foo contain only string keys. This PR fixes this.

The map type is map[string] when all keys in a map are strings. This adds an additional
check to ensure that map[string] is also the map type used for merges, providing the map
to be merged also only contains string keys.
@saracen saracen changed the title Use map[string] for maps when merged keys are also strings v3: Use map[string] for maps when merged keys are also strings Jan 16, 2021
@saracen
Copy link
Author

saracen commented Feb 2, 2021

@niemeyer are you happy with this approach?

TestMerge is simplified, because all of the keys are strings. I've added additional tests for when they're not.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant