mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-09-29 13:51:51 +02:00
Add listener policy to default generated config
So technical user can figure thing out based on self-documented commands, without referring to actual documentation.
This commit is contained in:
1 parent
4f125cf107
commit
0a30fdea69
2 files changed
+16
-1
No files matched your search
@@ -82,6 +82,16 @@ func InitConfig(v *viper.Viper, name string) {
|
|||||||
"0": {
|
"0": {
|
||||||
IP: "",
|
IP: "",
|
||||||
Port: 0,
|
Port: 0,
|
||||||
|
Policy: &ListenerPolicyConfig{
|
||||||
|
Name: "Main Policy",
|
||||||
|
Networks: []Rule{
|
||||||
|
{"network.0": []string{"upstream.0"}},
|
||||||
|
},
|
||||||
|
Rules: []Rule{
|
||||||
|
{"example.com": []string{"upstream.0"}},
|
||||||
|
{"*.ads.com": []string{"upstream.1"}},
|
||||||
|
},
|
||||||
|
},
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
v.SetDefault("network", map[string]*NetworkConfig{
|
v.SetDefault("network", map[string]*NetworkConfig{
|
||||||
|
|||||||
+6
-1
@@ -54,7 +54,12 @@ func TestLoadDefaultConfig(t *testing.T) {
|
|||||||
cfg := defaultConfig(t)
|
cfg := defaultConfig(t)
|
||||||
validate := validator.New()
|
validate := validator.New()
|
||||||
require.NoError(t, ctrld.ValidateConfig(validate, cfg))
|
require.NoError(t, ctrld.ValidateConfig(validate, cfg))
|
||||||
assert.Len(t, cfg.Listener, 1)
|
if assert.Len(t, cfg.Listener, 1) {
|
||||||
|
l0 := cfg.Listener["0"]
|
||||||
|
require.NotNil(t, l0.Policy)
|
||||||
|
assert.Len(t, l0.Policy.Networks, 1)
|
||||||
|
assert.Len(t, l0.Policy.Rules, 2)
|
||||||
|
}
|
||||||
assert.Len(t, cfg.Upstream, 2)
|
assert.Len(t, cfg.Upstream, 2)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user