resolve ioutil deprecations
This commit is contained in:
parent
ce8b7f01ef
commit
82f7cbcc92
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"sort"
|
||||||
)
|
)
|
||||||
@ -23,7 +22,7 @@ func read(path string) (ba []byte, err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
defer r.Close()
|
defer r.Close()
|
||||||
return ioutil.ReadAll(r)
|
return io.ReadAll(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
err = fmt.Errorf("%s: %w", path, os.ErrNotExist)
|
err = fmt.Errorf("%s: %w", path, os.ErrNotExist)
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"flag"
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -18,7 +17,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func buildBootImg(out io.Writer, ctx *renderContext) (err error) {
|
func buildBootImg(out io.Writer, ctx *renderContext) (err error) {
|
||||||
bootImg, err := ioutil.TempFile(os.TempDir(), "boot.img-")
|
bootImg, err := os.CreateTemp(os.TempDir(), "boot.img-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -30,7 +29,7 @@ func buildBootImg(out io.Writer, ctx *renderContext) (err error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// send the result
|
// send the result
|
||||||
bootImg.Seek(0, os.SEEK_SET)
|
bootImg.Seek(0, io.SeekStart)
|
||||||
io.Copy(out, bootImg)
|
io.Copy(out, bootImg)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
@ -14,7 +13,7 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func buildBootISO(out io.Writer, ctx *renderContext) (err error) {
|
func buildBootISO(out io.Writer, ctx *renderContext) (err error) {
|
||||||
tempDir, err := ioutil.TempDir("/tmp", "iso-v2-")
|
tempDir, err := os.MkdirTemp("/tmp", "iso-v2-")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -70,7 +69,7 @@ func buildBootISO(out io.Writer, ctx *renderContext) (err error) {
|
|||||||
f.Write([]byte("direktil marker file\n"))
|
f.Write([]byte("direktil marker file\n"))
|
||||||
f.Close()
|
f.Close()
|
||||||
|
|
||||||
err = ioutil.WriteFile(filepath.Join(tempDir, "grub", "grub.cfg"), []byte(`
|
err = os.WriteFile(filepath.Join(tempDir, "grub", "grub.cfg"), []byte(`
|
||||||
search --set=root --file /`+tag+`
|
search --set=root --file /`+tag+`
|
||||||
|
|
||||||
insmod all_video
|
insmod all_video
|
||||||
@ -113,7 +112,7 @@ menuentry "Direktil" {
|
|||||||
|
|
||||||
defer out.Close()
|
defer out.Close()
|
||||||
|
|
||||||
b, err := ioutil.ReadFile("/usr/lib/grub/i386-pc/cdboot.img")
|
b, err := os.ReadFile("/usr/lib/grub/i386-pc/cdboot.img")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@ -122,7 +121,7 @@ menuentry "Direktil" {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err = ioutil.ReadFile(coreImgPath)
|
b, err = os.ReadFile(coreImgPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"archive/tar"
|
"archive/tar"
|
||||||
"bytes"
|
"bytes"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
@ -37,7 +36,7 @@ func buildBootTar(out io.Writer, ctx *renderContext) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
kernelBytes, err := ioutil.ReadFile(kernelPath)
|
kernelBytes, err := os.ReadFile(kernelPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -98,7 +97,7 @@ func buildBootEFITar(out io.Writer, ctx *renderContext) (err error) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
kernelBytes, err := ioutil.ReadFile(kernelPath)
|
kernelBytes, err := os.ReadFile(kernelPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"time"
|
"time"
|
||||||
@ -43,7 +42,7 @@ func loadSecretData(config *config.Config) (sd *SecretData, err error) {
|
|||||||
config: config,
|
config: config,
|
||||||
}
|
}
|
||||||
|
|
||||||
ba, err := ioutil.ReadFile(secretDataPath())
|
ba, err := os.ReadFile(secretDataPath())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
err = nil
|
err = nil
|
||||||
|
@ -10,7 +10,6 @@ import (
|
|||||||
"crypto/x509"
|
"crypto/x509"
|
||||||
"encoding/asn1"
|
"encoding/asn1"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
)
|
)
|
||||||
@ -42,7 +41,7 @@ genLoop:
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = func() (err error) {
|
err = func() (err error) {
|
||||||
outFile, err := ioutil.TempFile("/tmp", "dls-key.")
|
outFile, err := os.CreateTemp("/tmp", "dls-key.")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -70,12 +69,12 @@ genLoop:
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
privKey, err = ioutil.ReadFile(outPath)
|
privKey, err = os.ReadFile(outPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
pubKey, err = ioutil.ReadFile(outPath + ".pub")
|
pubKey, err = os.ReadFile(outPath + ".pub")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ package main
|
|||||||
import (
|
import (
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
@ -25,7 +24,7 @@ func wsUploadConfig(req *restful.Request, resp *restful.Response) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func writeNewConfig(reader io.Reader) (err error) {
|
func writeNewConfig(reader io.Reader) (err error) {
|
||||||
out, err := ioutil.TempFile(*dataDir, ".config-upload")
|
out, err := os.CreateTemp(*dataDir, ".config-upload")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user