mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-01-11 03:11:50 +00:00
update golangci-lint and replace deprecated calls to io/ioutil
This commit is contained in:
committed by
Benj Fassbind
parent
71fd730598
commit
352f4e8772
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -63,7 +63,7 @@ jobs:
|
||||
- name: golangci-lint
|
||||
uses: golangci/golangci-lint-action@v3
|
||||
with:
|
||||
version: v1.45.0
|
||||
version: v1.50.1
|
||||
|
||||
- name: Setup Python
|
||||
uses: actions/setup-python@v2
|
||||
|
||||
@@ -5,7 +5,6 @@ run:
|
||||
linters:
|
||||
disable-all: true
|
||||
enable:
|
||||
- deadcode
|
||||
- goconst
|
||||
- gofmt
|
||||
- goimports
|
||||
@@ -14,6 +13,4 @@ linters:
|
||||
- misspell
|
||||
- revive
|
||||
- staticcheck
|
||||
- structcheck
|
||||
- varcheck
|
||||
- vetshadow
|
||||
|
||||
2
Makefile
2
Makefile
@@ -11,7 +11,7 @@ COVERAGE_DIR?=$(shell mktemp -d)
|
||||
all: modules test bench check system-test
|
||||
|
||||
prepare:
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.45.0
|
||||
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(shell go env GOPATH)/bin v1.50.1
|
||||
|
||||
modules:
|
||||
go mod download
|
||||
|
||||
@@ -3,7 +3,6 @@ package api
|
||||
import (
|
||||
"encoding/json"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"os"
|
||||
@@ -31,7 +30,7 @@ type ApiSuite struct {
|
||||
var _ = Suite(&ApiSuite{})
|
||||
|
||||
func createTestConfig() *os.File {
|
||||
file, err := ioutil.TempFile("", "aptly")
|
||||
file, err := os.CreateTemp("", "aptly")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package api
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -37,7 +36,7 @@ func apiGPGAddKey(c *gin.Context) {
|
||||
}
|
||||
if len(b.GpgKeyArmor) > 0 {
|
||||
var tempdir string
|
||||
tempdir, err = ioutil.TempDir(os.TempDir(), "aptly")
|
||||
tempdir, err = os.MkdirTemp(os.TempDir(), "aptly")
|
||||
if err != nil {
|
||||
c.AbortWithError(400, err)
|
||||
return
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -36,7 +35,7 @@ func aptlyGraph(cmd *commander.Command, args []string) error {
|
||||
|
||||
buf := bytes.NewBufferString(graph.String())
|
||||
|
||||
tempfile, err := ioutil.TempFile("", "aptly-graph")
|
||||
tempfile, err := os.CreateTemp("", "aptly-graph")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package goleveldb
|
||||
import (
|
||||
"bytes"
|
||||
"errors"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/syndtr/goleveldb/leveldb"
|
||||
@@ -19,7 +18,7 @@ type storage struct {
|
||||
|
||||
// CreateTemporary creates new DB of the same type in temp dir
|
||||
func (s *storage) CreateTemporary() (database.Storage, error) {
|
||||
tempdir, err := ioutil.TempDir("", "aptly")
|
||||
tempdir, err := os.MkdirTemp("", "aptly")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
@@ -39,7 +38,7 @@ func NewChanges(path string) (*Changes, error) {
|
||||
ChangesName: filepath.Base(path),
|
||||
}
|
||||
|
||||
c.TempDir, err = ioutil.TempDir(os.TempDir(), "aptly")
|
||||
c.TempDir, err = os.MkdirTemp(os.TempDir(), "aptly")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
@@ -136,7 +136,7 @@ func isMultilineField(field string, isRelease bool) bool {
|
||||
|
||||
// Write single field from Stanza to writer.
|
||||
//
|
||||
//nolint: interfacer
|
||||
// nolint: interfacer
|
||||
func writeField(w *bufio.Writer, field, value string, isRelease bool) (err error) {
|
||||
if !isMultilineField(field, isRelease) {
|
||||
_, err = w.WriteString(field + ": " + value + "\n")
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"path/filepath"
|
||||
@@ -596,7 +595,7 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
|
||||
}
|
||||
|
||||
var tempDir string
|
||||
tempDir, err = ioutil.TempDir(os.TempDir(), "aptly")
|
||||
tempDir, err = os.MkdirTemp(os.TempDir(), "aptly")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package deb
|
||||
import (
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"sort"
|
||||
|
||||
@@ -38,7 +37,7 @@ func (n *NullVerifier) VerifyClearsigned(clearsigned io.Reader, hint bool) (*pgp
|
||||
}
|
||||
|
||||
func (n *NullVerifier) ExtractClearsigned(clearsigned io.Reader) (text *os.File, err error) {
|
||||
text, _ = ioutil.TempFile("", "aptly-test")
|
||||
text, _ = os.CreateTemp("", "aptly-test")
|
||||
io.Copy(text, clearsigned)
|
||||
text.Seek(0, 0)
|
||||
os.Remove(text.Name())
|
||||
|
||||
@@ -3,7 +3,6 @@ package files
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sync"
|
||||
@@ -81,7 +80,7 @@ func (pool *PackagePool) FilepathList(progress aptly.Progress) ([]string, error)
|
||||
pool.Lock()
|
||||
defer pool.Unlock()
|
||||
|
||||
dirs, err := ioutil.ReadDir(pool.rootPath)
|
||||
dirs, err := os.ReadDir(pool.rootPath)
|
||||
if err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
return nil, nil
|
||||
|
||||
2
go.sum
2
go.sum
@@ -43,7 +43,6 @@ github.com/Azure/go-autorest/autorest/adal v0.9.13 h1:Mp5hbtOePIzM8pJVRa3YLrWWmZ
|
||||
github.com/Azure/go-autorest/autorest/adal v0.9.13/go.mod h1:W/MM4U6nLxnIskrw4UwWzlHfGjwUS50aOsc/I3yuU8M=
|
||||
github.com/Azure/go-autorest/autorest/date v0.3.0 h1:7gUk1U5M/CQbp9WoqinNzJar+8KY+LPI6wiWrP/myHw=
|
||||
github.com/Azure/go-autorest/autorest/date v0.3.0/go.mod h1:BI0uouVdmngYNUzGWeSYnokU+TrmwEsOqdt8Y6sso74=
|
||||
github.com/Azure/go-autorest/autorest/mocks v0.4.1 h1:K0laFcLE6VLTOwNgSxaGbUcLPuGXlNkbVvq4cW4nIHk=
|
||||
github.com/Azure/go-autorest/autorest/mocks v0.4.1/go.mod h1:LTp+uSrOhSkaKrUy935gNZuuIPPVsHlr9DSOxSayd+k=
|
||||
github.com/Azure/go-autorest/logger v0.2.1 h1:IG7i4p/mDa2Ce4TRyAO8IHnVhAVF3RFU+ZtXWSmf4Tg=
|
||||
github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8=
|
||||
@@ -91,7 +90,6 @@ github.com/fatih/color v1.7.0 h1:DkWD4oS2D8LGGgTQ6IvwJJXSL5Vp2ffcQg58nFV38Ys=
|
||||
github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4=
|
||||
github.com/form3tech-oss/jwt-go v3.2.2+incompatible h1:TcekIExNqud5crz4xD2pavyTgWiPvpYe4Xau31I0PRk=
|
||||
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
|
||||
github.com/fsnotify/fsnotify v1.4.7 h1:IXs+QLmnXW2CcXuY+8Mzv/fWEsPGWxqefPtCP5CnV9I=
|
||||
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
|
||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"net/url"
|
||||
@@ -56,7 +55,7 @@ func NewDownloader(downLimit int64, maxTries int, progress aptly.Progress) aptly
|
||||
|
||||
progressWriter := io.Writer(progress)
|
||||
if progress == nil {
|
||||
progressWriter = ioutil.Discard
|
||||
progressWriter = io.Discard
|
||||
}
|
||||
|
||||
downloader.client.CheckRedirect = downloader.checkRedirect
|
||||
|
||||
@@ -3,7 +3,6 @@ package http
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -27,7 +26,7 @@ type DownloaderSuiteBase struct {
|
||||
}
|
||||
|
||||
func (s *DownloaderSuiteBase) SetUpTest(c *C) {
|
||||
s.tempfile, _ = ioutil.TempFile(os.TempDir(), "aptly-test")
|
||||
s.tempfile, _ = os.CreateTemp(os.TempDir(), "aptly-test")
|
||||
s.l, _ = net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1)})
|
||||
s.url = fmt.Sprintf("http://localhost:%d", s.l.Addr().(*net.TCPAddr).Port)
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package http
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net"
|
||||
"net/http"
|
||||
"os"
|
||||
@@ -26,7 +25,7 @@ type GrabDownloaderSuiteBase struct {
|
||||
}
|
||||
|
||||
func (s *GrabDownloaderSuiteBase) SetUpTest(c *C) {
|
||||
s.tempfile, _ = ioutil.TempFile(os.TempDir(), "aptly-test")
|
||||
s.tempfile, _ = os.CreateTemp(os.TempDir(), "aptly-test")
|
||||
s.l, _ = net.ListenTCP("tcp4", &net.TCPAddr{IP: net.IPv4(127, 0, 0, 1)})
|
||||
s.url = fmt.Sprintf("http://localhost:%d", s.l.Addr().(*net.TCPAddr).Port)
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package http
|
||||
|
||||
import (
|
||||
"context"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -21,7 +20,7 @@ func DownloadTemp(ctx context.Context, downloader aptly.Downloader, url string)
|
||||
//
|
||||
// Temporary file would be already removed, so no need to cleanup
|
||||
func DownloadTempWithChecksum(ctx context.Context, downloader aptly.Downloader, url string, expected *utils.ChecksumInfo, ignoreMismatch bool) (*os.File, error) {
|
||||
tempdir, err := ioutil.TempDir(os.TempDir(), "aptly")
|
||||
tempdir, err := os.MkdirTemp(os.TempDir(), "aptly")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
13
pgp/gnupg.go
13
pgp/gnupg.go
@@ -6,7 +6,6 @@ import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"os/exec"
|
||||
"path/filepath"
|
||||
@@ -200,7 +199,7 @@ func (g *GpgVerifier) runGpgv(args []string, context string, showKeyTip bool) (*
|
||||
args = append([]string{"--status-fd", "3"}, args...)
|
||||
cmd := exec.Command(g.gpgv, args...)
|
||||
|
||||
tempf, err := ioutil.TempFile("", "aptly-gpg-status")
|
||||
tempf, err := os.CreateTemp("", "aptly-gpg-status")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -278,7 +277,7 @@ func (g *GpgVerifier) runGpgv(args []string, context string, showKeyTip bool) (*
|
||||
func (g *GpgVerifier) VerifyDetachedSignature(signature, cleartext io.Reader, showKeyTip bool) error {
|
||||
args := g.argsKeyrings()
|
||||
|
||||
sigf, err := ioutil.TempFile("", "aptly-gpg")
|
||||
sigf, err := os.CreateTemp("", "aptly-gpg")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -290,7 +289,7 @@ func (g *GpgVerifier) VerifyDetachedSignature(signature, cleartext io.Reader, sh
|
||||
return err
|
||||
}
|
||||
|
||||
clearf, err := ioutil.TempFile("", "aptly-gpg")
|
||||
clearf, err := os.CreateTemp("", "aptly-gpg")
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
@@ -323,7 +322,7 @@ func (g *GpgVerifier) IsClearSigned(clearsigned io.Reader) (bool, error) {
|
||||
func (g *GpgVerifier) VerifyClearsigned(clearsigned io.Reader, showKeyTip bool) (*KeyInfo, error) {
|
||||
args := g.argsKeyrings()
|
||||
|
||||
clearf, err := ioutil.TempFile("", "aptly-gpg")
|
||||
clearf, err := os.CreateTemp("", "aptly-gpg")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -341,7 +340,7 @@ func (g *GpgVerifier) VerifyClearsigned(clearsigned io.Reader, showKeyTip bool)
|
||||
|
||||
// ExtractClearsigned extracts cleartext from clearsigned file WITHOUT signature verification
|
||||
func (g *GpgVerifier) ExtractClearsigned(clearsigned io.Reader) (text *os.File, err error) {
|
||||
clearf, err := ioutil.TempFile("", "aptly-gpg")
|
||||
clearf, err := os.CreateTemp("", "aptly-gpg")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
@@ -353,7 +352,7 @@ func (g *GpgVerifier) ExtractClearsigned(clearsigned io.Reader) (text *os.File,
|
||||
return
|
||||
}
|
||||
|
||||
text, err = ioutil.TempFile("", "aptly-gpg")
|
||||
text, err = os.CreateTemp("", "aptly-gpg")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
@@ -83,7 +82,7 @@ func (g *GoSigner) Init() error {
|
||||
}
|
||||
defer passF.Close()
|
||||
|
||||
contents, err := ioutil.ReadAll(passF)
|
||||
contents, err := io.ReadAll(passF)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error reading passphrase file")
|
||||
}
|
||||
@@ -400,7 +399,7 @@ func (g *GoVerifier) VerifyDetachedSignature(signature, cleartext io.Reader, sho
|
||||
|
||||
// IsClearSigned returns true if file contains signature
|
||||
func (g *GoVerifier) IsClearSigned(clearsigned io.Reader) (bool, error) {
|
||||
signedBuffer, err := ioutil.ReadAll(clearsigned)
|
||||
signedBuffer, err := io.ReadAll(clearsigned)
|
||||
if err != nil {
|
||||
return false, errors.Wrap(err, "failed to read clearsigned data")
|
||||
}
|
||||
@@ -412,7 +411,7 @@ func (g *GoVerifier) IsClearSigned(clearsigned io.Reader) (bool, error) {
|
||||
|
||||
// VerifyClearsigned verifies clearsigned file using gpgv
|
||||
func (g *GoVerifier) VerifyClearsigned(clearsigned io.Reader, showKeyTip bool) (*KeyInfo, error) {
|
||||
signedBuffer, err := ioutil.ReadAll(clearsigned)
|
||||
signedBuffer, err := io.ReadAll(clearsigned)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to read clearsigned data")
|
||||
}
|
||||
@@ -451,7 +450,7 @@ func (g *GoVerifier) VerifyClearsigned(clearsigned io.Reader, showKeyTip bool) (
|
||||
// ExtractClearsigned extracts cleartext from clearsigned file WITHOUT signature verification
|
||||
func (g *GoVerifier) ExtractClearsigned(clearsigned io.Reader) (text *os.File, err error) {
|
||||
var signedBuffer []byte
|
||||
signedBuffer, err = ioutil.ReadAll(clearsigned)
|
||||
signedBuffer, err = io.ReadAll(clearsigned)
|
||||
if err != nil {
|
||||
return nil, errors.Wrap(err, "failed to read clearsigned data")
|
||||
}
|
||||
@@ -461,7 +460,7 @@ func (g *GoVerifier) ExtractClearsigned(clearsigned io.Reader) (text *os.File, e
|
||||
return nil, errors.New("no clearsigned data found")
|
||||
}
|
||||
|
||||
text, err = ioutil.TempFile("", "aptly-gpg")
|
||||
text, err = os.CreateTemp("", "aptly-gpg")
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
. "gopkg.in/check.v1"
|
||||
@@ -14,7 +13,7 @@ type ChecksumSuite struct {
|
||||
var _ = Suite(&ChecksumSuite{})
|
||||
|
||||
func (s *ChecksumSuite) SetUpTest(c *C) {
|
||||
s.tempfile, _ = ioutil.TempFile(c.MkDir(), "aptly-test")
|
||||
s.tempfile, _ = os.CreateTemp(c.MkDir(), "aptly-test")
|
||||
s.tempfile.WriteString(testString)
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ var _ = Suite(&CompressSuite{})
|
||||
const testString = "Quick brown fox jumps over black dog and runs away... Really far away... who knows?"
|
||||
|
||||
func (s *CompressSuite) SetUpTest(c *C) {
|
||||
s.tempfile, _ = ioutil.TempFile(c.MkDir(), "aptly-test")
|
||||
s.tempfile, _ = os.CreateTemp(c.MkDir(), "aptly-test")
|
||||
s.tempfile.WriteString(testString)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
@@ -16,7 +15,7 @@ type CopyfileSuite struct {
|
||||
var _ = Suite(&CopyfileSuite{})
|
||||
|
||||
func (s *CopyfileSuite) SetUpSuite(c *C) {
|
||||
s.source, _ = ioutil.TempFile(c.MkDir(), "source-file")
|
||||
s.source, _ = os.CreateTemp(c.MkDir(), "source-file")
|
||||
s.dest = filepath.Join(filepath.Dir(s.source.Name()), "destination-file")
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package utils
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"os"
|
||||
"testing"
|
||||
@@ -22,7 +21,7 @@ type UtilsSuite struct {
|
||||
var _ = Suite(&UtilsSuite{})
|
||||
|
||||
func (s *UtilsSuite) SetUpSuite(c *C) {
|
||||
s.tempfile, _ = ioutil.TempFile(c.MkDir(), "aptly-test-inaccessible")
|
||||
s.tempfile, _ = os.CreateTemp(c.MkDir(), "aptly-test-inaccessible")
|
||||
if err := os.Chmod(s.tempfile.Name(), 0000); err != nil {
|
||||
log.Fatalln(err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user