From 1a01e13db881d3b75cd31bf2a3564900d5b67d5b Mon Sep 17 00:00:00 2001 From: Jiacheng Xu Date: Fri, 2 Nov 2018 20:52:12 +0100 Subject: [PATCH] plugin/etcd: make the address of upstream optional (#2262) Automatically submitted. --- plugin/etcd/setup.go | 3 --- plugin/etcd/setup_test.go | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/plugin/etcd/setup.go b/plugin/etcd/setup.go index 4bce42a75..f753a0f1a 100644 --- a/plugin/etcd/setup.go +++ b/plugin/etcd/setup.go @@ -92,9 +92,6 @@ func etcdParse(c *caddy.Controller) (*Etcd, bool, error) { endpoints = args case "upstream": args := c.RemainingArgs() - if len(args) == 0 { - return nil, false, c.ArgErr() - } u, err := upstream.New(args) if err != nil { return nil, false, err diff --git a/plugin/etcd/setup_test.go b/plugin/etcd/setup_test.go index 517aeea54..620460cc1 100644 --- a/plugin/etcd/setup_test.go +++ b/plugin/etcd/setup_test.go @@ -30,6 +30,20 @@ func TestSetupEtcd(t *testing.T) { endpoint localhost:300 } `, false, "skydns", []string{"localhost:300"}, "", + }, + //test for upstream + { + `etcd { + endpoint localhost:300 + upstream 8.8.8.8:53 8.8.4.4:53 +}`, false, "skydns", []string{"localhost:300"}, "", + }, + //test for optional upstream address + { + `etcd { + endpoint localhost:300 + upstream +}`, false, "skydns", []string{"localhost:300"}, "", }, // negative {