mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-26 13:47:40 +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
@@ -63,7 +63,7 @@ jobs:
|
|||||||
- name: golangci-lint
|
- name: golangci-lint
|
||||||
uses: golangci/golangci-lint-action@v3
|
uses: golangci/golangci-lint-action@v3
|
||||||
with:
|
with:
|
||||||
version: v1.45.0
|
version: v1.50.1
|
||||||
|
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
|
|||||||
@@ -5,7 +5,6 @@ run:
|
|||||||
linters:
|
linters:
|
||||||
disable-all: true
|
disable-all: true
|
||||||
enable:
|
enable:
|
||||||
- deadcode
|
|
||||||
- goconst
|
- goconst
|
||||||
- gofmt
|
- gofmt
|
||||||
- goimports
|
- goimports
|
||||||
@@ -14,6 +13,4 @@ linters:
|
|||||||
- misspell
|
- misspell
|
||||||
- revive
|
- revive
|
||||||
- staticcheck
|
- staticcheck
|
||||||
- structcheck
|
|
||||||
- varcheck
|
|
||||||
- vetshadow
|
- vetshadow
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ COVERAGE_DIR?=$(shell mktemp -d)
|
|||||||
all: modules test bench check system-test
|
all: modules test bench check system-test
|
||||||
|
|
||||||
prepare:
|
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:
|
modules:
|
||||||
go mod download
|
go mod download
|
||||||
|
|||||||
+1
-2
@@ -3,7 +3,6 @@ package api
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
"os"
|
"os"
|
||||||
@@ -31,7 +30,7 @@ type ApiSuite struct {
|
|||||||
var _ = Suite(&ApiSuite{})
|
var _ = Suite(&ApiSuite{})
|
||||||
|
|
||||||
func createTestConfig() *os.File {
|
func createTestConfig() *os.File {
|
||||||
file, err := ioutil.TempFile("", "aptly")
|
file, err := os.CreateTemp("", "aptly")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -2,7 +2,6 @@ package api
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -37,7 +36,7 @@ func apiGPGAddKey(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
if len(b.GpgKeyArmor) > 0 {
|
if len(b.GpgKeyArmor) > 0 {
|
||||||
var tempdir string
|
var tempdir string
|
||||||
tempdir, err = ioutil.TempDir(os.TempDir(), "aptly")
|
tempdir, err = os.MkdirTemp(os.TempDir(), "aptly")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
c.AbortWithError(400, err)
|
c.AbortWithError(400, err)
|
||||||
return
|
return
|
||||||
|
|||||||
+1
-2
@@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -36,7 +35,7 @@ func aptlyGraph(cmd *commander.Command, args []string) error {
|
|||||||
|
|
||||||
buf := bytes.NewBufferString(graph.String())
|
buf := bytes.NewBufferString(graph.String())
|
||||||
|
|
||||||
tempfile, err := ioutil.TempFile("", "aptly-graph")
|
tempfile, err := os.CreateTemp("", "aptly-graph")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package goleveldb
|
|||||||
import (
|
import (
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"github.com/syndtr/goleveldb/leveldb"
|
"github.com/syndtr/goleveldb/leveldb"
|
||||||
@@ -19,7 +18,7 @@ type storage struct {
|
|||||||
|
|
||||||
// CreateTemporary creates new DB of the same type in temp dir
|
// CreateTemporary creates new DB of the same type in temp dir
|
||||||
func (s *storage) CreateTemporary() (database.Storage, error) {
|
func (s *storage) CreateTemporary() (database.Storage, error) {
|
||||||
tempdir, err := ioutil.TempDir("", "aptly")
|
tempdir, err := os.MkdirTemp("", "aptly")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -39,7 +38,7 @@ func NewChanges(path string) (*Changes, error) {
|
|||||||
ChangesName: filepath.Base(path),
|
ChangesName: filepath.Base(path),
|
||||||
}
|
}
|
||||||
|
|
||||||
c.TempDir, err = ioutil.TempDir(os.TempDir(), "aptly")
|
c.TempDir, err = os.MkdirTemp(os.TempDir(), "aptly")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -136,7 +136,7 @@ func isMultilineField(field string, isRelease bool) bool {
|
|||||||
|
|
||||||
// Write single field from Stanza to writer.
|
// Write single field from Stanza to writer.
|
||||||
//
|
//
|
||||||
//nolint: interfacer
|
// nolint: interfacer
|
||||||
func writeField(w *bufio.Writer, field, value string, isRelease bool) (err error) {
|
func writeField(w *bufio.Writer, field, value string, isRelease bool) (err error) {
|
||||||
if !isMultilineField(field, isRelease) {
|
if !isMultilineField(field, isRelease) {
|
||||||
_, err = w.WriteString(field + ": " + value + "\n")
|
_, err = w.WriteString(field + ": " + value + "\n")
|
||||||
|
|||||||
+1
-2
@@ -5,7 +5,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -596,7 +595,7 @@ func (p *PublishedRepo) Publish(packagePool aptly.PackagePool, publishedStorageP
|
|||||||
}
|
}
|
||||||
|
|
||||||
var tempDir string
|
var tempDir string
|
||||||
tempDir, err = ioutil.TempDir(os.TempDir(), "aptly")
|
tempDir, err = os.MkdirTemp(os.TempDir(), "aptly")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-2
@@ -3,7 +3,6 @@ package deb
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"sort"
|
"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) {
|
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)
|
io.Copy(text, clearsigned)
|
||||||
text.Seek(0, 0)
|
text.Seek(0, 0)
|
||||||
os.Remove(text.Name())
|
os.Remove(text.Name())
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package files
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sync"
|
"sync"
|
||||||
@@ -81,7 +80,7 @@ func (pool *PackagePool) FilepathList(progress aptly.Progress) ([]string, error)
|
|||||||
pool.Lock()
|
pool.Lock()
|
||||||
defer pool.Unlock()
|
defer pool.Unlock()
|
||||||
|
|
||||||
dirs, err := ioutil.ReadDir(pool.rootPath)
|
dirs, err := os.ReadDir(pool.rootPath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if os.IsNotExist(err) {
|
if os.IsNotExist(err) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
|||||||
@@ -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/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 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/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/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 h1:IG7i4p/mDa2Ce4TRyAO8IHnVhAVF3RFU+ZtXWSmf4Tg=
|
||||||
github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZmbF5NWuPV8+WeEW8=
|
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/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 h1:TcekIExNqud5crz4xD2pavyTgWiPvpYe4Xau31I0PRk=
|
||||||
github.com/form3tech-oss/jwt-go v3.2.2+incompatible/go.mod h1:pbq4aXjuKjdthFRnoDwaVPLA+WlJuPGy+QneDUgJi2k=
|
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/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 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||||
|
|||||||
+1
-2
@@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
@@ -56,7 +55,7 @@ func NewDownloader(downLimit int64, maxTries int, progress aptly.Progress) aptly
|
|||||||
|
|
||||||
progressWriter := io.Writer(progress)
|
progressWriter := io.Writer(progress)
|
||||||
if progress == nil {
|
if progress == nil {
|
||||||
progressWriter = ioutil.Discard
|
progressWriter = io.Discard
|
||||||
}
|
}
|
||||||
|
|
||||||
downloader.client.CheckRedirect = downloader.checkRedirect
|
downloader.client.CheckRedirect = downloader.checkRedirect
|
||||||
|
|||||||
@@ -3,7 +3,6 @@ package http
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -27,7 +26,7 @@ type DownloaderSuiteBase struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *DownloaderSuiteBase) SetUpTest(c *C) {
|
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.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)
|
s.url = fmt.Sprintf("http://localhost:%d", s.l.Addr().(*net.TCPAddr).Port)
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -3,7 +3,6 @@ package http
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"net"
|
"net"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
@@ -26,7 +25,7 @@ type GrabDownloaderSuiteBase struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *GrabDownloaderSuiteBase) SetUpTest(c *C) {
|
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.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)
|
s.url = fmt.Sprintf("http://localhost:%d", s.l.Addr().(*net.TCPAddr).Port)
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -2,7 +2,6 @@ package http
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"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
|
// 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) {
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-7
@@ -6,7 +6,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@@ -200,7 +199,7 @@ func (g *GpgVerifier) runGpgv(args []string, context string, showKeyTip bool) (*
|
|||||||
args = append([]string{"--status-fd", "3"}, args...)
|
args = append([]string{"--status-fd", "3"}, args...)
|
||||||
cmd := exec.Command(g.gpgv, args...)
|
cmd := exec.Command(g.gpgv, args...)
|
||||||
|
|
||||||
tempf, err := ioutil.TempFile("", "aptly-gpg-status")
|
tempf, err := os.CreateTemp("", "aptly-gpg-status")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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 {
|
func (g *GpgVerifier) VerifyDetachedSignature(signature, cleartext io.Reader, showKeyTip bool) error {
|
||||||
args := g.argsKeyrings()
|
args := g.argsKeyrings()
|
||||||
|
|
||||||
sigf, err := ioutil.TempFile("", "aptly-gpg")
|
sigf, err := os.CreateTemp("", "aptly-gpg")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
@@ -290,7 +289,7 @@ func (g *GpgVerifier) VerifyDetachedSignature(signature, cleartext io.Reader, sh
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
clearf, err := ioutil.TempFile("", "aptly-gpg")
|
clearf, err := os.CreateTemp("", "aptly-gpg")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
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) {
|
func (g *GpgVerifier) VerifyClearsigned(clearsigned io.Reader, showKeyTip bool) (*KeyInfo, error) {
|
||||||
args := g.argsKeyrings()
|
args := g.argsKeyrings()
|
||||||
|
|
||||||
clearf, err := ioutil.TempFile("", "aptly-gpg")
|
clearf, err := os.CreateTemp("", "aptly-gpg")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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
|
// ExtractClearsigned extracts cleartext from clearsigned file WITHOUT signature verification
|
||||||
func (g *GpgVerifier) ExtractClearsigned(clearsigned io.Reader) (text *os.File, err error) {
|
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 {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -353,7 +352,7 @@ func (g *GpgVerifier) ExtractClearsigned(clearsigned io.Reader) (text *os.File,
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
text, err = ioutil.TempFile("", "aptly-gpg")
|
text, err = os.CreateTemp("", "aptly-gpg")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-6
@@ -4,7 +4,6 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"sort"
|
"sort"
|
||||||
@@ -83,7 +82,7 @@ func (g *GoSigner) Init() error {
|
|||||||
}
|
}
|
||||||
defer passF.Close()
|
defer passF.Close()
|
||||||
|
|
||||||
contents, err := ioutil.ReadAll(passF)
|
contents, err := io.ReadAll(passF)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return errors.Wrap(err, "error reading passphrase file")
|
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
|
// IsClearSigned returns true if file contains signature
|
||||||
func (g *GoVerifier) IsClearSigned(clearsigned io.Reader) (bool, error) {
|
func (g *GoVerifier) IsClearSigned(clearsigned io.Reader) (bool, error) {
|
||||||
signedBuffer, err := ioutil.ReadAll(clearsigned)
|
signedBuffer, err := io.ReadAll(clearsigned)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, errors.Wrap(err, "failed to read clearsigned data")
|
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
|
// VerifyClearsigned verifies clearsigned file using gpgv
|
||||||
func (g *GoVerifier) VerifyClearsigned(clearsigned io.Reader, showKeyTip bool) (*KeyInfo, error) {
|
func (g *GoVerifier) VerifyClearsigned(clearsigned io.Reader, showKeyTip bool) (*KeyInfo, error) {
|
||||||
signedBuffer, err := ioutil.ReadAll(clearsigned)
|
signedBuffer, err := io.ReadAll(clearsigned)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to read clearsigned data")
|
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
|
// ExtractClearsigned extracts cleartext from clearsigned file WITHOUT signature verification
|
||||||
func (g *GoVerifier) ExtractClearsigned(clearsigned io.Reader) (text *os.File, err error) {
|
func (g *GoVerifier) ExtractClearsigned(clearsigned io.Reader) (text *os.File, err error) {
|
||||||
var signedBuffer []byte
|
var signedBuffer []byte
|
||||||
signedBuffer, err = ioutil.ReadAll(clearsigned)
|
signedBuffer, err = io.ReadAll(clearsigned)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrap(err, "failed to read clearsigned data")
|
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")
|
return nil, errors.New("no clearsigned data found")
|
||||||
}
|
}
|
||||||
|
|
||||||
text, err = ioutil.TempFile("", "aptly-gpg")
|
text, err = os.CreateTemp("", "aptly-gpg")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
. "gopkg.in/check.v1"
|
. "gopkg.in/check.v1"
|
||||||
@@ -14,7 +13,7 @@ type ChecksumSuite struct {
|
|||||||
var _ = Suite(&ChecksumSuite{})
|
var _ = Suite(&ChecksumSuite{})
|
||||||
|
|
||||||
func (s *ChecksumSuite) SetUpTest(c *C) {
|
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)
|
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?"
|
const testString = "Quick brown fox jumps over black dog and runs away... Really far away... who knows?"
|
||||||
|
|
||||||
func (s *CompressSuite) SetUpTest(c *C) {
|
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)
|
s.tempfile.WriteString(testString)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package utils
|
package utils
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"io/ioutil"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
@@ -16,7 +15,7 @@ type CopyfileSuite struct {
|
|||||||
var _ = Suite(&CopyfileSuite{})
|
var _ = Suite(&CopyfileSuite{})
|
||||||
|
|
||||||
func (s *CopyfileSuite) SetUpSuite(c *C) {
|
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")
|
s.dest = filepath.Join(filepath.Dir(s.source.Name()), "destination-file")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -2,7 +2,6 @@ package utils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/ioutil"
|
|
||||||
"log"
|
"log"
|
||||||
"os"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
@@ -22,7 +21,7 @@ type UtilsSuite struct {
|
|||||||
var _ = Suite(&UtilsSuite{})
|
var _ = Suite(&UtilsSuite{})
|
||||||
|
|
||||||
func (s *UtilsSuite) SetUpSuite(c *C) {
|
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 {
|
if err := os.Chmod(s.tempfile.Name(), 0000); err != nil {
|
||||||
log.Fatalln(err)
|
log.Fatalln(err)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user