mirror of
https://github.com/caddyserver/caddy.git
synced 2024-12-27 06:03:48 +03:00
replacer: working directory global placeholder (#5127)
This commit is contained in:
parent
d46ba2e27f
commit
b4e28af953
2 changed files with 9 additions and 0 deletions
|
@ -308,6 +308,10 @@ func globalDefaultReplacements(key string) (any, bool) {
|
||||||
return string(filepath.Separator), true
|
return string(filepath.Separator), true
|
||||||
case "system.os":
|
case "system.os":
|
||||||
return runtime.GOOS, true
|
return runtime.GOOS, true
|
||||||
|
case "system.wd":
|
||||||
|
// OK if there is an error; just return empty string
|
||||||
|
wd, _ := os.Getwd()
|
||||||
|
return wd, true
|
||||||
case "system.arch":
|
case "system.arch":
|
||||||
return runtime.GOARCH, true
|
return runtime.GOARCH, true
|
||||||
case "time.now":
|
case "time.now":
|
||||||
|
|
|
@ -372,6 +372,7 @@ func TestReplacerNew(t *testing.T) {
|
||||||
} else {
|
} else {
|
||||||
// test if default global replacements are added as the first provider
|
// test if default global replacements are added as the first provider
|
||||||
hostname, _ := os.Hostname()
|
hostname, _ := os.Hostname()
|
||||||
|
wd, _ := os.Getwd()
|
||||||
os.Setenv("CADDY_REPLACER_TEST", "envtest")
|
os.Setenv("CADDY_REPLACER_TEST", "envtest")
|
||||||
defer os.Setenv("CADDY_REPLACER_TEST", "")
|
defer os.Setenv("CADDY_REPLACER_TEST", "")
|
||||||
|
|
||||||
|
@ -395,6 +396,10 @@ func TestReplacerNew(t *testing.T) {
|
||||||
variable: "system.arch",
|
variable: "system.arch",
|
||||||
value: runtime.GOARCH,
|
value: runtime.GOARCH,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
variable: "system.wd",
|
||||||
|
value: wd,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
variable: "env.CADDY_REPLACER_TEST",
|
variable: "env.CADDY_REPLACER_TEST",
|
||||||
value: "envtest",
|
value: "envtest",
|
||||||
|
|
Loading…
Reference in a new issue