|
|
@ -22,7 +22,6 @@ import ( |
|
|
|
"errors" |
|
|
|
"fmt" |
|
|
|
"io" |
|
|
|
"io/ioutil" |
|
|
|
"log" |
|
|
|
"net" |
|
|
|
"net/http" |
|
|
@ -181,7 +180,7 @@ func cmdRun(fl Flags) (int, error) { |
|
|
|
var config []byte |
|
|
|
var err error |
|
|
|
if runCmdResumeFlag { |
|
|
|
config, err = ioutil.ReadFile(caddy.ConfigAutosavePath) |
|
|
|
config, err = os.ReadFile(caddy.ConfigAutosavePath) |
|
|
|
if os.IsNotExist(err) { |
|
|
|
// not a bad error; just can't resume if autosave file doesn't exist
|
|
|
|
caddy.Log().Info("no autosave file exists", zap.String("autosave_file", caddy.ConfigAutosavePath)) |
|
|
@ -219,7 +218,7 @@ func cmdRun(fl Flags) (int, error) { |
|
|
|
// if we are to report to another process the successful start
|
|
|
|
// of the server, do so now by echoing back contents of stdin
|
|
|
|
if runCmdPingbackFlag != "" { |
|
|
|
confirmationBytes, err := ioutil.ReadAll(os.Stdin) |
|
|
|
confirmationBytes, err := io.ReadAll(os.Stdin) |
|
|
|
if err != nil { |
|
|
|
return caddy.ExitCodeFailedStartup, |
|
|
|
fmt.Errorf("reading confirmation bytes from stdin: %v", err) |
|
|
@ -457,7 +456,7 @@ func cmdAdaptConfig(fl Flags) (int, error) { |
|
|
|
fmt.Errorf("unrecognized config adapter: %s", adaptCmdAdapterFlag) |
|
|
|
} |
|
|
|
|
|
|
|
input, err := ioutil.ReadFile(adaptCmdInputFlag) |
|
|
|
input, err := os.ReadFile(adaptCmdInputFlag) |
|
|
|
if err != nil { |
|
|
|
return caddy.ExitCodeFailedStartup, |
|
|
|
fmt.Errorf("reading input file: %v", err) |
|
|
@ -541,7 +540,7 @@ func cmdFmt(fl Flags) (int, error) { |
|
|
|
|
|
|
|
// as a special case, read from stdin if the file name is "-"
|
|
|
|
if formatCmdConfigFile == "-" { |
|
|
|
input, err := ioutil.ReadAll(os.Stdin) |
|
|
|
input, err := io.ReadAll(os.Stdin) |
|
|
|
if err != nil { |
|
|
|
return caddy.ExitCodeFailedStartup, |
|
|
|
fmt.Errorf("reading stdin: %v", err) |
|
|
@ -550,7 +549,7 @@ func cmdFmt(fl Flags) (int, error) { |
|
|
|
return caddy.ExitCodeSuccess, nil |
|
|
|
} |
|
|
|
|
|
|
|
input, err := ioutil.ReadFile(formatCmdConfigFile) |
|
|
|
input, err := os.ReadFile(formatCmdConfigFile) |
|
|
|
if err != nil { |
|
|
|
return caddy.ExitCodeFailedStartup, |
|
|
|
fmt.Errorf("reading input file: %v", err) |
|
|
@ -559,7 +558,7 @@ func cmdFmt(fl Flags) (int, error) { |
|
|
|
output := caddyfile.Format(input) |
|
|
|
|
|
|
|
if fl.Bool("overwrite") { |
|
|
|
if err := ioutil.WriteFile(formatCmdConfigFile, output, 0600); err != nil { |
|
|
|
if err := os.WriteFile(formatCmdConfigFile, output, 0600); err != nil { |
|
|
|
return caddy.ExitCodeFailedStartup, nil |
|
|
|
} |
|
|
|
} else { |
|
|
@ -699,7 +698,7 @@ func apiRequest(adminAddr, method, uri string, headers http.Header, body io.Read |
|
|
|
|
|
|
|
// if it didn't work, let the user know
|
|
|
|
if resp.StatusCode >= 400 { |
|
|
|
respBody, err := ioutil.ReadAll(io.LimitReader(resp.Body, 1024*10)) |
|
|
|
respBody, err := io.ReadAll(io.LimitReader(resp.Body, 1024*10)) |
|
|
|
if err != nil { |
|
|
|
return fmt.Errorf("HTTP %d: reading error message: %v", resp.StatusCode, err) |
|
|
|
} |
|
|
|