Commit 18e9aa4d authored by Matthew Holt's avatar Matthew Holt

Pipe and -conf flag together are an error (#315)

parent cf5aa1be
...@@ -282,15 +282,7 @@ func LoadCaddyfile(loader func() (Input, error)) (cdyfile Input, err error) { ...@@ -282,15 +282,7 @@ func LoadCaddyfile(loader func() (Input, error)) (cdyfile Input, err error) {
cdyfile = loadedGob.Caddyfile cdyfile = loadedGob.Caddyfile
} }
// Otherwise, we first try to get from stdin pipe // Try user's loader
if cdyfile == nil {
cdyfile, err = CaddyfileFromPipe(os.Stdin)
if err != nil {
return nil, err
}
}
// No piped input, so try the user's loader instead
if cdyfile == nil && loader != nil { if cdyfile == nil && loader != nil {
cdyfile, err = loader() cdyfile, err = loader()
} }
......
...@@ -117,6 +117,19 @@ func mustLogFatal(args ...interface{}) { ...@@ -117,6 +117,19 @@ func mustLogFatal(args ...interface{}) {
} }
func loadCaddyfile() (caddy.Input, error) { func loadCaddyfile() (caddy.Input, error) {
// First try stdin pipe
cdyfile, err := caddy.CaddyfileFromPipe(os.Stdin)
if err != nil {
return nil, err
}
if cdyfile != nil {
// it is an error if -conf is also specified because, which to use?
if conf != "" {
return nil, errors.New("load: can't choose between stdin pipe and -conf flag")
}
return cdyfile, err
}
// -conf flag // -conf flag
if conf != "" { if conf != "" {
contents, err := ioutil.ReadFile(conf) contents, err := ioutil.ReadFile(conf)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment