add toggle to split nats kv on "." delimiter - #355
Conversation
|
@TECHNOFAB11 Perhaps you'll want to look at this, as the original contributor of the nats provider? |
|
Looks good, it's been a while since I've seen my NATS provider code and I actually expected it to unflatten the data, so it's definitely a good idea to add the option to do that :) |
|
An alternative, since you expected it to unflatten already, is to just make this the default behavior and jot even have a config option. Though, that would unfortunately break people's code if they're using it... |
Yeah probably best to not break existing code even though it would be the expected outcome. PR is fine as is :) |
|
Hey @knadh, I made the requested change. Does this seem ready to merge? |
|
@nickchomey sorry, I lost track of this. Tagged |
….2.1 (#429) This PR contains the following updates: | Package | Type | Update | Change | OpenSSF | |---|---|---|---|---| | [github.com/knadh/koanf/parsers/toml/v2](https://github.com/knadh/koanf) | require | patch | `v2.2.0` → `v2.2.1` | [](https://securityscorecards.dev/viewer/?uri=github.com/knadh/koanf) | --- >⚠️ **Warning** > > Some dependencies could not be looked up. Check the [Dependency Dashboard](issues/23) for more information. --- ### Release Notes <details> <summary>knadh/koanf (github.com/knadh/koanf/parsers/toml/v2)</summary> ### [`v2.2.1`](https://github.com/knadh/koanf/releases/tag/v2.2.1) [Compare Source](knadh/koanf@v2.2.0...v2.2.1) #### What's Changed - Bump github.com/nats-io/nats-server/v2 from 2.9.23 to 2.10.27 in /providers/nats by [@​dependabot](https://github.com/dependabot) in [#​350](knadh/koanf#350) - Bump golang.org/x/net from 0.36.0 to 0.38.0 in /providers/consul by [@​dependabot](https://github.com/dependabot) in [#​351](knadh/koanf#351) - Bump golang.org/x/net from 0.37.0 to 0.38.0 in /examples by [@​dependabot](https://github.com/dependabot) in [#​353](knadh/koanf#353) - changing cliflagv2 to support variadic forcedinclude parameter by [@​kooroo](https://github.com/kooroo) in [#​357](knadh/koanf#357) - adds urfave/cli/v3 parser by [@​n0cloud](https://github.com/n0cloud) in [#​361](knadh/koanf#361) - add toggle to split nats kv on "." delimiter by [@​nickchomey](https://github.com/nickchomey) in [#​355](knadh/koanf#355) #### New Contributors - [@​kooroo](https://github.com/kooroo) made their first contribution in [#​357](knadh/koanf#357) - [@​n0cloud](https://github.com/n0cloud) made their first contribution in [#​361](knadh/koanf#361) - [@​nickchomey](https://github.com/nickchomey) made their first contribution in [#​355](knadh/koanf#355) **Full Changelog**: <knadh/koanf@v2.2.0...v2.2.1> </details> --- ### Configuration 📅 **Schedule**: (UTC) - Branch creation - At 12:00 AM through 04:59 AM and 10:00 PM through 11:59 PM, Monday through Friday (`* 0-4,22-23 * * 1-5`) - Only on Sunday and Saturday (`* * * * 0,6`) - Automerge - At any time (no schedule defined) 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Renovate Bot](https://github.com/renovatebot/renovate). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiI0My4xMzIuMyIsInVwZGF0ZWRJblZlciI6IjQzLjEzMi4zIiwidGFyZ2V0QnJhbmNoIjoibWFpbiIsImxhYmVscyI6WyJLaW5kL0RlcGVuZGVuY2llcyJdfQ==--> Reviewed-on: https://altlinux.space/stapler/stplr/pulls/429
This adds an optional "split" boolean config field to allow for splitting/unflattening a natskv key on the "." delimiter that denotes NATS KV subject/key hierarchies
My use case is:
Prefix = "abc"
There's a key "abc.xyz" with a value of "123"
Currently it will filter for keys with the "abc" prefix (minimizing kv.Get() calls), but then it just ends up setting
{ "abc.xyz" : 123 }in the koanf confmap.This PR allows it to split the key so that the conf map gets updated with something like this (or whatever the proper nested map syntax is in go)
Inspiration taken from the env provider (and surely many others do something similar)
I'm quite open to renaming the field to something other than Split, as well as changing its comment description