summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJordi Masip <[email protected]>2020-12-03 18:02:18 +0100
committerGitHub <[email protected]>2020-12-03 10:02:18 -0700
commite7a5a3850f09d26ddb035a8da4d233efc6a81581 (patch)
tree90c1aeb7c9eca577e67bb89aab18b67de835695f
parent792fca40f18b7c528b00a7dea508bdfd0821dd8c (diff)
downloadcaddy-e7a5a3850f09d26ddb035a8da4d233efc6a81581.tar.gz
caddy-e7a5a3850f09d26ddb035a8da4d233efc6a81581.zip
cmd: add ability to read config from stdin (#3898)
-rw-r--r--cmd/main.go6
1 files changed, 5 insertions, 1 deletions
diff --git a/cmd/main.go b/cmd/main.go
index e92e71f6e..2dfb8677f 100644
--- a/cmd/main.go
+++ b/cmd/main.go
@@ -123,7 +123,11 @@ func loadConfig(configFile, adapterName string) ([]byte, string, error) {
var cfgAdapter caddyconfig.Adapter
var err error
if configFile != "" {
- config, err = ioutil.ReadFile(configFile)
+ if configFile == "-" {
+ config, err = ioutil.ReadAll(os.Stdin)
+ } else {
+ config, err = ioutil.ReadFile(configFile)
+ }
if err != nil {
return nil, "", fmt.Errorf("reading config file: %v", err)
}