Skip to content

add toggle to split nats kv on "." delimiter - #355

Merged
knadh merged 3 commits into
knadh:masterfrom
nickchomey:delim-nats-kv
May 29, 2025
Merged

add toggle to split nats kv on "." delimiter#355
knadh merged 3 commits into
knadh:masterfrom
nickchomey:delim-nats-kv

Conversation

@nickchomey

@nickchomey nickchomey commented Apr 26, 2025

Copy link
Copy Markdown
Contributor

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)

{
  "abc": {
    "xyz": 123
  }
}

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

@nickchomey

Copy link
Copy Markdown
Contributor Author

@TECHNOFAB11 Perhaps you'll want to look at this, as the original contributor of the nats provider?

@TECHNOFAB11

Copy link
Copy Markdown
Contributor

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 :)

Comment thread providers/nats/nats.go Outdated
@nickchomey

nickchomey commented Apr 26, 2025

Copy link
Copy Markdown
Contributor Author

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...

@TECHNOFAB11

Copy link
Copy Markdown
Contributor

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 :)

Comment thread providers/nats/nats.go Outdated
@nickchomey

Copy link
Copy Markdown
Contributor Author

Hey @knadh, I made the requested change. Does this seem ready to merge?

@knadh
knadh merged commit 18f7b50 into knadh:master May 29, 2025
@knadh

knadh commented May 29, 2025

Copy link
Copy Markdown
Owner

@nickchomey sorry, I lost track of this. Tagged providers/nats/v0.2.0

Maks1mS pushed a commit to stplr-dev/stplr that referenced this pull request May 10, 2026
….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` | [![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/knadh/koanf/badge)](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 [@&#8203;dependabot](https://github.com/dependabot) in [#&#8203;350](knadh/koanf#350)
- Bump golang.org/x/net from 0.36.0 to 0.38.0 in /providers/consul by [@&#8203;dependabot](https://github.com/dependabot) in [#&#8203;351](knadh/koanf#351)
- Bump golang.org/x/net from 0.37.0 to 0.38.0 in /examples by [@&#8203;dependabot](https://github.com/dependabot) in [#&#8203;353](knadh/koanf#353)
- changing cliflagv2 to support variadic forcedinclude parameter by [@&#8203;kooroo](https://github.com/kooroo) in [#&#8203;357](knadh/koanf#357)
- adds urfave/cli/v3 parser by [@&#8203;n0cloud](https://github.com/n0cloud) in [#&#8203;361](knadh/koanf#361)
- add toggle to split nats kv on "." delimiter by [@&#8203;nickchomey](https://github.com/nickchomey) in [#&#8203;355](knadh/koanf#355)

#### New Contributors

- [@&#8203;kooroo](https://github.com/kooroo) made their first contribution in [#&#8203;357](knadh/koanf#357)
- [@&#8203;n0cloud](https://github.com/n0cloud) made their first contribution in [#&#8203;361](knadh/koanf#361)
- [@&#8203;nickchomey](https://github.com/nickchomey) made their first contribution in [#&#8203;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
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.

3 participants