Skip to content

Commit 76b7f49

Browse files
Merge pull request #30 from kaleido-io/arrays
Record defaults for array children
2 parents 133c038 + 43778f8 commit 76b7f49

File tree

4 files changed

+20
-13
lines changed

4 files changed

+20
-13
lines changed

go.mod

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ require (
1616
github.com/rs/cors v1.8.2
1717
github.com/santhosh-tekuri/jsonschema/v5 v5.0.0
1818
github.com/sirupsen/logrus v1.8.1
19-
github.com/spf13/viper v1.12.0
20-
github.com/stretchr/testify v1.7.1
19+
github.com/spf13/viper v1.12.1-0.20220712161005-5247643f0235
20+
github.com/stretchr/testify v1.8.0
2121
github.com/x-cray/logrus-prefixed-formatter v0.5.2
2222
golang.org/x/crypto v0.0.0-20220525230936-793ad666bf5e
2323
golang.org/x/text v0.3.7
@@ -40,14 +40,14 @@ require (
4040
github.com/onsi/ginkgo v1.16.5 // indirect
4141
github.com/onsi/gomega v1.19.0 // indirect
4242
github.com/pelletier/go-toml v1.9.5 // indirect
43-
github.com/pelletier/go-toml/v2 v2.0.1 // indirect
43+
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
4444
github.com/pmezard/go-difflib v1.0.0 // indirect
4545
github.com/spf13/afero v1.8.2 // indirect
4646
github.com/spf13/cast v1.5.0 // indirect
4747
github.com/spf13/jwalterweatherman v1.1.0 // indirect
4848
github.com/spf13/pflag v1.0.5 // indirect
49-
github.com/stretchr/objx v0.1.1 // indirect
50-
github.com/subosito/gotenv v1.3.0 // indirect
49+
github.com/stretchr/objx v0.4.0 // indirect
50+
github.com/subosito/gotenv v1.4.0 // indirect
5151
golang.org/x/net v0.0.0-20220531201128-c960675eff93 // indirect
5252
golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a // indirect
5353
golang.org/x/term v0.0.0-20220526004731-065cf7ba2467 // indirect

go.sum

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -352,8 +352,8 @@ github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FI
352352
github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc=
353353
github.com/pelletier/go-toml v1.9.5 h1:4yBQzkHv+7BHq2PQUZF3Mx0IYxG7LsP222s7Agd3ve8=
354354
github.com/pelletier/go-toml v1.9.5/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c=
355-
github.com/pelletier/go-toml/v2 v2.0.1 h1:8e3L2cCQzLFi2CR4g7vGFuFxX7Jl1kKX8gW+iV0GUKU=
356-
github.com/pelletier/go-toml/v2 v2.0.1/go.mod h1:r9LEWfGN8R5k0VXJ+0BkIe7MYkRdwZOjgMj2KwnJFUo=
355+
github.com/pelletier/go-toml/v2 v2.0.2 h1:+jQXlF3scKIcSEKkdHzXhCTDLPFi5r1wnK6yPS+49Gw=
356+
github.com/pelletier/go-toml/v2 v2.0.2/go.mod h1:MovirKjgVRESsAvNZlAjtFwV867yGuwRkXbG66OzopI=
357357
github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
358358
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
359359
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
@@ -406,21 +406,24 @@ github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmq
406406
github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo=
407407
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
408408
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
409-
github.com/spf13/viper v1.12.0 h1:CZ7eSOd3kZoaYDLbXnmzgQI5RlciuXBMA+18HwHRfZQ=
410-
github.com/spf13/viper v1.12.0/go.mod h1:b6COn30jlNxbm/V2IqWiNWkJ+vZNiMNksliPCiuKtSI=
409+
github.com/spf13/viper v1.12.1-0.20220712161005-5247643f0235 h1:azjn5/lAGpcMny6s1fW/y6rXTu2YUOA+a2C6wKpgpkw=
410+
github.com/spf13/viper v1.12.1-0.20220712161005-5247643f0235/go.mod h1:f40df4ovE8V1ot0NXmYP1zUDS+X1D5AXGviq9fCJqZU=
411411
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
412-
github.com/stretchr/objx v0.1.1 h1:2vfRuCMp5sSVIDSqO8oNnWJq7mPa6KVP3iPIwFBuy8A=
413412
github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
413+
github.com/stretchr/objx v0.4.0 h1:M2gUjqZET1qApGOWNSnZ49BAIMX4F/1plDv3+l31EJ4=
414+
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
414415
github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs=
415416
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
416417
github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4=
417418
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
418419
github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
419420
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
420-
github.com/stretchr/testify v1.7.1 h1:5TQK59W5E3v0r2duFAb7P95B6hEeOyEnHRa8MjYSMTY=
421421
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
422-
github.com/subosito/gotenv v1.3.0 h1:mjC+YW8QpAdXibNi+vNWgzmgBH4+5l5dCXv8cNysBLI=
423-
github.com/subosito/gotenv v1.3.0/go.mod h1:YzJjq/33h7nrwdY+iHMhEOEEbW0ovIz0tB6t6PwAXzs=
422+
github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals=
423+
github.com/stretchr/testify v1.8.0 h1:pSgiaMZlXftHpm5L7V1+rVB+AZJydKsMxsQBIJw4PKk=
424+
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
425+
github.com/subosito/gotenv v1.4.0 h1:yAzM1+SmVcz5R4tXGsNMu1jUl2aOJXoiWUCEwwnGrvs=
426+
github.com/subosito/gotenv v1.4.0/go.mod h1:mZd6rFysKEcUhUHXJk0C/08wAgyDBFuwEYL7vWWGaGo=
424427
github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM=
425428
github.com/x-cray/logrus-prefixed-formatter v0.5.2 h1:00txxvfBM9muc0jiLIEAkAcIMJzfthRT6usrui8uGmg=
426429
github.com/x-cray/logrus-prefixed-formatter v0.5.2/go.mod h1:2duySbKsL6M18s5GU7VPsoEPHyzalCE06qoARUCeBBE=

pkg/config/config.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,7 @@ func (c *configSection) AddChild(k string, defValue ...interface{}) {
420420
func (c *configSection) SetDefault(k string, defValue interface{}) {
421421
key := keyName(c.prefix, k)
422422
viper.SetDefault(key, defValue)
423+
c.AddChild(key, defValue)
423424
}
424425

425426
func GetConfig() fftypes.JSONObject {

pkg/config/config_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ func TestArrayOfPlugins(t *testing.T) {
154154
fft := tokPlugins.SubSection("fftokens")
155155
fft.AddKnownKey("url")
156156
fft.SubSection("proxy").AddKnownKey("url")
157+
fft.AddKnownKey("testdefault")
158+
fft.SetDefault("testdefault", "test")
157159
headers := fft.SubArray("headers")
158160
headers.AddKnownKey("name", "defname")
159161
viper.SetConfigType("yaml")
@@ -180,6 +182,7 @@ plugins:
180182
bobfft := bob.SubSection("fftokens")
181183
assert.Equal(t, "http://test", bobfft.GetString("url"))
182184
assert.Equal(t, "http://proxy", bobfft.SubSection("proxy").GetString("url"))
185+
assert.Equal(t, "test", bobfft.GetString("testdefault"))
183186
bobheaders := bobfft.SubArray("headers")
184187
assert.Equal(t, 2, bobheaders.ArraySize())
185188
assert.Equal(t, "header1", bobheaders.ArrayEntry(0).GetString("name"))

0 commit comments

Comments
 (0)