Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
C
Coredns
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Railgun
Coredns
Commits
c1d7c2e6
Commit
c1d7c2e6
authored
Jun 13, 2019
by
An Xiao
Committed by
Miek Gieben
Jun 13, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Raise error if regexp and template are not specified together (#2884)
Signed-off-by:
Xiao An
<
hac@zju.edu.cn
>
parent
481dea50
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
4 deletions
+11
-4
plugin/auto/setup.go
plugin/auto/setup.go
+4
-4
plugin/auto/setup_test.go
plugin/auto/setup_test.go
+7
-0
No files found.
plugin/auto/setup.go
View file @
c1d7c2e6
...
@@ -120,7 +120,7 @@ func autoParse(c *caddy.Controller) (Auto, error) {
...
@@ -120,7 +120,7 @@ func autoParse(c *caddy.Controller) (Auto, error) {
}
}
}
}
// regexp
// regexp
template
if
c
.
NextArg
()
{
if
c
.
NextArg
()
{
a
.
loader
.
re
,
err
=
regexp
.
Compile
(
c
.
Val
())
a
.
loader
.
re
,
err
=
regexp
.
Compile
(
c
.
Val
())
if
err
!=
nil
{
if
err
!=
nil
{
...
@@ -129,10 +129,10 @@ func autoParse(c *caddy.Controller) (Auto, error) {
...
@@ -129,10 +129,10 @@ func autoParse(c *caddy.Controller) (Auto, error) {
if
a
.
loader
.
re
.
NumSubexp
()
==
0
{
if
a
.
loader
.
re
.
NumSubexp
()
==
0
{
return
a
,
c
.
Errf
(
"Need at least one sub expression"
)
return
a
,
c
.
Errf
(
"Need at least one sub expression"
)
}
}
}
// template
if
!
c
.
NextArg
()
{
if
c
.
NextArg
()
{
return
a
,
c
.
ArgErr
()
}
a
.
loader
.
template
=
rewriteToExpand
(
c
.
Val
())
a
.
loader
.
template
=
rewriteToExpand
(
c
.
Val
())
}
}
...
...
plugin/auto/setup_test.go
View file @
c1d7c2e6
...
@@ -75,6 +75,13 @@ func TestAutoParse(t *testing.T) {
...
@@ -75,6 +75,13 @@ func TestAutoParse(t *testing.T) {
}`
,
}`
,
true
,
"/tmp"
,
"bliep"
,
`(.*)`
,
10
*
time
.
Second
,
nil
,
true
,
"/tmp"
,
"bliep"
,
`(.*)`
,
10
*
time
.
Second
,
nil
,
},
},
// no template specified.
{
`auto {
directory /tmp (.*)
}`
,
true
,
"/tmp"
,
""
,
`(.*)`
,
60
*
time
.
Second
,
nil
,
},
// no directory specified.
// no directory specified.
{
{
`auto example.org {
`auto example.org {
...
...
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