From e7a5a3850f09d26ddb035a8da4d233efc6a81581 Mon Sep 17 00:00:00 2001 From: Jordi Masip Date: Thu, 3 Dec 2020 18:02:18 +0100 Subject: [PATCH] cmd: add ability to read config from stdin (#3898) --- cmd/main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cmd/main.go b/cmd/main.go index e92e71f6..2dfb8677 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) }