cmd: add ability to read config from stdin (#3898)

This commit is contained in:
Jordi Masip
2020-12-03 18:02:18 +01:00
committed by GitHub
parent 792fca40f1
commit e7a5a3850f

View File

@@ -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)
}