mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-05-30 04:20:53 +00:00
Revert "go1.24: fix lint, unit and system tests"
This reverts commit f7057a9517.
# Conflicts:
# api/api.go
# api/files.go
# api/repos.go
# database/etcddb/database_test.go
# deb/remote_test.go
# deb/snapshot_bench_test.go
# deb/version.go
# files/package_pool.go
# files/public_test.go
# http/download.go
# http/grab.go
# s3/server_test.go
This commit is contained in:
@@ -29,7 +29,7 @@ func NewPackagePool(accountName, accountKey, container, prefix, endpoint string)
|
|||||||
return &PackagePool{az: azctx}, nil
|
return &PackagePool{az: azctx}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns the storage as string
|
// String
|
||||||
func (pool *PackagePool) String() string {
|
func (pool *PackagePool) String() string {
|
||||||
return pool.az.String()
|
return pool.az.String()
|
||||||
}
|
}
|
||||||
@@ -104,7 +104,7 @@ func (pool *PackagePool) Open(path string) (aptly.ReadSeekerCloser, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errors.Wrapf(err, "error creating tempfile for %s", path)
|
return nil, errors.Wrapf(err, "error creating tempfile for %s", path)
|
||||||
}
|
}
|
||||||
defer func () { _ = os.Remove(temp.Name()) }()
|
defer os.Remove(temp.Name())
|
||||||
|
|
||||||
_, err = pool.az.client.DownloadFile(context.TODO(), pool.az.container, path, temp, nil)
|
_, err = pool.az.client.DownloadFile(context.TODO(), pool.az.container, path, temp, nil)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -156,7 +156,7 @@ func (pool *PackagePool) Import(srcPath, basename string, checksums *utils.Check
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
defer func() { _ = source.Close() }()
|
defer source.Close()
|
||||||
|
|
||||||
err = pool.az.putFile(path, source, checksums.MD5)
|
err = pool.az.putFile(path, source, checksums.MD5)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package azure
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"io"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -69,8 +69,8 @@ func (s *PackagePoolSuite) TestFilepathList(c *C) {
|
|||||||
c.Check(err, IsNil)
|
c.Check(err, IsNil)
|
||||||
c.Check(list, DeepEquals, []string{})
|
c.Check(list, DeepEquals, []string{})
|
||||||
|
|
||||||
_, _ = s.pool.Import(s.debFile, "a.deb", &utils.ChecksumInfo{}, false, s.cs)
|
s.pool.Import(s.debFile, "a.deb", &utils.ChecksumInfo{}, false, s.cs)
|
||||||
_, _ = s.pool.Import(s.debFile, "b.deb", &utils.ChecksumInfo{}, false, s.cs)
|
s.pool.Import(s.debFile, "b.deb", &utils.ChecksumInfo{}, false, s.cs)
|
||||||
|
|
||||||
list, err = s.pool.FilepathList(nil)
|
list, err = s.pool.FilepathList(nil)
|
||||||
c.Check(err, IsNil)
|
c.Check(err, IsNil)
|
||||||
@@ -81,8 +81,8 @@ func (s *PackagePoolSuite) TestFilepathList(c *C) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *PackagePoolSuite) TestRemove(c *C) {
|
func (s *PackagePoolSuite) TestRemove(c *C) {
|
||||||
_, _ = s.pool.Import(s.debFile, "a.deb", &utils.ChecksumInfo{}, false, s.cs)
|
s.pool.Import(s.debFile, "a.deb", &utils.ChecksumInfo{}, false, s.cs)
|
||||||
_, _ = s.pool.Import(s.debFile, "b.deb", &utils.ChecksumInfo{}, false, s.cs)
|
s.pool.Import(s.debFile, "b.deb", &utils.ChecksumInfo{}, false, s.cs)
|
||||||
|
|
||||||
size, err := s.pool.Remove("c7/6b/4bd12fd92e4dfe1b55b18a67a669_a.deb")
|
size, err := s.pool.Remove("c7/6b/4bd12fd92e4dfe1b55b18a67a669_a.deb")
|
||||||
c.Check(err, IsNil)
|
c.Check(err, IsNil)
|
||||||
@@ -247,7 +247,7 @@ func (s *PackagePoolSuite) TestOpen(c *C) {
|
|||||||
|
|
||||||
f, err := s.pool.Open(path)
|
f, err := s.pool.Open(path)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
contents, err := io.ReadAll(f)
|
contents, err := ioutil.ReadAll(f)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
c.Check(len(contents), Equals, 2738)
|
c.Check(len(contents), Equals, 2738)
|
||||||
c.Check(f.Close(), IsNil)
|
c.Check(f.Close(), IsNil)
|
||||||
|
|||||||
+5
-7
@@ -18,7 +18,7 @@ import (
|
|||||||
|
|
||||||
// PublishedStorage abstract file system with published files (actually hosted on Azure)
|
// PublishedStorage abstract file system with published files (actually hosted on Azure)
|
||||||
type PublishedStorage struct {
|
type PublishedStorage struct {
|
||||||
// FIXME: unused ???? prefix string
|
prefix string
|
||||||
az *azContext
|
az *azContext
|
||||||
pathCache map[string]map[string]string
|
pathCache map[string]map[string]string
|
||||||
}
|
}
|
||||||
@@ -38,7 +38,7 @@ func NewPublishedStorage(accountName, accountKey, container, prefix, endpoint st
|
|||||||
return &PublishedStorage{az: azctx}, nil
|
return &PublishedStorage{az: azctx}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// String returns the storage as string
|
// String
|
||||||
func (storage *PublishedStorage) String() string {
|
func (storage *PublishedStorage) String() string {
|
||||||
return storage.az.String()
|
return storage.az.String()
|
||||||
}
|
}
|
||||||
@@ -65,7 +65,7 @@ func (storage *PublishedStorage) PutFile(path string, sourceFilename string) err
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer func() { _ = source.Close() }()
|
defer source.Close()
|
||||||
|
|
||||||
err = storage.az.putFile(path, source, sourceMD5)
|
err = storage.az.putFile(path, source, sourceMD5)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -158,7 +158,7 @@ func (storage *PublishedStorage) LinkFromPool(publishedPrefix, publishedRelPath,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer func() { _ = source.Close() }()
|
defer source.Close()
|
||||||
|
|
||||||
err = storage.az.putFile(relFilePath, source, sourceMD5)
|
err = storage.az.putFile(relFilePath, source, sourceMD5)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
@@ -193,9 +193,7 @@ func (storage *PublishedStorage) internalCopyOrMoveBlob(src, dst string, metadat
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("error acquiring lease on source blob %s", src)
|
return fmt.Errorf("error acquiring lease on source blob %s", src)
|
||||||
}
|
}
|
||||||
defer func() {
|
defer blobLeaseClient.BreakLease(context.Background(), &lease.BlobBreakOptions{BreakPeriod: to.Ptr(int32(60))})
|
||||||
_, _ = blobLeaseClient.BreakLease(context.Background(), &lease.BlobBreakOptions{BreakPeriod: to.Ptr(int32(60))})
|
|
||||||
}()
|
|
||||||
|
|
||||||
dstBlobClient := containerClient.NewBlobClient(dst)
|
dstBlobClient := containerClient.NewBlobClient(dst)
|
||||||
copyResp, err := dstBlobClient.StartCopyFromURL(context.Background(), srcBlobClient.URL(), &blob.StartCopyFromURLOptions{
|
copyResp, err := dstBlobClient.StartCopyFromURL(context.Background(), srcBlobClient.URL(), &blob.StartCopyFromURLOptions{
|
||||||
|
|||||||
+10
-10
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"io"
|
"io/ioutil"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"bytes"
|
"bytes"
|
||||||
@@ -36,7 +36,7 @@ func randString(n int) string {
|
|||||||
}
|
}
|
||||||
const alphanum = "0123456789abcdefghijklmnopqrstuvwxyz"
|
const alphanum = "0123456789abcdefghijklmnopqrstuvwxyz"
|
||||||
var bytes = make([]byte, n)
|
var bytes = make([]byte, n)
|
||||||
_, _ = rand.Read(bytes)
|
rand.Read(bytes)
|
||||||
for i, b := range bytes {
|
for i, b := range bytes {
|
||||||
bytes[i] = alphanum[b%byte(len(alphanum))]
|
bytes[i] = alphanum[b%byte(len(alphanum))]
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ func (s *PublishedStorageSuite) TearDownTest(c *C) {
|
|||||||
func (s *PublishedStorageSuite) GetFile(c *C, path string) []byte {
|
func (s *PublishedStorageSuite) GetFile(c *C, path string) []byte {
|
||||||
resp, err := s.storage.az.client.DownloadStream(context.Background(), s.storage.az.container, path, nil)
|
resp, err := s.storage.az.client.DownloadStream(context.Background(), s.storage.az.container, path, nil)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
data, err := io.ReadAll(resp.Body)
|
data, err := ioutil.ReadAll(resp.Body)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
return data
|
return data
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ func (s *PublishedStorageSuite) TestPutFile(c *C) {
|
|||||||
filename := "a/b.txt"
|
filename := "a/b.txt"
|
||||||
|
|
||||||
dir := c.MkDir()
|
dir := c.MkDir()
|
||||||
err := os.WriteFile(filepath.Join(dir, "a"), content, 0644)
|
err := ioutil.WriteFile(filepath.Join(dir, "a"), content, 0644)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
err = s.storage.PutFile(filename, filepath.Join(dir, "a"))
|
err = s.storage.PutFile(filename, filepath.Join(dir, "a"))
|
||||||
@@ -140,7 +140,7 @@ func (s *PublishedStorageSuite) TestPutFilePlus(c *C) {
|
|||||||
filename := "a/b+c.txt"
|
filename := "a/b+c.txt"
|
||||||
|
|
||||||
dir := c.MkDir()
|
dir := c.MkDir()
|
||||||
err := os.WriteFile(filepath.Join(dir, "a"), content, 0644)
|
err := ioutil.WriteFile(filepath.Join(dir, "a"), content, 0644)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
err = s.storage.PutFile(filename, filepath.Join(dir, "a"))
|
err = s.storage.PutFile(filename, filepath.Join(dir, "a"))
|
||||||
@@ -258,7 +258,7 @@ func (s *PublishedStorageSuite) TestRemoveDirsPlus(c *C) {
|
|||||||
|
|
||||||
func (s *PublishedStorageSuite) TestRenameFile(c *C) {
|
func (s *PublishedStorageSuite) TestRenameFile(c *C) {
|
||||||
dir := c.MkDir()
|
dir := c.MkDir()
|
||||||
err := os.WriteFile(filepath.Join(dir, "a"), []byte("Welcome to Azure!"), 0644)
|
err := ioutil.WriteFile(filepath.Join(dir, "a"), []byte("Welcome to Azure!"), 0644)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
err = s.storage.PutFile("source.txt", filepath.Join(dir, "a"))
|
err = s.storage.PutFile("source.txt", filepath.Join(dir, "a"))
|
||||||
@@ -280,18 +280,18 @@ func (s *PublishedStorageSuite) TestLinkFromPool(c *C) {
|
|||||||
cs := files.NewMockChecksumStorage()
|
cs := files.NewMockChecksumStorage()
|
||||||
|
|
||||||
tmpFile1 := filepath.Join(c.MkDir(), "mars-invaders_1.03.deb")
|
tmpFile1 := filepath.Join(c.MkDir(), "mars-invaders_1.03.deb")
|
||||||
err := os.WriteFile(tmpFile1, []byte("Contents"), 0644)
|
err := ioutil.WriteFile(tmpFile1, []byte("Contents"), 0644)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
cksum1 := utils.ChecksumInfo{MD5: "c1df1da7a1ce305a3b60af9d5733ac1d"}
|
cksum1 := utils.ChecksumInfo{MD5: "c1df1da7a1ce305a3b60af9d5733ac1d"}
|
||||||
|
|
||||||
tmpFile2 := filepath.Join(c.MkDir(), "mars-invaders_1.03.deb")
|
tmpFile2 := filepath.Join(c.MkDir(), "mars-invaders_1.03.deb")
|
||||||
err = os.WriteFile(tmpFile2, []byte("Spam"), 0644)
|
err = ioutil.WriteFile(tmpFile2, []byte("Spam"), 0644)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
cksum2 := utils.ChecksumInfo{MD5: "e9dfd31cc505d51fc26975250750deab"}
|
cksum2 := utils.ChecksumInfo{MD5: "e9dfd31cc505d51fc26975250750deab"}
|
||||||
|
|
||||||
tmpFile3 := filepath.Join(c.MkDir(), "netboot/boot.img.gz")
|
tmpFile3 := filepath.Join(c.MkDir(), "netboot/boot.img.gz")
|
||||||
_ = os.MkdirAll(filepath.Dir(tmpFile3), 0777)
|
os.MkdirAll(filepath.Dir(tmpFile3), 0777)
|
||||||
err = os.WriteFile(tmpFile3, []byte("Contents"), 0644)
|
err = ioutil.WriteFile(tmpFile3, []byte("Contents"), 0644)
|
||||||
c.Assert(err, IsNil)
|
c.Assert(err, IsNil)
|
||||||
cksum3 := utils.ChecksumInfo{MD5: "c1df1da7a1ce305a3b60af9d5733ac1d"}
|
cksum3 := utils.ChecksumInfo{MD5: "c1df1da7a1ce305a3b60af9d5733ac1d"}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user