in api/internal/core/store/validate.go [163:199]
func checkUpstream(upstream *entity.UpstreamDef) error {
if upstream == nil {
return nil
}
if upstream.PassHost == "node" && upstream.Nodes != nil {
nodes, ok := entity.NodesFormat(upstream.Nodes).([]*entity.Node)
if !ok {
return fmt.Errorf("upstrams nodes not support value %v when `pass_host` is `node`", nodes)
} else if len(nodes) != 1 {
return fmt.Errorf("only support single node for `node` mode currentlywhen `pass_host` is `node`")
}
}
if upstream.PassHost == "rewrite" && upstream.UpstreamHost == "" {
return fmt.Errorf("`upstream_host` can't be empty when `pass_host` is `rewrite`")
}
if upstream.Type != "chash" {
return nil
}
//to confirm
if upstream.HashOn == "" {
upstream.HashOn = "vars"
}
if upstream.HashOn != "consumer" && upstream.Key == "" {
return fmt.Errorf("missing key")
}
if err := cHashKeySchemaCheck(upstream); err != nil {
return err
}
return nil
}