Skip to content

Commit f0529b3

Browse files
authored
Config: Allow escaping dots in keys via '[unsplit.key]' syntax (#8512)
* Config: allow escaping dots in keys via '[unsplit.key]' syntax
1 parent 76f867a commit f0529b3

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

NOTICE.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,11 @@ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
134134

135135
--------------------------------------------------------------------------------
136136
Module : github.com/elastic/go-ucfg
137-
Version : v0.8.8
138-
Time : 2024-03-18T20:24:48Z
137+
Version : v0.8.9-0.20250307075119-2a22403faaea
138+
Time : 2025-03-07T07:51:19Z
139139
Licence : Apache-2.0
140140

141-
Contents of probable licence file $GOMODCACHE/github.com/elastic/[email protected].8/LICENSE:
141+
Contents of probable licence file $GOMODCACHE/github.com/elastic/[email protected].9-0.20250307075119-2a22403faaea/LICENSE:
142142

143143
Apache License
144144
Version 2.0, January 2004

docs/reference/third-party-dependencies.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ This page lists the third-party dependencies used to build {{eck}}.
2020
| [github.com/Masterminds/sprig/v3](https://github.com/Masterminds/sprig) | v3.3.0 | MIT |
2121
| [github.com/blang/semver/v4](https://github.com/blang/semver) | v4.0.0 | MIT |
2222
| [github.com/davecgh/go-spew](https://github.com/davecgh/go-spew) | v1.1.2-0.20180830191138-d8f796af33cc | ISC |
23-
| [github.com/elastic/go-ucfg](https://github.com/elastic/go-ucfg) | v0.8.8 | Apache-2.0 |
23+
| [github.com/elastic/go-ucfg](https://github.com/elastic/go-ucfg) | v0.8.9-0.20250307075119-2a22403faaea | Apache-2.0 |
2424
| [github.com/ghodss/yaml](https://github.com/ghodss/yaml) | v1.0.0 | MIT |
2525
| [github.com/gkampitakis/go-snaps](https://github.com/gkampitakis/go-snaps) | v0.5.8 | MIT |
2626
| [github.com/go-logr/logr](https://github.com/go-logr/logr) | v1.4.2 | Apache-2.0 |

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ require (
77
github.com/Masterminds/sprig/v3 v3.3.0
88
github.com/blang/semver/v4 v4.0.0
99
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
10-
github.com/elastic/go-ucfg v0.8.8
10+
github.com/elastic/go-ucfg v0.8.9-0.20250307075119-2a22403faaea
1111
github.com/ghodss/yaml v1.0.0
1212
github.com/gkampitakis/go-snaps v0.5.8
1313
github.com/go-logr/logr v1.4.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ github.com/docker/docker-credential-helpers v0.8.2 h1:bX3YxiGzFP5sOXWc3bTPEXdEaZ
4242
github.com/docker/docker-credential-helpers v0.8.2/go.mod h1:P3ci7E3lwkZg6XiHdRKft1KckHiO9a2rNtyFbZ/ry9M=
4343
github.com/elastic/go-sysinfo v1.15.1 h1:zBmTnFEXxIQ3iwcQuk7MzaUotmKRp3OabbbWM8TdzIQ=
4444
github.com/elastic/go-sysinfo v1.15.1/go.mod h1:jPSuTgXG+dhhh0GKIyI2Cso+w5lPJ5PvVqKlL8LV/Hk=
45-
github.com/elastic/go-ucfg v0.8.8 h1:54KIF/2zFKfl0MzsSOCGOsZ3O2bnjFQJ0nDJcLhviyk=
46-
github.com/elastic/go-ucfg v0.8.8/go.mod h1:4E8mPOLSUV9hQ7sgLEJ4bvt0KhMuDJa8joDT2QGAEKA=
45+
github.com/elastic/go-ucfg v0.8.9-0.20250307075119-2a22403faaea h1:SX+ZnuBacMQVu1sNniwUEpi9i3dBaYlbg1WDioQh/ho=
46+
github.com/elastic/go-ucfg v0.8.9-0.20250307075119-2a22403faaea/go.mod h1:4E8mPOLSUV9hQ7sgLEJ4bvt0KhMuDJa8joDT2QGAEKA=
4747
github.com/elastic/go-windows v1.0.2 h1:yoLLsAsV5cfg9FLhZ9EXZ2n2sQFKeDYrHenkcivY4vI=
4848
github.com/elastic/go-windows v1.0.2/go.mod h1:bGcDpBzXgYSqM0Gx3DM4+UxFj300SZLixie9u9ixLM8=
4949
github.com/emicklei/go-restful/v3 v3.12.1 h1:PJMDIM/ak7btuL8Ex0iYET9hxM3CI2sjZtzpL63nKAU=

pkg/controller/common/settings/canonical_config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ import (
2222
type CanonicalConfig ucfg.Config
2323

2424
// Options are config options for the YAML file. Currently contains only support for dotted keys.
25-
var Options = []ucfg.Option{ucfg.PathSep("."), ucfg.AppendValues}
25+
var Options = []ucfg.Option{ucfg.PathSep("."), ucfg.AppendValues, ucfg.EscapePath()}
2626

2727
// NewCanonicalConfig creates a new empty config.
2828
func NewCanonicalConfig() *CanonicalConfig {

pkg/controller/common/settings/canonical_config_test.go

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,19 @@ import (
1313

1414
func TestCanonicalConfig_Render(t *testing.T) {
1515
config := MustCanonicalConfig(map[string]interface{}{
16-
"aaa": "aa a",
17-
"bbb": "b bb",
18-
"aab": "a a a",
19-
"key": map[string]interface{}{"emptyarray": []string{}},
20-
"withquotes": "aa\"bb\"aa",
21-
"zz": "zzz z z z",
16+
"[escaped.key]": map[string]interface{}{"[another.escaped.key]": "value"},
17+
"aaa": "aa a",
18+
"bbb": "b bb",
19+
"aab": "a a a",
20+
"key": map[string]interface{}{"emptyarray": []string{}},
21+
"withquotes": "aa\"bb\"aa",
22+
"zz": "zzz z z z",
2223
})
2324
output, err := config.Render()
2425
require.NoError(t, err)
25-
expected := []byte(`aaa: aa a
26+
expected := []byte(`'[escaped.key]':
27+
'[another.escaped.key]': value
28+
aaa: aa a
2629
aab: a a a
2730
bbb: b bb
2831
key:

0 commit comments

Comments
 (0)