Skip to content

Commit b7d4fbc

Browse files
committed
pkg/settings: add yaml support
1 parent 8d4b127 commit b7d4fbc

15 files changed

+393
-4
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ require (
1515
github.com/go-json-experiment/json v0.0.0-20250223041408-d3c622f1b874
1616
github.com/go-playground/validator/v10 v10.26.0
1717
github.com/go-viper/mapstructure/v2 v2.4.0
18+
github.com/goccy/go-yaml v1.19.2
1819
github.com/golang-jwt/jwt/v5 v5.2.3
1920
github.com/google/go-cmp v0.7.0
2021
github.com/google/uuid v1.6.0
@@ -98,7 +99,6 @@ require (
9899
github.com/go-playground/locales v0.14.1 // indirect
99100
github.com/go-playground/universal-translator v0.18.1 // indirect
100101
github.com/goccy/go-json v0.10.5 // indirect
101-
github.com/goccy/go-yaml v1.12.0 // indirect
102102
github.com/gofrs/uuid v4.4.0+incompatible // indirect
103103
github.com/golang/protobuf v1.5.4 // indirect
104104
github.com/google/flatbuffers v25.2.10+incompatible // indirect

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,8 @@ github.com/go-viper/mapstructure/v2 v2.4.0 h1:EBsztssimR/CONLSZZ04E8qAkxNYq4Qp9L
9292
github.com/go-viper/mapstructure/v2 v2.4.0/go.mod h1:oJDH3BJKyqBA2TXFhDsKDGDTlndYOZ6rGS0BRZIxGhM=
9393
github.com/goccy/go-json v0.10.5 h1:Fq85nIqj+gXn/S5ahsiTlK3TmC85qgirsdTP/+DeaC4=
9494
github.com/goccy/go-json v0.10.5/go.mod h1:oq7eo15ShAhp70Anwd5lgX2pLfOS3QCiwU/PULtXL6M=
95-
github.com/goccy/go-yaml v1.12.0 h1:/1WHjnMsI1dlIBQutrvSMGZRQufVO3asrHfTwfACoPM=
96-
github.com/goccy/go-yaml v1.12.0/go.mod h1:wKnAMd44+9JAAnGQpWVEgBzGt3YuTaQ4uXoHvE4m7WU=
95+
github.com/goccy/go-yaml v1.19.2 h1:PmFC1S6h8ljIz6gMRBopkjP1TVT7xuwrButHID66PoM=
96+
github.com/goccy/go-yaml v1.19.2/go.mod h1:XBurs7gK8ATbW4ZPGKgcbrY1Br56PdM69F7LkFRi1kA=
9797
github.com/gofrs/uuid v4.0.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
9898
github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1YrTJupqA=
9999
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
WorkflowLimit: "200"
2+
WorkflowExecutionConcurrencyLimit: "200"
3+
GatewayIncomingPayloadSizeLimit: 1mb
4+
GatewayVaultManagementEnabled: "true"
5+
VaultCiphertextSizeLimit: 2kb
6+
VaultIdentifierKeySizeLimit: 64b
7+
VaultIdentifierOwnerSizeLimit: 64b
8+
VaultIdentifierNamespaceSizeLimit: 64b
9+
VaultPluginBatchSizeLimit: "20"
10+
VaultRequestBatchSizeLimit: "10"
11+
PerOrg:
12+
ZeroBalancePruningTimeout: 24h0m0s
13+
PerOwner:
14+
WorkflowExecutionConcurrencyLimit: "5"
15+
VaultSecretsLimit: "100"
16+
PerWorkflow:
17+
TriggerRegistrationsTimeout: 10s
18+
TriggerSubscriptionTimeout: 15s
19+
TriggerSubscriptionLimit: "10"
20+
TriggerEventQueueLimit: "50"
21+
TriggerEventQueueTimeout: 10m0s
22+
CapabilityConcurrencyLimit: "30"
23+
CapabilityCallTimeout: 3m0s
24+
SecretsConcurrencyLimit: "5"
25+
ExecutionConcurrencyLimit: "5"
26+
ExecutionTimeout: 5m0s
27+
ExecutionResponseLimit: 100kb
28+
WASMMemoryLimit: 100mb
29+
WASMBinarySizeLimit: 100mb
30+
WASMCompressedBinarySizeLimit: 20mb
31+
WASMConfigSizeLimit: 1mb
32+
WASMSecretsSizeLimit: 1mb
33+
LogLineLimit: 1kb
34+
LogEventLimit: "1000"
35+
ChainAllowed:
36+
Default: "false"
37+
Values:
38+
"12922642891491394802": "true"
39+
"3379446385462418246": "true"
40+
CRONTrigger:
41+
FastestScheduleInterval: 30s
42+
HTTPTrigger:
43+
RateLimit: every30s:3
44+
LogTrigger:
45+
EventRateLimit: every6s:10
46+
EventSizeLimit: 5kb
47+
FilterAddressLimit: "5"
48+
FilterTopicsPerSlotLimit: "10"
49+
ChainWrite:
50+
TargetsLimit: "10"
51+
ReportSizeLimit: 5kb
52+
EVM:
53+
TransactionGasLimit: "5000000"
54+
GasLimit:
55+
Default: "5000000"
56+
Values:
57+
"12922642891491394802": "50000000"
58+
"3379446385462418246": "10000000"
59+
ChainRead:
60+
CallLimit: "15"
61+
LogQueryBlockLimit: "100"
62+
PayloadSizeLimit: 5kb
63+
Consensus:
64+
ObservationSizeLimit: 100kb
65+
CallLimit: "20"
66+
HTTPAction:
67+
CallLimit: "5"
68+
CacheAgeLimit: 10m0s
69+
ConnectionTimeout: 10s
70+
RequestSizeLimit: 10kb
71+
ResponseSizeLimit: 100kb
72+
Secrets:
73+
CallLimit: "5"

pkg/settings/cresettings/settings_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"testing"
1111
"time"
1212

13+
"github.com/goccy/go-yaml"
1314
"github.com/pelletier/go-toml/v2"
1415
"github.com/stretchr/testify/assert"
1516
"github.com/stretchr/testify/require"
@@ -35,6 +36,8 @@ var (
3536
defaultsJSON string
3637
//go:embed defaults.toml
3738
defaultsTOML string
39+
//go:embed defaults.yaml
40+
defaultsYAML string
3841
)
3942

4043
func TestDefault(t *testing.T) {
@@ -61,6 +64,22 @@ func TestDefault(t *testing.T) {
6164
require.Equal(t, defaultsTOML, string(b))
6265
}
6366
})
67+
68+
t.Run("yaml", func(t *testing.T) {
69+
jb, err := json.MarshalIndent(Default, "", "\t")
70+
if err != nil {
71+
log.Fatal(err)
72+
}
73+
b, err := yaml.JSONToYAML(jb)
74+
if err != nil {
75+
log.Fatal(err)
76+
}
77+
if *update {
78+
require.NoError(t, os.WriteFile("defaults.yaml", b, 0644))
79+
} else {
80+
require.Equal(t, defaultsYAML, string(b))
81+
}
82+
})
6483
}
6584

6685
func TestSchema_Unmarshal(t *testing.T) {

pkg/settings/json.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ func readJSONMaps(files fs.FS, dir string) (jsonMap, error) {
100100
}
101101
m, err := readJSONMap(files, path)
102102
if err != nil {
103-
return fmt.Errorf("failed to read toml file %s: %w", path, err)
103+
return fmt.Errorf("failed to read json file %s: %w", path, err)
104104
}
105105
name := strings.TrimSuffix(d.Name(), ".json")
106106
ms[name] = m

pkg/settings/testdata/config.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# File generated from source files. DO NOT EDIT.
2+
global:
3+
Bar:
4+
Baz: "10"
5+
Foo: "5"
6+
org:
7+
"123":
8+
Bar:
9+
Baz: "99"
10+
Foo: "42"
11+
"456":
12+
Bar:
13+
Baz: "500"
14+
Foo: "99"
15+
owner:
16+
00026b4aa7e57ca7b68ae1bf45653f56b656fd3a:
17+
Bar:
18+
Baz: "200"
19+
Foo: "75"
20+
8bd112d3f8f92e41c861939545ad387307af9703:
21+
Bar:
22+
Baz: "43"
23+
Foo: "13"
24+
workflow:
25+
15c631d295ef5e32deb99a10ee6804bc4af13855687559d7ff6552ac6dbb2ce0:
26+
Bar:
27+
Baz: "13"
28+
Foo: "17"
29+
15c631d295ef5e32deb99a10ee6804bc4af1385568f9b3363f6552ac6dbb2cef:
30+
Bar:
31+
Baz: "50"
32+
Foo: "20"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Foo: "5"
2+
3+
Bar:
4+
Baz: "10"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Foo: "42"
2+
3+
Bar:
4+
Baz: "99"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Foo: "99"
2+
3+
Bar:
4+
Baz: "500"
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Foo: "75"
2+
3+
Bar:
4+
Baz: "200"

0 commit comments

Comments
 (0)