replace deprecated ioutil function calls

This commit is contained in:
Matthew Penner
2021-11-15 10:24:52 -07:00
parent be543ce3e0
commit d8df353ce8
14 changed files with 130 additions and 101 deletions

View File

@@ -4,7 +4,7 @@ import (
"crypto/tls"
"encoding/json"
"fmt"
"io/ioutil"
"io"
"net/http"
"net/url"
"os"
@@ -19,16 +19,14 @@ import (
"github.com/pterodactyl/wings/config"
)
var (
configureArgs struct {
PanelURL string
Token string
ConfigPath string
Node string
Override bool
AllowInsecure bool
}
)
var configureArgs struct {
PanelURL string
Token string
ConfigPath string
Node string
Override bool
AllowInsecure bool
}
var nodeIdRegex = regexp.MustCompile(`^(\d+)$`)
@@ -140,13 +138,13 @@ func configureCmdRun(cmd *cobra.Command, args []string) {
fmt.Println("The authentication credentials provided were not valid.")
os.Exit(1)
} else if res.StatusCode != http.StatusOK {
b, _ := ioutil.ReadAll(res.Body)
b, _ := io.ReadAll(res.Body)
fmt.Println("An error occurred while processing this request.\n", string(b))
os.Exit(1)
}
b, err := ioutil.ReadAll(res.Body)
b, err := io.ReadAll(res.Body)
cfg, err := config.NewAtPath(configPath)
if err != nil {

View File

@@ -6,7 +6,6 @@ import (
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"net/url"
"os/exec"
@@ -29,19 +28,19 @@ import (
"github.com/pterodactyl/wings/system"
)
const DefaultHastebinUrl = "https://ptero.co"
const DefaultLogLines = 200
var (
diagnosticsArgs struct {
IncludeEndpoints bool
IncludeLogs bool
ReviewBeforeUpload bool
HastebinURL string
LogLines int
}
const (
DefaultHastebinUrl = "https://ptero.co"
DefaultLogLines = 200
)
var diagnosticsArgs struct {
IncludeEndpoints bool
IncludeLogs bool
ReviewBeforeUpload bool
HastebinURL string
LogLines int
}
func newDiagnosticsCommand() *cobra.Command {
command := &cobra.Command{
Use: "diagnostics",
@@ -110,7 +109,6 @@ func diagnosticsCmdRun(cmd *cobra.Command, args []string) {
printHeader(output, "Wings Configuration")
if err := config.FromFile(config.DefaultLocation); err != nil {
}
cfg := config.Get()
fmt.Fprintln(output, " Panel Location:", redact(cfg.PanelLocation))
@@ -226,7 +224,7 @@ func uploadToHastebin(hbUrl, content string) (string, error) {
return "", err
}
pres := make(map[string]interface{})
body, err := ioutil.ReadAll(res.Body)
body, err := io.ReadAll(res.Body)
if err != nil {
fmt.Println("Failed to parse response.", err)
return "", err