mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-06-08 05:50:47 +00:00
Add support for Azure package pools
This adds support for storing packages directly on Azure, with no truly "local" (on-disk) repo used. The existing Azure PublishedStorage implementation was refactored to move the shared code to a separate context struct, which can then be re-used by the new PackagePool. In addition, the files package's mockChecksumStorage was made public so that it could be used in the Azure PackagePool tests as well. Signed-off-by: Ryan Gonzalez <ryan.gonzalez@collabora.com>
This commit is contained in:
committed by
André Roth
parent
810df17009
commit
f9325fbc91
+9
-9
@@ -5,19 +5,19 @@ import (
|
||||
"github.com/aptly-dev/aptly/utils"
|
||||
)
|
||||
|
||||
type mockChecksumStorage struct {
|
||||
store map[string]utils.ChecksumInfo
|
||||
type MockChecksumStorage struct {
|
||||
Store map[string]utils.ChecksumInfo
|
||||
}
|
||||
|
||||
// NewMockChecksumStorage creates aptly.ChecksumStorage for tests
|
||||
func NewMockChecksumStorage() aptly.ChecksumStorage {
|
||||
return &mockChecksumStorage{
|
||||
store: make(map[string]utils.ChecksumInfo),
|
||||
return &MockChecksumStorage{
|
||||
Store: make(map[string]utils.ChecksumInfo),
|
||||
}
|
||||
}
|
||||
|
||||
func (st *mockChecksumStorage) Get(path string) (*utils.ChecksumInfo, error) {
|
||||
c, ok := st.store[path]
|
||||
func (st *MockChecksumStorage) Get(path string) (*utils.ChecksumInfo, error) {
|
||||
c, ok := st.Store[path]
|
||||
if !ok {
|
||||
return nil, nil
|
||||
}
|
||||
@@ -25,12 +25,12 @@ func (st *mockChecksumStorage) Get(path string) (*utils.ChecksumInfo, error) {
|
||||
return &c, nil
|
||||
}
|
||||
|
||||
func (st *mockChecksumStorage) Update(path string, c *utils.ChecksumInfo) error {
|
||||
st.store[path] = *c
|
||||
func (st *MockChecksumStorage) Update(path string, c *utils.ChecksumInfo) error {
|
||||
st.Store[path] = *c
|
||||
return nil
|
||||
}
|
||||
|
||||
// Check interface
|
||||
var (
|
||||
_ aptly.ChecksumStorage = &mockChecksumStorage{}
|
||||
_ aptly.ChecksumStorage = &MockChecksumStorage{}
|
||||
)
|
||||
|
||||
@@ -111,7 +111,7 @@ func (s *PackagePoolSuite) TestImportOk(c *C) {
|
||||
// SHA256 should be automatically calculated
|
||||
c.Check(s.checksum.SHA256, Equals, "c76b4bd12fd92e4dfe1b55b18a67a669d92f62985d6a96c8a21d96120982cf12")
|
||||
// checksum storage is filled with new checksum
|
||||
c.Check(s.cs.(*mockChecksumStorage).store[path].SHA256, Equals, "c76b4bd12fd92e4dfe1b55b18a67a669d92f62985d6a96c8a21d96120982cf12")
|
||||
c.Check(s.cs.(*MockChecksumStorage).Store[path].SHA256, Equals, "c76b4bd12fd92e4dfe1b55b18a67a669d92f62985d6a96c8a21d96120982cf12")
|
||||
|
||||
info, err := s.pool.Stat(path)
|
||||
c.Assert(err, IsNil)
|
||||
@@ -128,7 +128,7 @@ func (s *PackagePoolSuite) TestImportOk(c *C) {
|
||||
c.Check(err, IsNil)
|
||||
c.Check(path, Equals, "c7/6b/4bd12fd92e4dfe1b55b18a67a669_some.deb")
|
||||
// checksum storage is filled with new checksum
|
||||
c.Check(s.cs.(*mockChecksumStorage).store[path].SHA256, Equals, "c76b4bd12fd92e4dfe1b55b18a67a669d92f62985d6a96c8a21d96120982cf12")
|
||||
c.Check(s.cs.(*MockChecksumStorage).Store[path].SHA256, Equals, "c76b4bd12fd92e4dfe1b55b18a67a669d92f62985d6a96c8a21d96120982cf12")
|
||||
|
||||
// double import, should be ok
|
||||
s.checksum.SHA512 = "" // clear checksum
|
||||
@@ -139,7 +139,7 @@ func (s *PackagePoolSuite) TestImportOk(c *C) {
|
||||
c.Check(s.checksum.SHA512, Equals, "d7302241373da972aa9b9e71d2fd769b31a38f71182aa71bc0d69d090d452c69bb74b8612c002ccf8a89c279ced84ac27177c8b92d20f00023b3d268e6cec69c")
|
||||
|
||||
// clear checksum storage, and do double-import
|
||||
delete(s.cs.(*mockChecksumStorage).store, path)
|
||||
delete(s.cs.(*MockChecksumStorage).Store, path)
|
||||
s.checksum.SHA512 = "" // clear checksum
|
||||
path, err = s.pool.Import(s.debFile, filepath.Base(s.debFile), &s.checksum, false, s.cs)
|
||||
c.Check(err, IsNil)
|
||||
@@ -244,7 +244,7 @@ func (s *PackagePoolSuite) TestVerify(c *C) {
|
||||
c.Check(exists, Equals, false)
|
||||
|
||||
// check existence, with missing checksum and no info in checksum storage
|
||||
delete(s.cs.(*mockChecksumStorage).store, path)
|
||||
delete(s.cs.(*MockChecksumStorage).Store, path)
|
||||
s.checksum.SHA512 = ""
|
||||
ppath, exists, err = s.pool.Verify("", filepath.Base(s.debFile), &s.checksum, s.cs)
|
||||
c.Check(ppath, Equals, path)
|
||||
|
||||
Reference in New Issue
Block a user