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

Periods in ConfigMap keys get replaced by colons without any possibility of escape. #155

Open
wasabii opened this issue Jan 15, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request

Comments

@wasabii
Copy link

wasabii commented Jan 15, 2024

entry => sectionNamePrefix + entry.Key.Replace('.', ':'),

Techincally, Microsoft.Extensions.Configuration, supports key values with periods in their names. For instance, in JSON:

"Foo.Bar": {
   "Value": "Hi"
}

But there's no way to represent this pattern in a ConfigMap.

Perhaps some escaping syntax.

@tintoy tintoy added the investigating The issue is being investigated label Jan 15, 2024
@tintoy
Copy link
Owner

tintoy commented Jan 15, 2024

Thanks, good catch! I think this was originally to match K8s envFrom but there’s no real need to do so. I’ll look into making the replacement configurable even if it’s just to completely enable/disable the behaviour.

@tintoy tintoy self-assigned this Jan 15, 2024
@tintoy tintoy added bug Something isn't working enhancement New feature or request and removed investigating The issue is being investigated enhancement New feature or request labels Jan 15, 2024
@wasabii
Copy link
Author

wasabii commented Jan 15, 2024

Well the way the dotnet parses env variables would work. That escapes : with _.

So it would be a changing change.

@tintoy
Copy link
Owner

tintoy commented Jan 15, 2024

Maybe we can wind up supporting 3 options (overloads, conceptually) when configuring the configuration provider for a specific ConfigMap:

  1. Existing behaviour (the default; backward-compatible)
  2. A single character to replace . with.
  3. A set of mappings to replace characters (will throw if resulting replacements would be illegal).

About the only restriction here is that the resulting keys cannot contain a : because that’s the character used by the configuration system to represent sections and sub-sections.

@tintoy tintoy added enhancement New feature or request and removed bug Something isn't working labels Jan 15, 2024
@tintoy
Copy link
Owner

tintoy commented Jan 15, 2024

Also worth noting the section in the docs relating to : vs __ so that may be something we can consider as well:

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/?view=aspnetcore-8.0#non-prefixed-environment-variables

@tintoy
Copy link
Owner

tintoy commented Jan 21, 2024

Hi - can you give v2.5.7-develop.2 a try and see if that works for you?

When setting up your configuration, there is now an additional parameter you can pass (keyPathDelimiters) that specifies which characters represent delimiters in ConfigMap and Secret keys (you can pass an empty char array or Enumerable.Empty<char>() to entirely prevent the ConfigMap/Secret keys from being modified when converted to IConfiguration keys).

@tintoy
Copy link
Owner

tintoy commented Jan 21, 2024

Sorry, that was the wrong branch. Will try again 🙂

@tintoy
Copy link
Owner

tintoy commented Jan 21, 2024

Ok - can you give v2.5.0-configmap-key-escape.51 a try?

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

No branches or pull requests

2 participants