Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
caddy
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
caddy
Commits
dd4b3efa
Commit
dd4b3efa
authored
Oct 15, 2017
by
Craig Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove 'macro foo' syntax
parent
3a969bc0
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
35 deletions
+25
-35
caddyfile/parse.go
caddyfile/parse.go
+1
-5
caddyfile/parse_test.go
caddyfile/parse_test.go
+24
-30
No files found.
caddyfile/parse.go
View file @
dd4b3efa
...
@@ -461,11 +461,7 @@ type ServerBlock struct {
...
@@ -461,11 +461,7 @@ type ServerBlock struct {
func
(
p
*
parser
)
isMacro
()
(
bool
,
string
)
{
func
(
p
*
parser
)
isMacro
()
(
bool
,
string
)
{
keys
:=
p
.
block
.
Keys
keys
:=
p
.
block
.
Keys
// "macro foo {}" style
// A macro block is a single key with parens. Nothing else qualifies.
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 ()?
if
len
(
keys
)
==
1
&&
strings
.
HasPrefix
(
keys
[
0
],
"("
)
&&
strings
.
HasSuffix
(
keys
[
0
],
")"
)
{
if
len
(
keys
)
==
1
&&
strings
.
HasPrefix
(
keys
[
0
],
"("
)
&&
strings
.
HasSuffix
(
keys
[
0
],
")"
)
{
return
true
,
strings
.
TrimSuffix
(
keys
[
0
][
1
:
],
")"
)
return
true
,
strings
.
TrimSuffix
(
keys
[
0
][
1
:
],
")"
)
}
}
...
...
caddyfile/parse_test.go
View file @
dd4b3efa
...
@@ -15,7 +15,6 @@
...
@@ -15,7 +15,6 @@
package
caddyfile
package
caddyfile
import
(
import
(
"fmt"
"io/ioutil"
"io/ioutil"
"os"
"os"
"path/filepath"
"path/filepath"
...
@@ -517,17 +516,14 @@ func testParser(input string) parser {
...
@@ -517,17 +516,14 @@ func testParser(input string) parser {
}
}
func
TestMacro
(
t
*
testing
.
T
)
{
func
TestMacro
(
t
*
testing
.
T
)
{
for
_
,
tst
:=
range
[]
string
{
"(common)"
,
"macro common"
}
{
p
:=
testParser
(
`(common) {
t
.
Run
(
tst
,
func
(
t
*
testing
.
T
)
{
p
:=
testParser
(
fmt
.
Sprintf
(
`
%s {
gzip foo
gzip foo
errors stderr
errors stderr
}
}
http://example.com {
http://example.com {
import common
import common
}
}
`
,
tst
)
)
`
)
blocks
,
err
:=
p
.
parseAll
()
blocks
,
err
:=
p
.
parseAll
()
if
err
!=
nil
{
if
err
!=
nil
{
t
.
Fatal
(
err
)
t
.
Fatal
(
err
)
...
@@ -551,7 +547,5 @@ func TestMacro(t *testing.T) {
...
@@ -551,7 +547,5 @@ func TestMacro(t *testing.T) {
if
actual
,
expected
:=
blocks
[
0
]
.
Tokens
[
"errors"
][
1
]
.
Text
,
"stderr"
;
expected
!=
actual
{
if
actual
,
expected
:=
blocks
[
0
]
.
Tokens
[
"errors"
][
1
]
.
Text
,
"stderr"
;
expected
!=
actual
{
t
.
Errorf
(
"Expected argument to be '%s' but was '%s'"
,
expected
,
actual
)
t
.
Errorf
(
"Expected argument to be '%s' but was '%s'"
,
expected
,
actual
)
}
}
})
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment