mirror of
https://github.com/StackExchange/dnscontrol.git
synced 2024-09-20 06:46:19 +08:00
CHORE: Remove deprecated io/ioutil (#1699)
* Remove deprecated io/ioutil * fixup! * fixup!
This commit is contained in:
parent
5e8bb6e461
commit
cd61c2c766
|
@ -3,7 +3,7 @@ package main
|
|||
import (
|
||||
"bytes"
|
||||
"html/template"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sort"
|
||||
|
||||
"github.com/StackExchange/dnscontrol/v3/providers"
|
||||
|
@ -109,7 +109,7 @@ func generateFeatureMatrix() error {
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return ioutil.WriteFile("docs/_includes/matrix.html", buf.Bytes(), 0644)
|
||||
return os.WriteFile("docs/_includes/matrix.html", buf.Bytes(), 0644)
|
||||
}
|
||||
|
||||
// FeatureDef describes features.
|
||||
|
|
|
@ -2,7 +2,6 @@ package commands
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/ditashi/jsbeautifier-go/jsbeautifier"
|
||||
|
@ -47,7 +46,7 @@ func (args *FmtArgs) flags() []cli.Flag {
|
|||
|
||||
// FmtFile reads and formats a file.
|
||||
func FmtFile(args FmtArgs) error {
|
||||
fileBytes, readErr := ioutil.ReadFile(args.InputFile)
|
||||
fileBytes, readErr := os.ReadFile(args.InputFile)
|
||||
if readErr != nil {
|
||||
return readErr
|
||||
}
|
||||
|
@ -67,7 +66,7 @@ func FmtFile(args FmtArgs) error {
|
|||
if args.OutputFile == "" {
|
||||
fmt.Print(beautified)
|
||||
} else {
|
||||
if err := ioutil.WriteFile(args.OutputFile, []byte(beautified), 0744); err != nil {
|
||||
if err := os.WriteFile(args.OutputFile, []byte(beautified), 0744); err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Fprintf(os.Stderr, "File %s successfully written\n", args.OutputFile)
|
||||
|
|
|
@ -2,7 +2,6 @@ package commands
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
|
@ -33,7 +32,7 @@ func testFormat(t *testing.T, domain, format string) {
|
|||
expectedFilename := fmt.Sprintf("test_data/%s.zone.%s", domain, format)
|
||||
outputFiletmpl := fmt.Sprintf("%s.zone.%s.*.txt", domain, format)
|
||||
|
||||
outfile, err := ioutil.TempFile("", outputFiletmpl)
|
||||
outfile, err := os.CreateTemp("", outputFiletmpl)
|
||||
if err != nil {
|
||||
log.Fatal(fmt.Errorf("gz can't TempFile %q: %w", outputFiletmpl, err))
|
||||
}
|
||||
|
@ -56,19 +55,19 @@ func testFormat(t *testing.T, domain, format string) {
|
|||
}
|
||||
|
||||
// Read the actual result:
|
||||
got, err := ioutil.ReadFile(outfile.Name())
|
||||
got, err := os.ReadFile(outfile.Name())
|
||||
if err != nil {
|
||||
log.Fatal(fmt.Errorf("can't read actuals %q: %w", outfile.Name(), err))
|
||||
}
|
||||
|
||||
// Read the expected result
|
||||
want, err := ioutil.ReadFile(expectedFilename)
|
||||
want, err := os.ReadFile(expectedFilename)
|
||||
if err != nil {
|
||||
log.Fatal(fmt.Errorf("can't read expected %q: %w", outfile.Name(), err))
|
||||
}
|
||||
|
||||
// // Update got -> want
|
||||
// err = ioutil.WriteFile(expectedFilename, got, 0644)
|
||||
// err = os.WriteFile(expectedFilename, got, 0644)
|
||||
// if err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"log"
|
||||
"net/url"
|
||||
"sort"
|
||||
|
@ -101,7 +101,7 @@ func NewVault(cfg *models.DNSConfig, vaultPath string, email string, server stri
|
|||
// It will return true if it issued or updated the certificate.
|
||||
func (c *certManager) IssueOrRenewCert(cfg *CertConfig, renewUnder int, verbose bool) (bool, error) {
|
||||
if !verbose {
|
||||
acmelog.Logger = log.New(ioutil.Discard, "", 0)
|
||||
acmelog.Logger = log.New(io.Discard, "", 0)
|
||||
}
|
||||
defer c.finalCleanUp()
|
||||
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"encoding/json"
|
||||
"encoding/pem"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
|
@ -53,7 +52,7 @@ func (d directoryStorage) GetCertificate(name string) (*certificate.Resource, er
|
|||
return nil, err
|
||||
}
|
||||
// load cert
|
||||
crtBytes, err := ioutil.ReadFile(d.certFile(name, "crt"))
|
||||
crtBytes, err := os.ReadFile(d.certFile(name, "crt"))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -75,16 +74,16 @@ func (d directoryStorage) StoreCertificate(name string, cert *certificate.Resour
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = ioutil.WriteFile(d.certFile(name, "json"), jDAt, perms); err != nil {
|
||||
if err = os.WriteFile(d.certFile(name, "json"), jDAt, perms); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = ioutil.WriteFile(d.certFile(name, "crt"), pub, perms); err != nil {
|
||||
if err = os.WriteFile(d.certFile(name, "crt"), pub, perms); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = ioutil.WriteFile(d.certFile(name, "pem"), combined, perms); err != nil {
|
||||
if err = os.WriteFile(d.certFile(name, "pem"), combined, perms); err != nil {
|
||||
return err
|
||||
}
|
||||
return ioutil.WriteFile(d.certFile(name, "key"), priv, perms)
|
||||
return os.WriteFile(d.certFile(name, "key"), priv, perms)
|
||||
}
|
||||
|
||||
func (d directoryStorage) GetAccount(acmeHost string) (*Account, error) {
|
||||
|
@ -101,7 +100,7 @@ func (d directoryStorage) GetAccount(acmeHost string) (*Account, error) {
|
|||
if err = dec.Decode(acct); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
keyBytes, err := ioutil.ReadFile(d.accountKeyFile(acmeHost))
|
||||
keyBytes, err := os.ReadFile(d.accountKeyFile(acmeHost))
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -124,7 +123,7 @@ func (d directoryStorage) StoreAccount(acmeHost string, account *Account) error
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = ioutil.WriteFile(d.accountFile(acmeHost), acctBytes, perms); err != nil {
|
||||
if err = os.WriteFile(d.accountFile(acmeHost), acctBytes, perms); err != nil {
|
||||
return err
|
||||
}
|
||||
keyBytes, err := x509.MarshalECPrivateKey(account.key)
|
||||
|
@ -133,5 +132,5 @@ func (d directoryStorage) StoreAccount(acmeHost string, account *Account) error
|
|||
}
|
||||
pemKey := &pem.Block{Type: "EC PRIVATE KEY", Bytes: keyBytes}
|
||||
pemBytes := pem.EncodeToMemory(pemKey)
|
||||
return ioutil.WriteFile(d.accountKeyFile(acmeHost), pemBytes, perms)
|
||||
return os.WriteFile(d.accountKeyFile(acmeHost), pemBytes, perms)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
_ "embed" // Used to embed helpers.js in the binary.
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -40,7 +39,7 @@ var EnableFetch bool = false
|
|||
|
||||
// ExecuteJavascript accepts a javascript string and runs it, returning the resulting dnsConfig.
|
||||
func ExecuteJavascript(file string, devMode bool, variables map[string]string) (*models.DNSConfig, error) {
|
||||
script, err := ioutil.ReadFile(file)
|
||||
script, err := os.ReadFile(file)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -111,7 +110,7 @@ func ExecuteJavascript(file string, devMode bool, variables map[string]string) (
|
|||
func GetHelpers(devMode bool) string {
|
||||
if devMode {
|
||||
// Load the file:
|
||||
b, err := ioutil.ReadFile(helpersJsFileName)
|
||||
b, err := os.ReadFile(helpersJsFileName)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -143,7 +142,7 @@ func require(call otto.FunctionCall) otto.Value {
|
|||
|
||||
printer.Debugf("requiring: %s (%s)\n", file, relFile)
|
||||
// quick fix, by replacing to linux slashes, to make it work with windows paths too.
|
||||
data, err := ioutil.ReadFile(filepath.ToSlash(relFile))
|
||||
data, err := os.ReadFile(filepath.ToSlash(relFile))
|
||||
|
||||
if err != nil {
|
||||
throw(call.Otto, err.Error())
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
@ -28,7 +27,7 @@ func init() {
|
|||
}
|
||||
|
||||
func TestParsedFiles(t *testing.T) {
|
||||
files, err := ioutil.ReadDir(testDir)
|
||||
files, err := os.ReadDir(testDir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -80,7 +79,7 @@ func TestParsedFiles(t *testing.T) {
|
|||
}
|
||||
testName := name[:len(name)-3]
|
||||
expectedFile := filepath.Join(testDir, testName+".json")
|
||||
expectedJSON, err := ioutil.ReadFile(expectedFile)
|
||||
expectedJSON, err := os.ReadFile(expectedFile)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -88,7 +87,7 @@ func TestParsedFiles(t *testing.T) {
|
|||
as := string(actualJSON)
|
||||
_, _ = es, as
|
||||
// When debugging, leave behind the actual result:
|
||||
//ioutil.WriteFile(expectedFile+".ACTUAL", []byte(es), 0644)
|
||||
// os.WriteFile(expectedFile+".ACTUAL", []byte(es), 0644)
|
||||
testifyrequire.JSONEqf(t, es, as, "EXPECTING %q = \n```\n%s\n```", expectedFile, as)
|
||||
|
||||
// For each domain, if there is a zone file, test against it:
|
||||
|
@ -101,7 +100,7 @@ func TestParsedFiles(t *testing.T) {
|
|||
var dCount int
|
||||
for _, dc := range conf.Domains {
|
||||
zoneFile := filepath.Join(testDir, testName, dc.Name+".zone")
|
||||
expectedZone, err := ioutil.ReadFile(zoneFile)
|
||||
expectedZone, err := os.ReadFile(zoneFile)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
@ -119,7 +118,7 @@ func TestParsedFiles(t *testing.T) {
|
|||
as := actualZone
|
||||
if es != as {
|
||||
// On failure, leave behind the .ACTUAL file.
|
||||
ioutil.WriteFile(zoneFile+".ACTUAL", []byte(actualZone), 0644)
|
||||
os.WriteFile(zoneFile+".ACTUAL", []byte(actualZone), 0644)
|
||||
}
|
||||
testifyrequire.Equal(t, es, as, "EXPECTING %q =\n```\n%s```", zoneFile, as)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package spflib
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"os"
|
||||
"strings"
|
||||
|
@ -137,5 +136,5 @@ func (c *cache) Save(filename string) error {
|
|||
}
|
||||
}
|
||||
dat, _ := json.MarshalIndent(outRecs, "", " ")
|
||||
return ioutil.WriteFile(filename, dat, 0644)
|
||||
return os.WriteFile(filename, dat, 0644)
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"sort"
|
||||
|
||||
|
@ -50,7 +49,7 @@ func (api *autoDnsProvider) request(method string, requestPath string, data inte
|
|||
}
|
||||
defer response.Body.Close()
|
||||
|
||||
responseText, _ := ioutil.ReadAll(response.Body)
|
||||
responseText, _ := io.ReadAll(response.Body)
|
||||
if response.StatusCode != 200 {
|
||||
return nil, errors.New("Request to " + requestURL.Path + " failed: " + string(responseText))
|
||||
}
|
||||
|
|
|
@ -17,13 +17,13 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/StackExchange/dnscontrol/v3/pkg/printer"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/StackExchange/dnscontrol/v3/pkg/printer"
|
||||
|
||||
"github.com/miekg/dns"
|
||||
|
||||
"github.com/StackExchange/dnscontrol/v3/models"
|
||||
|
@ -166,7 +166,7 @@ func (c *bindProvider) GetZoneRecords(domain string) (models.Records, error) {
|
|||
c.zonefile = filepath.Join(c.directory,
|
||||
makeFileName(c.filenameformat, domain, domain, ""))
|
||||
}
|
||||
content, err := ioutil.ReadFile(c.zonefile)
|
||||
content, err := os.ReadFile(c.zonefile)
|
||||
if os.IsNotExist(err) {
|
||||
// If the file doesn't exist, that's not an error. Just informational.
|
||||
c.zoneFileFound = false
|
||||
|
|
|
@ -3,7 +3,7 @@ package cloudns
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
@ -218,7 +218,7 @@ func (c *cloudnsProvider) get(endpoint string, params requestParams) ([]byte, er
|
|||
return []byte{}, err
|
||||
}
|
||||
|
||||
bodyString, _ := ioutil.ReadAll(resp.Body)
|
||||
bodyString, _ := io.ReadAll(resp.Body)
|
||||
|
||||
// Got error from API ?
|
||||
var errResp errorResponse
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"os"
|
||||
"sort"
|
||||
|
@ -538,7 +538,7 @@ func (client *providerClient) put(endpoint string, requestBody []byte) ([]byte,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
bodyString, _ := ioutil.ReadAll(resp.Body)
|
||||
bodyString, _ := io.ReadAll(resp.Body)
|
||||
if resp.StatusCode == 200 {
|
||||
return bodyString, nil
|
||||
}
|
||||
|
@ -573,7 +573,7 @@ func (client *providerClient) delete(endpoint string) ([]byte, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
bodyString, _ := ioutil.ReadAll(resp.Body)
|
||||
bodyString, _ := io.ReadAll(resp.Body)
|
||||
if resp.StatusCode == 200 {
|
||||
//printer.Printf("DEBUG: Delete successful (200)\n")
|
||||
return bodyString, nil
|
||||
|
@ -609,7 +609,7 @@ func (client *providerClient) post(endpoint string, requestBody []byte) ([]byte,
|
|||
return nil, err
|
||||
}
|
||||
|
||||
bodyString, _ := ioutil.ReadAll(resp.Body)
|
||||
bodyString, _ := io.ReadAll(resp.Body)
|
||||
//printer.Printf("------------------\n")
|
||||
//printer.Printf("DEBUG: resp.StatusCode == %d\n", resp.StatusCode)
|
||||
//printer.Printf("POST RESPONSE = %s\n", bodyString)
|
||||
|
@ -650,7 +650,7 @@ func (client *providerClient) geturl(url string) ([]byte, error) {
|
|||
return nil, err
|
||||
}
|
||||
|
||||
bodyString, _ := ioutil.ReadAll(resp.Body)
|
||||
bodyString, _ := io.ReadAll(resp.Body)
|
||||
if resp.StatusCode == 200 {
|
||||
return bodyString, nil
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"regexp"
|
||||
"strconv"
|
||||
|
@ -284,7 +284,7 @@ retry:
|
|||
return []byte{}, resp, err
|
||||
}
|
||||
|
||||
bodyString, _ := ioutil.ReadAll(resp.Body)
|
||||
bodyString, _ := io.ReadAll(resp.Body)
|
||||
// Got error from API ?
|
||||
if resp.StatusCode > 299 {
|
||||
if resp.StatusCode == 429 && retrycnt < 5 {
|
||||
|
@ -350,7 +350,7 @@ retry:
|
|||
return []byte{}, err
|
||||
}
|
||||
|
||||
bodyString, _ := ioutil.ReadAll(resp.Body)
|
||||
bodyString, _ := io.ReadAll(resp.Body)
|
||||
|
||||
// Got error from API ?
|
||||
if resp.StatusCode > 299 {
|
||||
|
|
|
@ -6,7 +6,7 @@ import (
|
|||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
@ -71,7 +71,7 @@ func (c *easynameProvider) request(method, uri string, body *bytes.Buffer, resul
|
|||
return err
|
||||
}
|
||||
|
||||
bodyString, _ := ioutil.ReadAll(resp.Body)
|
||||
bodyString, _ := io.ReadAll(resp.Body)
|
||||
json.Unmarshal(bodyString, &result)
|
||||
|
||||
status := result.GetStatus()
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"crypto/sha1"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/cookiejar"
|
||||
"net/url"
|
||||
|
@ -631,7 +630,7 @@ func (c *hednsProvider) saveSessionFile() error {
|
|||
}
|
||||
|
||||
fileName := path.Join(c.SessionFilePath, sessionFileName)
|
||||
err = ioutil.WriteFile(fileName, []byte(strings.Join(entries, "\n")), 0600)
|
||||
err = os.WriteFile(fileName, []byte(strings.Join(entries, "\n")), 0600)
|
||||
return err
|
||||
}
|
||||
|
||||
|
@ -642,7 +641,7 @@ func (c *hednsProvider) loadSessionFile() error {
|
|||
}
|
||||
|
||||
fileName := path.Join(c.SessionFilePath, sessionFileName)
|
||||
bytes, err := ioutil.ReadFile(fileName)
|
||||
bytes, err := os.ReadFile(fileName)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
// Skip loading the session.
|
||||
|
|
|
@ -4,13 +4,13 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/StackExchange/dnscontrol/v3/pkg/printer"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/StackExchange/dnscontrol/v3/pkg/printer"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -251,7 +251,7 @@ func (api *hetznerProvider) request(endpoint string, method string, request inte
|
|||
|
||||
defer cleanupResponseBody()
|
||||
if !statusOK(resp.StatusCode) {
|
||||
data, _ := ioutil.ReadAll(resp.Body)
|
||||
data, _ := io.ReadAll(resp.Body)
|
||||
printer.Printf(string(data))
|
||||
return fmt.Errorf("bad status code from HETZNER: %d not 200", resp.StatusCode)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/StackExchange/dnscontrol/v3/pkg/diff"
|
||||
|
@ -252,7 +252,7 @@ func (hp *hostingdeProvider) get(service, method string, params request) (*respo
|
|||
return nil, fmt.Errorf("error occurred: %s", resp.Status)
|
||||
}
|
||||
|
||||
bodyBytes, err := ioutil.ReadAll(resp.Body)
|
||||
bodyBytes, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("could not read response body: %w", err)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package internetbs
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"strings"
|
||||
)
|
||||
|
@ -71,7 +71,7 @@ func (c *internetbsProvider) get(endpoint string, params requestParams) ([]byte,
|
|||
return []byte{}, err
|
||||
}
|
||||
|
||||
bodyString, _ := ioutil.ReadAll(resp.Body)
|
||||
bodyString, _ := io.ReadAll(resp.Body)
|
||||
|
||||
// Got error from API ?
|
||||
var errResp errorResponse
|
||||
|
|
|
@ -4,11 +4,11 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/StackExchange/dnscontrol/v3/pkg/printer"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/StackExchange/dnscontrol/v3/pkg/printer"
|
||||
|
||||
"github.com/StackExchange/dnscontrol/v3/models"
|
||||
"github.com/TomOnTime/utfutil"
|
||||
ps "github.com/bhendo/go-powershell"
|
||||
|
@ -102,7 +102,7 @@ func generatePSZoneAll(dnsserver string) string {
|
|||
|
||||
func (psh *psHandle) GetDNSZoneRecords(dnsserver, domain string) ([]nativeRecord, error) {
|
||||
|
||||
tmpfile, err := ioutil.TempFile("", "zonerecords.*.json")
|
||||
tmpfile, err := os.CreateTemp("", "zonerecords.*.json")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ func (psh *psHandle) GetDNSZoneRecords(dnsserver, domain string) ([]nativeRecord
|
|||
//printer.Printf("CONTENTS = %s\n", contents)
|
||||
//printer.Printf("CONTENTS STR = %q\n", contents[:10])
|
||||
//printer.Printf("CONTENTS HEX = %v\n", []byte(contents)[:10])
|
||||
//ioutil.WriteFile("/temp/list.json", contents, 0777)
|
||||
//os.WriteFile("/temp/list.json", contents, 0777)
|
||||
var records []nativeRecord
|
||||
err = json.Unmarshal(contents, &records)
|
||||
if err != nil {
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
)
|
||||
|
||||
|
@ -140,7 +140,7 @@ func (api *netcupProvider) get(action string, params interface{}) (json.RawMessa
|
|||
return nil, err
|
||||
}
|
||||
|
||||
bodyString, _ := ioutil.ReadAll(resp.Body)
|
||||
bodyString, _ := io.ReadAll(resp.Body)
|
||||
|
||||
respData := &response{}
|
||||
err = json.Unmarshal(bodyString, &respData)
|
||||
|
|
|
@ -2,8 +2,9 @@ package octoyaml
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"os"
|
||||
|
||||
"github.com/StackExchange/dnscontrol/v3/pkg/printer"
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/StackExchange/dnscontrol/v3/models"
|
||||
"github.com/StackExchange/dnscontrol/v3/pkg/transform"
|
||||
|
@ -50,7 +51,7 @@ func ExecuteJavascript(script string, devMode bool) (*models.DNSConfig, error) {
|
|||
|
||||
// GetHelpers returns the filename of helpers.js, or the esc'ed version.
|
||||
func GetHelpers(devMode bool) string {
|
||||
d, err := ioutil.ReadFile("../pkg/js/helpers.js")
|
||||
d, err := os.ReadFile("../pkg/js/helpers.js")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -63,7 +64,7 @@ func require(call otto.FunctionCall) otto.Value {
|
|||
}
|
||||
file := call.Argument(0).String()
|
||||
printer.Printf("requiring: %s\n", file)
|
||||
data, err := ioutil.ReadFile(file)
|
||||
data, err := os.ReadFile(file)
|
||||
if err != nil {
|
||||
throw(call.Otto, err.Error())
|
||||
}
|
||||
|
|
|
@ -11,7 +11,6 @@ data we output models.RecordConfig objects.
|
|||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"reflect"
|
||||
"strconv"
|
||||
|
||||
|
@ -25,7 +24,7 @@ func ReadYaml(r io.Reader, origin string) (models.Records, error) {
|
|||
results := models.Records{}
|
||||
|
||||
// Slurp the YAML into a string.
|
||||
ydata, err := ioutil.ReadAll(r)
|
||||
ydata, err := io.ReadAll(r)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("can not read yaml filehandle: %w", err)
|
||||
}
|
||||
|
|
|
@ -15,7 +15,6 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
@ -39,7 +38,7 @@ func TestYamlWrite(t *testing.T) {
|
|||
|
||||
// Read a .JS and make sure we can generate the expected YAML.
|
||||
|
||||
files, err := ioutil.ReadDir(testDir)
|
||||
files, err := os.ReadDir(testDir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -58,7 +57,7 @@ func TestYamlWrite(t *testing.T) {
|
|||
t.Run(f.Name(), func(t *testing.T) {
|
||||
fname := filepath.Join(testDir, f.Name())
|
||||
fmt.Printf("Filename: %v\n", fname)
|
||||
content, err := ioutil.ReadFile(fname)
|
||||
content, err := os.ReadFile(fname)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -84,7 +83,7 @@ func TestYamlWrite(t *testing.T) {
|
|||
// Read expected YAML
|
||||
|
||||
expectedFile := filepath.Join(testDir, basename+".yaml")
|
||||
expectedData, err := ioutil.ReadFile(expectedFile)
|
||||
expectedData, err := os.ReadFile(expectedFile)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -108,7 +107,7 @@ func TestYamlRead(t *testing.T) {
|
|||
|
||||
minifyFlag := true
|
||||
|
||||
files, err := ioutil.ReadDir(testDir)
|
||||
files, err := os.ReadDir(testDir)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -126,7 +125,7 @@ func TestYamlRead(t *testing.T) {
|
|||
|
||||
// Parse YAML
|
||||
|
||||
content, err := ioutil.ReadFile(filepath.Join(testDir, f.Name()))
|
||||
content, err := os.ReadFile(filepath.Join(testDir, f.Name()))
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
content = nil
|
||||
|
@ -158,7 +157,7 @@ func TestYamlRead(t *testing.T) {
|
|||
|
||||
// Read expected JSON
|
||||
expectedFile := filepath.Join(testDir, basename+".json")
|
||||
expectedData, err := ioutil.ReadFile(expectedFile)
|
||||
expectedData, err := os.ReadFile(expectedFile)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
fmt.Println("SKIPPING")
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
)
|
||||
|
@ -189,7 +189,7 @@ func (api *packetframeProvider) get(endpoint string, target interface{}) error {
|
|||
}
|
||||
|
||||
func (api *packetframeProvider) handleErrors(resp *http.Response) error {
|
||||
body, err := ioutil.ReadAll(resp.Body)
|
||||
body, err := io.ReadAll(resp.Body)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -6,15 +6,16 @@ package rwth
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/StackExchange/dnscontrol/v3/models"
|
||||
"github.com/StackExchange/dnscontrol/v3/pkg/printer"
|
||||
"github.com/miekg/dns"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/StackExchange/dnscontrol/v3/models"
|
||||
"github.com/StackExchange/dnscontrol/v3/pkg/printer"
|
||||
"github.com/miekg/dns"
|
||||
)
|
||||
|
||||
const (
|
||||
|
@ -188,7 +189,7 @@ func (api *rwthProvider) request(endpoint string, method string, request url.Val
|
|||
|
||||
defer cleanupResponseBody()
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
data, _ := ioutil.ReadAll(resp.Body)
|
||||
data, _ := io.ReadAll(resp.Body)
|
||||
printer.Printf(string(data))
|
||||
return fmt.Errorf("bad status code from RWTH: %d not 200", resp.StatusCode)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue