mirror of
https://github.com/gogrlx/nats-server.git
synced 2026-04-02 03:38:42 -07:00
Merge pull request #1584 from wallyqs/leaf-remote-conf-check
Add more config checks for leafnode remotes
This commit is contained in:
@@ -1129,7 +1129,7 @@ func TestConfigCheck(t *testing.T) {
|
||||
leafnodes {
|
||||
remotes = [
|
||||
{
|
||||
url: "tls://connect.ngs.global:7422"
|
||||
url: "tls://nats:7422"
|
||||
tls {
|
||||
timeout: 0.01
|
||||
}
|
||||
@@ -1140,6 +1140,30 @@ func TestConfigCheck(t *testing.T) {
|
||||
errorLine: 0,
|
||||
errorPos: 0,
|
||||
},
|
||||
{
|
||||
name: "when leafnode remotes use wrong type",
|
||||
config: `
|
||||
leafnodes {
|
||||
remotes: {
|
||||
url: "tls://nats:7422"
|
||||
}
|
||||
}`,
|
||||
err: errors.New(`Expected remotes field to be an array, got map[string]interface {}`),
|
||||
errorLine: 3,
|
||||
errorPos: 5,
|
||||
},
|
||||
{
|
||||
name: "when leafnode remotes url uses wrong type",
|
||||
config: `
|
||||
leafnodes {
|
||||
remotes: [
|
||||
{ urls: 1234 }
|
||||
]
|
||||
}`,
|
||||
err: errors.New(`Expected remote leafnode url to be an array or string, got 1234`),
|
||||
errorLine: 4,
|
||||
errorPos: 18,
|
||||
},
|
||||
{
|
||||
name: "when setting latency tracking without a system account",
|
||||
config: `
|
||||
|
||||
@@ -1455,8 +1455,9 @@ func parseLeafNodes(v interface{}, opts *Options, errors *[]error, warnings *[]e
|
||||
}
|
||||
case "remotes":
|
||||
// Parse the remote options here.
|
||||
remotes, err := parseRemoteLeafNodes(mv, errors, warnings)
|
||||
remotes, err := parseRemoteLeafNodes(tk, errors, warnings)
|
||||
if err != nil {
|
||||
*errors = append(*errors, err)
|
||||
continue
|
||||
}
|
||||
opts.LeafNode.Remotes = remotes
|
||||
@@ -1612,7 +1613,6 @@ func parseLeafUsers(mv interface{}, errors *[]error, warnings *[]error) ([]*User
|
||||
func parseRemoteLeafNodes(v interface{}, errors *[]error, warnings *[]error) ([]*RemoteLeafOpts, error) {
|
||||
var lt token
|
||||
defer convertPanicToErrorList(<, errors)
|
||||
|
||||
tk, v := unwrapValue(v, <)
|
||||
ra, ok := v.([]interface{})
|
||||
if !ok {
|
||||
@@ -1647,6 +1647,9 @@ func parseRemoteLeafNodes(v interface{}, errors *[]error, warnings *[]error) ([]
|
||||
continue
|
||||
}
|
||||
remote.URLs = append(remote.URLs, url)
|
||||
default:
|
||||
*errors = append(*errors, &configErr{tk, fmt.Sprintf("Expected remote leafnode url to be an array or string, got %v", v)})
|
||||
continue
|
||||
}
|
||||
case "account", "local":
|
||||
remote.LocalAccount = v.(string)
|
||||
|
||||
Reference in New Issue
Block a user