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
1f8d1df4
Commit
1f8d1df4
authored
Oct 30, 2018
by
Darshan Chaudhary
Committed by
Matt Holt
Oct 30, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
caddyfile: Allow partial directive env var expansion (#2253)
parent
dd836874
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
9 additions
and
1 deletion
+9
-1
caddyfile/parse.go
caddyfile/parse.go
+1
-1
caddyfile/parse_test.go
caddyfile/parse_test.go
+8
-0
No files found.
caddyfile/parse.go
View file @
1f8d1df4
...
...
@@ -343,7 +343,7 @@ func (p *parser) doSingleImport(importFile string) ([]Token, error) {
// are loaded into the current server block for later use
// by directive setup functions.
func
(
p
*
parser
)
directive
()
error
{
dir
:=
p
.
Val
(
)
dir
:=
replaceEnvVars
(
p
.
Val
()
)
nesting
:=
0
// TODO: More helpful error message ("did you mean..." or "maybe you need to install its server type")
...
...
caddyfile/parse_test.go
View file @
1f8d1df4
...
...
@@ -452,6 +452,7 @@ func TestEnvironmentReplacement(t *testing.T) {
os
.
Setenv
(
"PORT"
,
"8080"
)
os
.
Setenv
(
"ADDRESS"
,
"servername.com"
)
os
.
Setenv
(
"FOOBAR"
,
"foobar"
)
os
.
Setenv
(
"PARTIAL_DIR"
,
"r1"
)
// basic test; unix-style env vars
p
:=
testParser
(
`{$ADDRESS}`
)
...
...
@@ -460,6 +461,13 @@ func TestEnvironmentReplacement(t *testing.T) {
t
.
Errorf
(
"Expected key to be '%s' but was '%s'"
,
expected
,
actual
)
}
// basic test; unix-style env vars
p
=
testParser
(
`di{$PARTIAL_DIR}`
)
blocks
,
_
=
p
.
parseAll
()
if
actual
,
expected
:=
blocks
[
0
]
.
Keys
[
0
],
"dir1"
;
expected
!=
actual
{
t
.
Errorf
(
"Expected key to be '%s' but was '%s'"
,
expected
,
actual
)
}
// multiple vars per token
p
=
testParser
(
`{$ADDRESS}:{$PORT}`
)
blocks
,
_
=
p
.
parseAll
()
...
...
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