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
Łukasz Nowak
caddy
Commits
8b8afd72
Commit
8b8afd72
authored
Aug 17, 2016
by
Matthew Holt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support env vars in import; make sure it's a file
parent
c5524b0b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
caddyfile/parse.go
caddyfile/parse.go
+12
-2
No files found.
caddyfile/parse.go
View file @
8b8afd72
...
...
@@ -201,11 +201,14 @@ func (p *parser) directives() error {
// other words, call Next() to access the first token that was
// imported.
func
(
p
*
parser
)
doImport
()
error
{
// syntax check
// syntax check
s
if
!
p
.
NextArg
()
{
return
p
.
ArgErr
()
}
importPattern
:=
p
.
Val
()
importPattern
:=
replaceEnvVars
(
p
.
Val
())
if
importPattern
==
""
{
return
p
.
Err
(
"Import requires a non-empty filepath"
)
}
if
p
.
NextArg
()
{
return
p
.
Err
(
"Import takes only one argument (glob pattern or file)"
)
}
...
...
@@ -284,6 +287,13 @@ func (p *parser) doSingleImport(importFile string) ([]Token, error) {
return
nil
,
p
.
Errf
(
"Could not import %s: %v"
,
importFile
,
err
)
}
defer
file
.
Close
()
if
info
,
err
:=
file
.
Stat
();
err
!=
nil
{
return
nil
,
p
.
Errf
(
"Could not import %s: %v"
,
importFile
,
err
)
}
else
if
info
.
IsDir
()
{
return
nil
,
p
.
Errf
(
"Could not import %s: is a directory"
,
importFile
)
}
importedTokens
:=
allTokens
(
file
)
// Tack the filename onto these tokens so errors show the imported file's name
...
...
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