Commit dd4b3efa authored by Craig Peterson's avatar Craig Peterson

remove 'macro foo' syntax

parent 3a969bc0
......@@ -461,11 +461,7 @@ type ServerBlock struct {
func (p *parser) isMacro() (bool, string) {
keys := p.block.Keys
// "macro foo {}" style
if len(keys) == 2 && keys[0] == "macro" {
return true, keys[1]
}
// (foo) style. What to do if more than one server key and some have ()?
// A macro block is a single key with parens. Nothing else qualifies.
if len(keys) == 1 && strings.HasPrefix(keys[0], "(") && strings.HasSuffix(keys[0], ")") {
return true, strings.TrimSuffix(keys[0][1:], ")")
}
......
......@@ -15,7 +15,6 @@
package caddyfile
import (
"fmt"
"io/ioutil"
"os"
"path/filepath"
......@@ -517,17 +516,14 @@ func testParser(input string) parser {
}
func TestMacro(t *testing.T) {
for _, tst := range []string{"(common)", "macro common"} {
t.Run(tst, func(t *testing.T) {
p := testParser(fmt.Sprintf(`
%s {
p := testParser(`(common) {
gzip foo
errors stderr
}
http://example.com {
import common
}
`, tst))
`)
blocks, err := p.parseAll()
if err != nil {
t.Fatal(err)
......@@ -551,7 +547,5 @@ func TestMacro(t *testing.T) {
if actual, expected := blocks[0].Tokens["errors"][1].Text, "stderr"; expected != actual {
t.Errorf("Expected argument to be '%s' but was '%s'", expected, actual)
}
})
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment