diff --git a/README.md b/README.md index 63494ef..a79e48f 100644 --- a/README.md +++ b/README.md @@ -99,15 +99,20 @@ CLI interface for archived Flags: - --[no-]help Show context-sensitive help (also try --help-long and --help-man). + --[no-]help Show context-sensitive help (also try --help-long + and --help-man). -d, --[no-]debug Enable debug mode ($ARCHIVED_CLI_DEBUG) - -t, --[no-]trace Enable trace mode (debug mode on steroids) ($ARCHIVED_CLI_TRACE) - -s, --endpoint=ENDPOINT Manager API endpoint address ($ARCHIVED_CLI_ENDPOINT) + -t, --[no-]trace Enable trace mode (debug mode on steroids) + ($ARCHIVED_CLI_TRACE) + -s, --endpoint=ENDPOINT Manager API endpoint address + ($ARCHIVED_CLI_ENDPOINT) --[no-]insecure Do not use TLS for gRPC connection --[no-]insecure-skip-verify - Do not perform TLS certificate verification for gRPC connection + Do not perform TLS certificate verification for + gRPC connection --cache-dir="~/.cache/archived/cli/objects" - Stat-cache directory for objects ($ARCHIVED_CLI_STAT_CACHE_DIR) + Stat-cache directory for objects + ($ARCHIVED_CLI_STAT_CACHE_DIR) -n, --namespace="default" namespace for containers to operate on Commands: @@ -156,9 +161,6 @@ version publish object list list objects in the given container and version -object create - create object(s) from location - object url get URL for the object diff --git a/cli/lazyblob/lazyblob.go b/cli/lazyblob/lazyblob.go index 93307b6..f195932 100644 --- a/cli/lazyblob/lazyblob.go +++ b/cli/lazyblob/lazyblob.go @@ -34,7 +34,7 @@ func New(url, tempDir string, length uint64) LazyBLOB { "url": url, "length": length, "tempdir": tempDir, - }).Debug("lazyblob initialized") + }).Trace("initializing lazyblob ...") return &lazyblob{ url: url, diff --git a/cli/service/service.go b/cli/service/service.go index 134cd12..3944b98 100644 --- a/cli/service/service.go +++ b/cli/service/service.go @@ -1,26 +1,16 @@ package service import ( - "bytes" "context" - "crypto/sha256" - "encoding/hex" "fmt" "io" - "io/fs" "net/http" - "os" - "path/filepath" - "strings" - "github.com/ProtonMail/go-crypto/openpgp" "github.com/pkg/errors" - rpmutils "github.com/sassoftware/go-rpmutils" log "github.com/sirupsen/logrus" - "github.com/teran/archived/cli/lazyblob" + "github.com/teran/archived/cli/service/source" cache "github.com/teran/archived/cli/service/stat_cache" - "github.com/teran/archived/cli/yum" v1proto "github.com/teran/archived/manager/presenter/grpc/proto/v1" ) @@ -36,19 +26,16 @@ type Service interface { ListContainers(namespaceName string) func(ctx context.Context) error DeleteContainer(namespaceName, containerName string) func(ctx context.Context) error - CreateVersion(namespaceName, containerName string, shouldPublish bool, fromDir, fromYumRepo, rpmGPGKey, rpmGPGKeyChecksum *string) func(ctx context.Context) error + CreateVersion(namespaceName, containerName string, shouldPublish bool, src source.Source) func(ctx context.Context) error DeleteVersion(namespaceName, containerName, versionID string) func(ctx context.Context) error ListVersions(namespaceName, containerName string) func(ctx context.Context) error PublishVersion(namespaceName, containerName, versionID string) func(ctx context.Context) error - CreateObject(namespaceName, containerName, versionID, directoryPath string) func(ctx context.Context) error ListObjects(namespaceName, containerName, versionID string) func(ctx context.Context) error GetObjectURL(namespaceName, containerName, versionID, objectKey string) func(ctx context.Context) error DeleteObject(namespaceName, containerName, versionID, objectKey string) func(ctx context.Context) error } -const processStatusInterval int = 100 - type service struct { cache cache.CacheRepository cli v1proto.ManageServiceClient @@ -191,7 +178,7 @@ func (s *service) DeleteContainer(namespaceName, containerName string) func(ctx } } -func (s *service) CreateVersion(namespaceName, containerName string, shouldPublish bool, fromDir, fromYumRepo, rpmGPGKey, rpmGPGKeyChecksum *string) func(ctx context.Context) error { +func (s *service) CreateVersion(namespaceName, containerName string, shouldPublish bool, src source.Source) func(ctx context.Context) error { return func(ctx context.Context) error { log.Tracef("creating version ...") resp, err := s.cli.CreateVersion(ctx, &v1proto.CreateVersionRequest{ @@ -205,27 +192,10 @@ func (s *service) CreateVersion(namespaceName, containerName string, shouldPubli versionID := resp.GetVersion() log.Tracef("version created: `%s`", versionID) - if fromDir != nil && *fromDir != "" { - log.Tracef("--from-dir is requested with `%s`", *fromDir) - err = s.CreateObject(namespaceName, containerName, versionID, *fromDir)(ctx) - if err != nil { - return errors.Wrap(err, "error creating objects") - } - } else if fromYumRepo != nil && *fromYumRepo != "" { - log.Tracef("--from-yum-repo is requested with `%s`", *fromYumRepo) - var gpgKeyring openpgp.EntityList = nil - if *rpmGPGKey != "" { - log.Tracef("RPM GPG Key was passed so initialing GPG keyring ...") - gpgKeyring, err = getGPGKey(ctx, *rpmGPGKey, rpmGPGKeyChecksum) - if err != nil { - return err - } - } - - err := s.createVersionFromYUMRepository(ctx, namespaceName, containerName, versionID, *fromYumRepo, gpgKeyring) - if err != nil { - return errors.Wrap(err, "error creating objects") - } + if err := src.Process(ctx, func(ctx context.Context, obj source.Object) error { + return s.createObject(ctx, namespaceName, containerName, versionID, obj) + }); err != nil { + return errors.Wrap(err, "error processing source") } if shouldPublish { @@ -248,143 +218,6 @@ func (s *service) CreateVersion(namespaceName, containerName string, shouldPubli } } -func (s *service) createVersionFromYUMRepository(ctx context.Context, namespaceName string, containerName, versionID, url string, gpgKeyring openpgp.EntityList) error { - log.WithFields(log.Fields{ - "repository_url": url, - }).Info("running creating version from YUM repository ...") - - repo := yum.New(url) - packages, err := repo.Packages(ctx) - if err != nil { - return errors.Wrap(err, "error getting repository data") - } - - log.WithFields(log.Fields{ - "repository_url": url, - }).Info("handling YUM repository metadata files ...") - for k, v := range repo.Metadata() { - size := len(v) - - hasher := sha256.New() - n, err := hasher.Write(v) - if err != nil { - return err - } - - if n != size { - return io.ErrShortWrite - } - - checksum := hex.EncodeToString(hasher.Sum(nil)) - - log.Tracef("rpc CreateObject(%s, %s, %s, %s, %s, %d)", namespaceName, containerName, versionID, k, checksum, size) - resp, err := s.cli.CreateObject(ctx, &v1proto.CreateObjectRequest{ - Namespace: namespaceName, - Container: containerName, - Version: versionID, - Key: k, - Checksum: checksum, - Size: uint64(size), - }) - if err != nil { - return errors.Wrap(err, "error creating object") - } - - if uploadURL := resp.GetUploadUrl(); uploadURL != "" { - err := uploadBlob(ctx, uploadURL, bytes.NewReader(v), uint64(size)) - if err != nil { - return err - } - } - } - - log.WithFields(log.Fields{ - "repository_url": url, - "packages_count": len(packages), - }).Info("handling package files ...") - for cnt, pkg := range packages { - err := func(name, checksum, sourceURL string, size uint64) error { - lb := lazyblob.New(sourceURL, os.TempDir(), size) - defer func() { - if err := lb.Close(); err != nil { - log.Warnf("error removing scratch data: %s", err) - } - }() - - if pkg.ChecksumType != "sha256" { - filename, err := lb.Filename(ctx) - if err != nil { - return errors.Wrap(err, "error getting package filename") - } - - checksum, err = checksumFile(filename) - if err != nil { - return errors.Wrap(err, "error calculating checksum") - } - } - - log.Tracef("rpc CreateObject(%s, %s, %s, %s, %s, %d)", namespaceName, containerName, versionID, name, checksum, size) - resp, err := s.cli.CreateObject(ctx, &v1proto.CreateObjectRequest{ - Namespace: namespaceName, - Container: containerName, - Version: versionID, - Key: name, - Checksum: checksum, - Size: size, - }) - if err != nil { - return errors.Wrap(err, "error creating object") - } - - if uploadURL := resp.GetUploadUrl(); uploadURL != "" { - if gpgKeyring != nil { - log.Debug("verifying RPM GPG signature ...") - - fp, err := lb.Reader(ctx) - if err != nil { - return errors.Wrap(err, "error opening package file") - } - - _, sigs, err := rpmutils.Verify(fp, gpgKeyring) - if err != nil { - return errors.Wrapf(err, "error verifying package signature: %s", name) - } - - if len(sigs) == 0 { - log.Warnf("package `%s` does not contain signature", name) - } - } - - err := func(uploadURL string) error { - log.Tracef("Upload URL: `%s`", uploadURL) - - fp, err := lb.Reader(ctx) - if err != nil { - return errors.Wrap(err, "error getting reader for package file") - } - - return uploadBlob(ctx, uploadURL, fp, size) - }(uploadURL) - if err != nil { - return err - } - } - - if cnt%processStatusInterval == 0 { - log.WithFields(log.Fields{ - "repository_url": url, - }).Infof("%d files processed ...", cnt+1) - } - - return nil - }(pkg.Name, pkg.Checksum, strings.TrimSuffix(url, "/")+"/"+strings.TrimPrefix(pkg.Name, "/"), pkg.Size) - if err != nil { - return err - } - } - return nil -} - func (s *service) DeleteVersion(namespaceName, containerName, versionID string) func(ctx context.Context) error { return func(ctx context.Context) error { _, err := s.cli.DeleteVersion(ctx, &v1proto.DeleteVersionRequest{ @@ -436,100 +269,6 @@ func (s *service) PublishVersion(namespaceName, containerName, versionID string) } } -func (s *service) CreateObject(namespaceName, containerName, versionID, directoryPath string) func(ctx context.Context) error { - return func(ctx context.Context) error { - log.WithFields(log.Fields{ - "directory": directoryPath, - }).Info("scanning directory ...") - var cnt int - return filepath.Walk(directoryPath, func(path string, info fs.FileInfo, err error) error { - defer func() { cnt++ }() - - if err != nil { - return errors.Wrap(err, "walk: internal error") - } - - if info.IsDir() { - return nil - } - - shortPath := strings.TrimPrefix(path, directoryPath) - shortPath = strings.TrimPrefix(shortPath, "/") - size := info.Size() - - log.WithFields(log.Fields{ - "filename": shortPath, - "size": size, - }).Debug("file found") - - log.WithFields(log.Fields{ - "filename": shortPath, - "size": size, - }).Tracef("attempting to retrieve checksum from cache") - checksum, err := s.cache.Get(ctx, path, info) - if err != nil { - return errors.Wrap(err, "error retrieving checksum from cache") - } - - if checksum == "" { - log.WithFields(log.Fields{ - "filename": shortPath, - "size": size, - }).Debug("generating checksum") - checksum, err = checksumFile(path) - if err != nil { - return errors.Wrap(err, "error calculating file checksum") - } - - err := s.cache.Put(ctx, path, info, checksum) - if err != nil { - log.Warnf("error putting checksum calculation result into cache: %s", err) - } - } - log.WithFields(log.Fields{ - "filename": shortPath, - "size": size, - "checksum": checksum, - }).Debug("checksum") - - log.Tracef("rpc CreateObject(%s,%s, %s, %s, %s, %d)", namespaceName, containerName, versionID, shortPath, checksum, size) - resp, err := s.cli.CreateObject(ctx, &v1proto.CreateObjectRequest{ - Namespace: namespaceName, - Container: containerName, - Version: versionID, - Key: shortPath, - Checksum: checksum, - Size: uint64(size), - }) - if err != nil { - return errors.Wrap(err, "error creating object") - } - - if url := resp.GetUploadUrl(); url != "" { - log.Tracef("Upload URL: `%s`", url) - - fp, err := os.Open(path) - if err != nil { - return errors.Wrap(err, "error opening file") - } - defer fp.Close() - - if err := uploadBlob(ctx, url, fp, uint64(size)); err != nil { - return err - } - } - - if cnt%processStatusInterval == 0 { - log.WithFields(log.Fields{ - "directory": directoryPath, - }).Infof("%d files processed ...", cnt+1) - } - - return nil - }) - } -} - func (s *service) ListObjects(namespaceName, containerName, versionID string) func(ctx context.Context) error { return func(ctx context.Context) error { resp, err := s.cli.ListObjects(ctx, &v1proto.ListObjectsRequest{ @@ -583,28 +322,38 @@ func (s *service) DeleteObject(namespaceName, containerName, versionID, objectKe } } -func checksumFile(filename string) (string, error) { - info, err := os.Stat(filename) - if err != nil { - return "", errors.Wrap(err, "error performing stat on file") - } - fp, err := os.Open(filename) +func (s *service) createObject(ctx context.Context, namespaceName, containerName, versionID string, object source.Object) error { + log.WithFields(log.Fields{ + "path": object.Path, + "sha256": object.SHA256, + "length": object.Size, + }).Info("creating object ...") + + resp, err := s.cli.CreateObject(ctx, &v1proto.CreateObjectRequest{ + Namespace: namespaceName, + Container: containerName, + Version: versionID, + Key: object.Path, + Checksum: object.SHA256, + Size: object.Size, + }) if err != nil { - return "", errors.Wrap(err, "error opening file") + return errors.Wrap(err, "error creating object") } - defer fp.Close() - h := sha256.New() - n, err := io.Copy(h, fp) - if err != nil { - return "", errors.Wrap(err, "error reading file") - } + if url := resp.GetUploadUrl(); url != "" { + log.WithFields(log.Fields{ + "path": object.Path, + "sha256": object.SHA256, + "length": object.Size, + "url": url, + }).Info("uploading BLOB ...") - if n != info.Size() { - return "", errors.Errorf("file size is %d bytes while only %d was copied: early EOF", info.Size(), n) + if err := uploadBlob(ctx, url, object.Contents, object.Size); err != nil { + return err + } } - - return hex.EncodeToString(h.Sum(nil)), nil + return nil } func uploadBlob(ctx context.Context, url string, rd io.Reader, size uint64) error { @@ -618,7 +367,7 @@ func uploadBlob(ctx context.Context, url string, rd io.Reader, size uint64) erro log.WithFields(log.Fields{ "url": url, "length": size, - }).Tracef("size is set") + }).Tracef("Setting Content-Length ...") req.ContentLength = int64(size) } diff --git a/cli/service/service_test.go b/cli/service/service_test.go index 87d512e..54ef59b 100644 --- a/cli/service/service_test.go +++ b/cli/service/service_test.go @@ -2,24 +2,17 @@ package service import ( "context" - "io" - "net/http" - "net/http/httptest" "testing" - echo "github.com/labstack/echo/v4" - "github.com/labstack/echo/v4/middleware" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/suite" - ptr "github.com/teran/go-ptr" + sourceMock "github.com/teran/archived/cli/service/source/mock" cacheMock "github.com/teran/archived/cli/service/stat_cache/mock" ) const ( defaultNamespace = "default" - - mimeTypeMultipartFormData = "multipart/form-data" ) func init() { @@ -92,793 +85,19 @@ func (s *serviceTestSuite) TestDeleteContainer() { func (s *serviceTestSuite) TestCreateVersion() { s.cliMock.On("CreateVersion", defaultNamespace, "container1").Return("version_id", nil).Once() - fn := s.svc.CreateVersion(defaultNamespace, "container1", false, nil, nil, nil, nil) - s.Require().NoError(fn(s.ctx)) -} + s.sourceMock.On("Process").Return(nil).Once() -func (s *serviceTestSuite) TestCreateVersionAndPublish() { - s.cliMock.On("CreateVersion", defaultNamespace, "container1").Return("version_id", nil).Once() - s.cliMock.On("PublishVersion", defaultNamespace, "container1", "version_id").Return(nil).Once() - - fn := s.svc.CreateVersion(defaultNamespace, "container1", true, nil, nil, nil, nil) + fn := s.svc.CreateVersion(defaultNamespace, "container1", false, s.sourceMock) s.Require().NoError(fn(s.ctx)) } -func (s *serviceTestSuite) TestCreateVersionAndPublishWithEmptyPath() { +func (s *serviceTestSuite) TestCreateVersionAndPublish() { s.cliMock.On("CreateVersion", defaultNamespace, "container1").Return("version_id", nil).Once() s.cliMock.On("PublishVersion", defaultNamespace, "container1", "version_id").Return(nil).Once() - fn := s.svc.CreateVersion(defaultNamespace, "container1", true, ptr.String(""), nil, nil, nil) - s.Require().NoError(fn(s.ctx)) -} - -func (s *serviceTestSuite) TestCreateVersionFromDirAndPublish() { - s.cacheMock.On("Get", "testdata/repo/somefile1").Return("", nil).Once() - s.cacheMock.On("Get", "testdata/repo/somefile2").Return("", nil).Once() - s.cacheMock.On("Put", "testdata/repo/somefile1", "a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4").Return(nil).Once() - s.cacheMock.On("Put", "testdata/repo/somefile2", "ff5a972ba33179c7ec67c73e00a362b629c489f9d7c86489644db2bcd8c62c61").Return(nil).Once() + s.sourceMock.On("Process").Return(nil).Once() - s.cliMock.On("CreateVersion", defaultNamespace, "container1").Return("version_id", nil, nil).Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "somefile1", "a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4", uint64(5)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "somefile2", "ff5a972ba33179c7ec67c73e00a362b629c489f9d7c86489644db2bcd8c62c61", uint64(5)). - Return(ptr.String(""), nil). - Once() - s.cliMock.On("PublishVersion", defaultNamespace, "container1", "version_id").Return(nil).Once() - - fn := s.svc.CreateVersion(defaultNamespace, "container1", true, ptr.String("testdata/repo"), nil, nil, nil) - s.Require().NoError(fn(s.ctx)) -} - -func (s *serviceTestSuite) TestCreateVersionFromYumRepoAndPublish() { - e := echo.New() - e.Use(middleware.Logger()) - e.Use(middleware.Recover()) - e.Static("/", "../yum/testdata/repo") - - srv := httptest.NewServer(e) - defer srv.Close() - - e2 := echo.New() - e2.Use(middleware.Logger()) - e2.Use(middleware.Recover()) - e2.PUT("/upload", func(c echo.Context) error { - if c.Request().Header.Get("Content-Length") != "6156" { - return c.NoContent(http.StatusLengthRequired) - } - - if c.Request().Header.Get("Content-Type") != mimeTypeMultipartFormData { - return c.NoContent(http.StatusUnsupportedMediaType) - } - return nil - }) - - uploadSrv := httptest.NewServer(e2) - defer uploadSrv.Close() - - s.cliMock.On("CreateVersion", defaultNamespace, "container1").Return("version_id", nil, nil).Once() - - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/12fd2c7242e8f946c5a99b40acc94e297144685022f23f08f5d4932a37387053-primary.xml.gz", "12fd2c7242e8f946c5a99b40acc94e297144685022f23f08f5d4932a37387053", uint64(4550)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/3228a79e4328e912dc272ea29a6e627187e4d1ecdb41c39f17e67b0a4f1ea1a5-primary.sqlite.bz2", "3228a79e4328e912dc272ea29a6e627187e4d1ecdb41c39f17e67b0a4f1ea1a5", uint64(9036)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/f47c809e5e0589800a672ee64fd4f4fd7bc71152596bcf8ebcd6a582d40ca9dd-filelists.xml.gz", "f47c809e5e0589800a672ee64fd4f4fd7bc71152596bcf8ebcd6a582d40ca9dd", uint64(3000)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/a362c47ae86d8ee5f6e623fcb09e309d5b701316fe356e7642fa24ca47610c52-filelists.sqlite.bz2", "a362c47ae86d8ee5f6e623fcb09e309d5b701316fe356e7642fa24ca47610c52", uint64(5554)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/3af4f502859773f9b5b5a3b8033f8561f01b270414cabb3b46612703c85d731f-other.xml.gz", "3af4f502859773f9b5b5a3b8033f8561f01b270414cabb3b46612703c85d731f", uint64(2848)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/27c7a0b93802b0173730c713cf74c0ac80e402880e3a87f12c5dc3efcfa0ec32-other.sqlite.bz2", "27c7a0b93802b0173730c713cf74c0ac80e402880e3a87f12c5dc3efcfa0ec32", uint64(4351)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/repomd.xml", "904c00f4c838f67d1c79113d7996840add665d513889b112bb715776607c151c", uint64(3078)). - Return(ptr.String(""), nil). - Once() - - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg1-1-1.x86_64.rpm", "49fd5f21e3d489e500eba418207d62bc241d9f512a23b14fecb8a7777ee01bc6", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg1-1-2.x86_64.rpm", "08b032391b745436fd9b2a19b3f74889a5965c24d27d1d818a0d49b66ac4f47a", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg1-1-3.x86_64.rpm", "d9c6b377f3484f5a6312164df290186d9ed5536a8e3e67ef1c7ae8c9b956794b", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg10-1-1.x86_64.rpm", "af60a18cd0517920acac3ff737e5595c4b2dc779dd9205f6731eeba54265dfd7", uint64(6740)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg10-1-2.x86_64.rpm", "6dc90f4258183bb61baa2a0a588732fa5db0fd165d1b7bf02ff0198fca93efdb", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg10-1-3.x86_64.rpm", "a68d0510bec578428402a029eac55e34e8784e96556e9f2d1c9424911c2a489f", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg2-1-1.x86_64.rpm", "88307ad55751656bb96132d8d448aa78ebafb28120634695f8207c8460ad7dff", uint64(6741)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg2-1-2.x86_64.rpm", "e5dd6aac17915a9ada1b39e4efcb03e4ee3e6998ff910c0584ccb11f97721632", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg2-1-3.x86_64.rpm", "d216d06a4ff1569a98ff981469bbf2765300587f69dbf378a150c0cf8dfb4795", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg3-1-1.x86_64.rpm", "68170e526f756eeb06d33d77332000a67e8eb31eb004f28de509ed8aae72f8a6", uint64(6741)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg3-1-2.x86_64.rpm", "f75513d7fc853e3f8d4c832700151dcb04d88388f367c4a29a0c702988fd9c80", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg3-1-3.x86_64.rpm", "ec036e47e7e711cf26b126c103e25bf0191a67bfc44089f18ee6c3ade8a334d1", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg4-1-1.x86_64.rpm", "e7de03570c76ec13cceff7bca33cec6fcff45e3c4c83e088b06764825542e78b", uint64(6741)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg4-1-2.x86_64.rpm", "c9731ea0936b1c4debc4ebae7935687c4a5a5f9b538ab795c903adbce6ba5b70", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg4-1-3.x86_64.rpm", "5942505f4082335d8cde4e03bb9bb9080e86efb6a24dce6167a71abbe418a1d2", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg5-1-1.x86_64.rpm", "006ef00d887654372886d295c1dc03eff7b18c611c1d35c4081456300bf99d15", uint64(6741)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg5-1-2.x86_64.rpm", "ab195eaac0cc29c13c5920e0bdb8f2dedcc20ca10861775d6a0ccce8bb81546c", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg5-1-3.x86_64.rpm", "f2149561e84c54c429869ec051b18b3c59a92313164fc2b678c08b182711e339", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg6-1-1.x86_64.rpm", "234b5d4a4ea3cd320292c374efdb2ca51876fac43f902d3816a8b04bd155a5c1", uint64(6741)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg6-1-2.x86_64.rpm", "2665d47c785688562748b0d7c0637a2c9ff052cb12acf09a2b64d0da699843f2", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg6-1-3.x86_64.rpm", "84c25528dc5381c89656e52a6af6fa51c7cb9faa69cec3b5c196ffd4ba037c80", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg7-1-1.x86_64.rpm", "6b3edf4d9a1194b0b07c660281378375d258f25e1e74c7852f9fb209c0b1de4f", uint64(6741)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg7-1-2.x86_64.rpm", "8c9d92872e4c3c462203682c63c79d61c00b398f84a4adf66f2da08e4c416a4b", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg7-1-3.x86_64.rpm", "845b31dbb4d80b13ace39ab2da1e19d68727d43de7b01fd5cf5c10e633f7707e", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg8-1-1.x86_64.rpm", "1ed2f5e08a1f57c68199c57271404945762bcba36d99c2c03a45d60ad8e53a75", uint64(6741)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg8-1-2.x86_64.rpm", "dde30ee7035800604434e3b0928934c56fc382748cb3dc6a87ee7605a15af9a3", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg8-1-3.x86_64.rpm", "1fec4e8fcd788227fd836960f129b7c5384bf416aa78bdb7923dfdc431b208bf", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg9-1-1.x86_64.rpm", "0ba29dded6b136adb548396295f46ff4fa827d416cdfa25129ddaef5be2f2d96", uint64(6740)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg9-1-2.x86_64.rpm", "192d106bc5c19b9e8651dbd255f5f0a240b781b85a2af0ce58d1c5f8670158b6", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg9-1-3.x86_64.rpm", "ae2f90464235b2abeccf9c2607c51bab0b8a4f3afd6531026d62d54300b2e093", uint64(6742)). - Return(ptr.String(""), nil). - Once() - - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg1-1-1.src.rpm", "5906d8401381f428c28074563ed082425074cf4737ef38ca1bf21c3261aabd76", uint64(6123)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg1-1-2.src.rpm", "fb69e232a677646c0375e9cf999e5c8493368edcafd0e5fe6f901a7425f7d68e", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg1-1-3.src.rpm", "cf28031ec6d8ddc146b1f2ec37e4b7bbd7f4f751ae9b7730f709c43d0292bb79", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg10-1-1.src.rpm", "7f86347249889174a4bcfa2d20aec471e44275be06484f45a2d1afa4f61d8895", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg10-1-2.src.rpm", "151a800766bfb51b8f414878367f64028f3693dc323a01de2ccc10d96813f302", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg10-1-3.src.rpm", "370e830462c33db0cc11dcaa7f539773a651c1dde980bd1e92db601d85156419", uint64(6125)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg2-1-1.src.rpm", "802c968cd29794edf721fcbc5924a68606df9a0648d89c648481bf77ff89c53c", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg2-1-2.src.rpm", "f26e8390a958c0fd0a15c07cf9ef2f93485b90ec701888013f1453b0946c7c47", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg2-1-3.src.rpm", "07a1e8b441c8e329cb07567bdbd845d833da6721dfc166c3510469f313ebd652", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg3-1-1.src.rpm", "3a557ebe499975f3c7b95e1b39ca3ff10369b51dec045d8f882a0cb587815db4", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg3-1-2.src.rpm", "4ad8107d6a8a9f32c3c2f4971756467ee536979cb246e53a9d238c824df665ea", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg3-1-3.src.rpm", "14b797a378b75c5c6793400f2d2f14b98099ba32b95828686ca7b14c8475d889", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg4-1-1.src.rpm", "7b981767615dd5c739f027bcc17aa91343d36aa5040e59f7614e401a35b2e703", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg4-1-2.src.rpm", "3f55e2dd76104d19baf4148342c0cdc5b0230879cca6c5b13c07f24a25d79a1d", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg4-1-3.src.rpm", "80ea7ece7614339e906e80920a5a5d5bf0881f3e9a0a02ab2831036e67ea4152", uint64(6125)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg5-1-1.src.rpm", "182367519219c7f56c1213350372333219fa0d2f858072f524734308949daf61", uint64(6122)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg5-1-2.src.rpm", "904021dcfd97e54d3c5cbaa7742af844cc5c48adb4af4ba88495db30afd629d9", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg5-1-3.src.rpm", "7b74718b1f01b561f66d04706327269bf67981db6743c46858fe03e2868c6ef5", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg6-1-1.src.rpm", "96e669c98d8d79d0acc77f1d9b3246e6baabf2f49a7591d26ba69740b80574ee", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg6-1-2.src.rpm", "798464bf773513c123183fe00aa350459ec31568e2ee1895d8fef4d6dfbb2e28", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg6-1-3.src.rpm", "d9e1eaa79d2b80349186b3ec51a5331ca400994d9ba0a5fbcd6992fdf2234fcb", uint64(6125)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg7-1-1.src.rpm", "8f76905b96b5476485fca223804a9900c3351f0b61e30f862ebc7e48f1232fca", uint64(6123)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg7-1-2.src.rpm", "263e504fd0be3d6903e03e4b5d3c820c6f06e474253d63bf7951223c3080cc17", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg7-1-3.src.rpm", "c04e4e225556951502e2ce533ac25d26decf63a768013c14bcec32dc60b88837", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg8-1-1.src.rpm", "6b0bb85fe30ae6e406a1dddb2af7126294e24fae64e79be67c426e94f90720ee", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg8-1-2.src.rpm", "cc3fd1c43ea62332e534e0f5d6a7df7f1c808725116109f33fe38453682d5ee7", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg8-1-3.src.rpm", "d5ccf0943d89947bb2f8b3ed8466d60e452f1b0daa881d5d3fe2c8584778883b", uint64(6125)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg9-1-1.src.rpm", "ed76da35a9b4f4ea4e3828f6a978016cc6b4b9c0cd0548f2d4cbd6a695b1f6e9", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg9-1-2.src.rpm", "26dc22dbbbd6569c6d41d7c37b6e8b3d90ec24c76c075bfe8b0016de64bb2029", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg9-1-3.src.rpm", "869bf9b01e2ea53e02bb8666ca1118e2c9e5cef2598e9a1b1f67125531b3bd8e", uint64(6125)). - Return(ptr.String(""), nil). - Once() - - s.cliMock.On("PublishVersion", defaultNamespace, "container1", "version_id").Return(nil).Once() - - fn := s.svc.CreateVersion(defaultNamespace, "container1", true, ptr.String(""), ptr.String(srv.URL), ptr.String(""), nil) - s.Require().NoError(fn(s.ctx)) -} - -func (s *serviceTestSuite) TestCreateVersionFromYumRepoAndPublishSHA1() { - e := echo.New() - e.Use(middleware.Logger()) - e.Use(middleware.Recover()) - e.Static("/", "../yum/testdata/repo-sha1") - - srv := httptest.NewServer(e) - defer srv.Close() - - e2 := echo.New() - e2.Use(middleware.Logger()) - e2.Use(middleware.Recover()) - e2.PUT("/upload", func(c echo.Context) error { - if c.Request().Header.Get("Content-Length") != "6156" { - return c.NoContent(http.StatusLengthRequired) - } - - if c.Request().Header.Get("Content-Type") != mimeTypeMultipartFormData { - return c.NoContent(http.StatusUnsupportedMediaType) - } - return nil - }) - - uploadSrv := httptest.NewServer(e2) - defer uploadSrv.Close() - - s.cliMock.On("CreateVersion", defaultNamespace, "container1").Return("version_id", nil, nil).Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/80779e2ab55e25a77124d370de1d08deae8f1cc6-primary.xml.gz", "1c07f3f3f0e6d09972c1d7852d1dbc9715d6fbdceee66c50e8356d1e69502d3b", uint64(688)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/e7a8a53e7398f6c22894718ea227fea60f2b78ba-primary.sqlite.bz2", "c9b8ce03b503e29d9ec2faa2328e4f2082f0a5f71478ca6cb2f1a3ab75e676bc", uint64(1937)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/4a11e3eeb25d21b08f41e5578d702d2bea21a2e7-filelists.xml.gz", "b56801c0a86f9a0136953e8c8e59cd35c1f18fc41e70ba8fcdcccfee068dfc8a", uint64(282)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/c66ce2caa41ed83879f9b3dd9f40e61c65af499e-filelists.sqlite.bz2", "59bd3edd4edacac87e5e15494698f34a7f52277691635f927c185e92a681d9ee", uint64(787)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/fdedb6ce109127d52228d01b0239010ddca14c8f-other.xml.gz", "56e566dfc63b0a7056b21cec661717a411f68cf98747d9a719557bce3a8ac41a", uint64(247)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/b31561a27d014d35b59b27c27859bb1c17ac573e-other.sqlite.bz2", "7eec446e0036d356d8e5694047d9fdb6af00f2fc62993b854232830cf9dbcff8", uint64(669)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/repomd.xml", "9f18801e8532f631e308a130a347f66eb3900d054df1d66dff53a69aa5b9e7d3", uint64(2601)). - Return(ptr.String(""), nil). - Once() - - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "Packages/testpkg-1-1.src.rpm", "684303227d799ffe1f0b39e030a12ad249931a11ec1690e2079f981cc16d8c52", uint64(6156)). - Return(ptr.String(uploadSrv.URL+"/upload"), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "Packages/testpkg-1-1.x86_64.rpm", "d9ae5e56ea38d2ac470f320cade63663dae6ab8b8e1630b2fd5a3c607f45e2ee", uint64(6722)). - Return(ptr.String(""), nil). - Once() - s.cliMock.On("PublishVersion", defaultNamespace, "container1", "version_id").Return(nil).Once() - - fn := s.svc.CreateVersion(defaultNamespace, "container1", true, ptr.String(""), ptr.String(srv.URL), ptr.String(""), nil) - s.Require().NoError(fn(s.ctx)) -} - -func (s *serviceTestSuite) TestCreateVersionFromYumRepoAndPublishGPGNoSignature() { - e := echo.New() - e.Use(middleware.Logger()) - e.Use(middleware.Recover()) - e.Static("/", "../yum/testdata/repo") - - srv := httptest.NewServer(e) - defer srv.Close() - - e2 := echo.New() - e2.Use(middleware.Logger()) - e2.Use(middleware.Recover()) - e2.PUT("/upload", func(c echo.Context) error { - if c.Request().Header.Get("Content-Length") != "6156" { - return c.NoContent(http.StatusLengthRequired) - } - - if c.Request().Header.Get("Content-Type") != mimeTypeMultipartFormData { - return c.NoContent(http.StatusUnsupportedMediaType) - } - return nil - }) - - uploadSrv := httptest.NewServer(e2) - defer uploadSrv.Close() - - s.cliMock.On("CreateVersion", defaultNamespace, "container1").Return("version_id", nil, nil).Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/12fd2c7242e8f946c5a99b40acc94e297144685022f23f08f5d4932a37387053-primary.xml.gz", "12fd2c7242e8f946c5a99b40acc94e297144685022f23f08f5d4932a37387053", uint64(4550)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/3228a79e4328e912dc272ea29a6e627187e4d1ecdb41c39f17e67b0a4f1ea1a5-primary.sqlite.bz2", "3228a79e4328e912dc272ea29a6e627187e4d1ecdb41c39f17e67b0a4f1ea1a5", uint64(9036)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/f47c809e5e0589800a672ee64fd4f4fd7bc71152596bcf8ebcd6a582d40ca9dd-filelists.xml.gz", "f47c809e5e0589800a672ee64fd4f4fd7bc71152596bcf8ebcd6a582d40ca9dd", uint64(3000)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/a362c47ae86d8ee5f6e623fcb09e309d5b701316fe356e7642fa24ca47610c52-filelists.sqlite.bz2", "a362c47ae86d8ee5f6e623fcb09e309d5b701316fe356e7642fa24ca47610c52", uint64(5554)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/3af4f502859773f9b5b5a3b8033f8561f01b270414cabb3b46612703c85d731f-other.xml.gz", "3af4f502859773f9b5b5a3b8033f8561f01b270414cabb3b46612703c85d731f", uint64(2848)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/27c7a0b93802b0173730c713cf74c0ac80e402880e3a87f12c5dc3efcfa0ec32-other.sqlite.bz2", "27c7a0b93802b0173730c713cf74c0ac80e402880e3a87f12c5dc3efcfa0ec32", uint64(4351)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/repomd.xml", "904c00f4c838f67d1c79113d7996840add665d513889b112bb715776607c151c", uint64(3078)). - Return(ptr.String(""), nil). - Once() - - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg1-1-1.x86_64.rpm", "49fd5f21e3d489e500eba418207d62bc241d9f512a23b14fecb8a7777ee01bc6", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg1-1-2.x86_64.rpm", "08b032391b745436fd9b2a19b3f74889a5965c24d27d1d818a0d49b66ac4f47a", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg1-1-3.x86_64.rpm", "d9c6b377f3484f5a6312164df290186d9ed5536a8e3e67ef1c7ae8c9b956794b", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg10-1-1.x86_64.rpm", "af60a18cd0517920acac3ff737e5595c4b2dc779dd9205f6731eeba54265dfd7", uint64(6740)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg10-1-2.x86_64.rpm", "6dc90f4258183bb61baa2a0a588732fa5db0fd165d1b7bf02ff0198fca93efdb", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg10-1-3.x86_64.rpm", "a68d0510bec578428402a029eac55e34e8784e96556e9f2d1c9424911c2a489f", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg2-1-1.x86_64.rpm", "88307ad55751656bb96132d8d448aa78ebafb28120634695f8207c8460ad7dff", uint64(6741)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg2-1-2.x86_64.rpm", "e5dd6aac17915a9ada1b39e4efcb03e4ee3e6998ff910c0584ccb11f97721632", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg2-1-3.x86_64.rpm", "d216d06a4ff1569a98ff981469bbf2765300587f69dbf378a150c0cf8dfb4795", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg3-1-1.x86_64.rpm", "68170e526f756eeb06d33d77332000a67e8eb31eb004f28de509ed8aae72f8a6", uint64(6741)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg3-1-2.x86_64.rpm", "f75513d7fc853e3f8d4c832700151dcb04d88388f367c4a29a0c702988fd9c80", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg3-1-3.x86_64.rpm", "ec036e47e7e711cf26b126c103e25bf0191a67bfc44089f18ee6c3ade8a334d1", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg4-1-1.x86_64.rpm", "e7de03570c76ec13cceff7bca33cec6fcff45e3c4c83e088b06764825542e78b", uint64(6741)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg4-1-2.x86_64.rpm", "c9731ea0936b1c4debc4ebae7935687c4a5a5f9b538ab795c903adbce6ba5b70", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg4-1-3.x86_64.rpm", "5942505f4082335d8cde4e03bb9bb9080e86efb6a24dce6167a71abbe418a1d2", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg5-1-1.x86_64.rpm", "006ef00d887654372886d295c1dc03eff7b18c611c1d35c4081456300bf99d15", uint64(6741)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg5-1-2.x86_64.rpm", "ab195eaac0cc29c13c5920e0bdb8f2dedcc20ca10861775d6a0ccce8bb81546c", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg5-1-3.x86_64.rpm", "f2149561e84c54c429869ec051b18b3c59a92313164fc2b678c08b182711e339", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg6-1-1.x86_64.rpm", "234b5d4a4ea3cd320292c374efdb2ca51876fac43f902d3816a8b04bd155a5c1", uint64(6741)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg6-1-2.x86_64.rpm", "2665d47c785688562748b0d7c0637a2c9ff052cb12acf09a2b64d0da699843f2", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg6-1-3.x86_64.rpm", "84c25528dc5381c89656e52a6af6fa51c7cb9faa69cec3b5c196ffd4ba037c80", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg7-1-1.x86_64.rpm", "6b3edf4d9a1194b0b07c660281378375d258f25e1e74c7852f9fb209c0b1de4f", uint64(6741)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg7-1-2.x86_64.rpm", "8c9d92872e4c3c462203682c63c79d61c00b398f84a4adf66f2da08e4c416a4b", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg7-1-3.x86_64.rpm", "845b31dbb4d80b13ace39ab2da1e19d68727d43de7b01fd5cf5c10e633f7707e", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg8-1-1.x86_64.rpm", "1ed2f5e08a1f57c68199c57271404945762bcba36d99c2c03a45d60ad8e53a75", uint64(6741)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg8-1-2.x86_64.rpm", "dde30ee7035800604434e3b0928934c56fc382748cb3dc6a87ee7605a15af9a3", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg8-1-3.x86_64.rpm", "1fec4e8fcd788227fd836960f129b7c5384bf416aa78bdb7923dfdc431b208bf", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg9-1-1.x86_64.rpm", "0ba29dded6b136adb548396295f46ff4fa827d416cdfa25129ddaef5be2f2d96", uint64(6740)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg9-1-2.x86_64.rpm", "192d106bc5c19b9e8651dbd255f5f0a240b781b85a2af0ce58d1c5f8670158b6", uint64(6742)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg9-1-3.x86_64.rpm", "ae2f90464235b2abeccf9c2607c51bab0b8a4f3afd6531026d62d54300b2e093", uint64(6742)). - Return(ptr.String(""), nil). - Once() - - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg1-1-1.src.rpm", "5906d8401381f428c28074563ed082425074cf4737ef38ca1bf21c3261aabd76", uint64(6123)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg1-1-2.src.rpm", "fb69e232a677646c0375e9cf999e5c8493368edcafd0e5fe6f901a7425f7d68e", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg1-1-3.src.rpm", "cf28031ec6d8ddc146b1f2ec37e4b7bbd7f4f751ae9b7730f709c43d0292bb79", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg10-1-1.src.rpm", "7f86347249889174a4bcfa2d20aec471e44275be06484f45a2d1afa4f61d8895", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg10-1-2.src.rpm", "151a800766bfb51b8f414878367f64028f3693dc323a01de2ccc10d96813f302", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg10-1-3.src.rpm", "370e830462c33db0cc11dcaa7f539773a651c1dde980bd1e92db601d85156419", uint64(6125)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg2-1-1.src.rpm", "802c968cd29794edf721fcbc5924a68606df9a0648d89c648481bf77ff89c53c", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg2-1-2.src.rpm", "f26e8390a958c0fd0a15c07cf9ef2f93485b90ec701888013f1453b0946c7c47", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg2-1-3.src.rpm", "07a1e8b441c8e329cb07567bdbd845d833da6721dfc166c3510469f313ebd652", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg3-1-1.src.rpm", "3a557ebe499975f3c7b95e1b39ca3ff10369b51dec045d8f882a0cb587815db4", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg3-1-2.src.rpm", "4ad8107d6a8a9f32c3c2f4971756467ee536979cb246e53a9d238c824df665ea", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg3-1-3.src.rpm", "14b797a378b75c5c6793400f2d2f14b98099ba32b95828686ca7b14c8475d889", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg4-1-1.src.rpm", "7b981767615dd5c739f027bcc17aa91343d36aa5040e59f7614e401a35b2e703", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg4-1-2.src.rpm", "3f55e2dd76104d19baf4148342c0cdc5b0230879cca6c5b13c07f24a25d79a1d", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg4-1-3.src.rpm", "80ea7ece7614339e906e80920a5a5d5bf0881f3e9a0a02ab2831036e67ea4152", uint64(6125)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg5-1-1.src.rpm", "182367519219c7f56c1213350372333219fa0d2f858072f524734308949daf61", uint64(6122)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg5-1-2.src.rpm", "904021dcfd97e54d3c5cbaa7742af844cc5c48adb4af4ba88495db30afd629d9", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg5-1-3.src.rpm", "7b74718b1f01b561f66d04706327269bf67981db6743c46858fe03e2868c6ef5", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg6-1-1.src.rpm", "96e669c98d8d79d0acc77f1d9b3246e6baabf2f49a7591d26ba69740b80574ee", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg6-1-2.src.rpm", "798464bf773513c123183fe00aa350459ec31568e2ee1895d8fef4d6dfbb2e28", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg6-1-3.src.rpm", "d9e1eaa79d2b80349186b3ec51a5331ca400994d9ba0a5fbcd6992fdf2234fcb", uint64(6125)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg7-1-1.src.rpm", "8f76905b96b5476485fca223804a9900c3351f0b61e30f862ebc7e48f1232fca", uint64(6123)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg7-1-2.src.rpm", "263e504fd0be3d6903e03e4b5d3c820c6f06e474253d63bf7951223c3080cc17", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg7-1-3.src.rpm", "c04e4e225556951502e2ce533ac25d26decf63a768013c14bcec32dc60b88837", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg8-1-1.src.rpm", "6b0bb85fe30ae6e406a1dddb2af7126294e24fae64e79be67c426e94f90720ee", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg8-1-2.src.rpm", "cc3fd1c43ea62332e534e0f5d6a7df7f1c808725116109f33fe38453682d5ee7", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg8-1-3.src.rpm", "d5ccf0943d89947bb2f8b3ed8466d60e452f1b0daa881d5d3fe2c8584778883b", uint64(6125)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg9-1-1.src.rpm", "ed76da35a9b4f4ea4e3828f6a978016cc6b4b9c0cd0548f2d4cbd6a695b1f6e9", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg9-1-2.src.rpm", "26dc22dbbbd6569c6d41d7c37b6e8b3d90ec24c76c075bfe8b0016de64bb2029", uint64(6124)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg9-1-3.src.rpm", "869bf9b01e2ea53e02bb8666ca1118e2c9e5cef2598e9a1b1f67125531b3bd8e", uint64(6125)). - Return(ptr.String(""), nil). - Once() - - s.cliMock.On("PublishVersion", defaultNamespace, "container1", "version_id").Return(nil).Once() - - fn := s.svc.CreateVersion(defaultNamespace, "container1", true, ptr.String(""), ptr.String(srv.URL), ptr.String("file://./testdata/gpg/somekey.gpg"), nil) - s.Require().NoError(fn(s.ctx)) -} - -func (s *serviceTestSuite) TestCreateVersionFromYumRepoAndPublishGPGSigned() { - e := echo.New() - e.Use(middleware.Logger()) - e.Use(middleware.Recover()) - e.Static("/", "../yum/testdata/repo-signed") - - srv := httptest.NewServer(e) - defer srv.Close() - - e2 := echo.New() - e2.Use(middleware.Logger()) - e2.Use(middleware.Recover()) - e2.PUT("/upload", func(c echo.Context) error { - if c.Request().Header.Get("Content-Length") != "6115" { - return c.NoContent(http.StatusLengthRequired) - } - - if c.Request().Header.Get("Content-Type") != mimeTypeMultipartFormData { - return c.NoContent(http.StatusUnsupportedMediaType) - } - return nil - }) - - uploadSrv := httptest.NewServer(e2) - defer uploadSrv.Close() - - s.cliMock.On("CreateVersion", defaultNamespace, "container1").Return("version_id", nil, nil).Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/c99064d5c98a01f3720c735431ab1f449c56a1c4e233efd99353716d856c245f-primary.xml.gz", "c99064d5c98a01f3720c735431ab1f449c56a1c4e233efd99353716d856c245f", uint64(718)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/0586c412097e75a9420880bb8256802008e79f2cbe7d7d34cebeb55abce6ad40-primary.sqlite.bz2", "0586c412097e75a9420880bb8256802008e79f2cbe7d7d34cebeb55abce6ad40", uint64(1985)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/64f76a79439371fc632b7cac21b68f322142bc183b706332314e97d1007f8f0c-filelists.xml.gz", "64f76a79439371fc632b7cac21b68f322142bc183b706332314e97d1007f8f0c", uint64(314)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/464b3eff37b3eee86b7e4f78efcf0e8911afa496a57753ac42a67c2afbdd2d48-filelists.sqlite.bz2", "464b3eff37b3eee86b7e4f78efcf0e8911afa496a57753ac42a67c2afbdd2d48", uint64(859)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/4c25d51dbded8086515c32ce5753f7bd22d4b0d0ee9c45d3f580751fbd26e05a-other.xml.gz", "4c25d51dbded8086515c32ce5753f7bd22d4b0d0ee9c45d3f580751fbd26e05a", uint64(282)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/f16e9edf15ee11cb5a79dd9466f58bbe2a481db47cfad8f6287540beda0779f6-other.sqlite.bz2", "f16e9edf15ee11cb5a79dd9466f58bbe2a481db47cfad8f6287540beda0779f6", uint64(743)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "repodata/repomd.xml", "4d207e2d80ec3aefb6f9e08f744f547f7171c94dc451d01fa24fe5c57ffb01a0", uint64(3069)). - Return(ptr.String(""), nil). - Once() - - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "SRPMS/testpkg-1-1.src.rpm", "cbce80483872b31a4b92a9ef0aea11f38e0f06db301781db53ba88a365bffd8e", uint64(6115)). - Return(ptr.String(uploadSrv.URL+"/upload"), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version_id", "RPMS/x86_64/testpkg-1-1.x86_64.rpm", "3ea740db3d27481b38231c9bd987c46bb6bdda480c60fbfcce84d7d88abf5051", uint64(6734)). - Return(ptr.String(""), nil). - Once() - s.cliMock.On("PublishVersion", defaultNamespace, "container1", "version_id").Return(nil).Once() - - fn := s.svc.CreateVersion(defaultNamespace, "container1", true, ptr.String(""), ptr.String(srv.URL), ptr.String("file://./testdata/gpg/somekey.gpg"), nil) + fn := s.svc.CreateVersion(defaultNamespace, "container1", true, s.sourceMock) s.Require().NoError(fn(s.ctx)) } @@ -903,90 +122,6 @@ func (s *serviceTestSuite) TestPublishVersion() { s.Require().NoError(fn(s.ctx)) } -func (s *serviceTestSuite) TestCreateObjectWithoutEndingSlashInThePath() { - s.cacheMock.On("Get", "testdata/repo/somefile1").Return("", nil).Once() - s.cacheMock.On("Get", "testdata/repo/somefile2").Return("", nil).Once() - s.cacheMock.On("Put", "testdata/repo/somefile1", "a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4").Return(nil).Once() - s.cacheMock.On("Put", "testdata/repo/somefile2", "ff5a972ba33179c7ec67c73e00a362b629c489f9d7c86489644db2bcd8c62c61").Return(nil).Once() - - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version1", "somefile1", "a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4", uint64(5)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version1", "somefile2", "ff5a972ba33179c7ec67c73e00a362b629c489f9d7c86489644db2bcd8c62c61", uint64(5)). - Return(ptr.String(""), nil). - Once() - - fn := s.svc.CreateObject(defaultNamespace, "container1", "version1", "testdata/repo") - s.Require().NoError(fn(s.ctx)) -} - -func (s *serviceTestSuite) TestCreateObjectWithEndingSlashInThePath() { - s.cacheMock.On("Get", "testdata/repo/somefile1").Return("", nil).Once() - s.cacheMock.On("Get", "testdata/repo/somefile2").Return("", nil).Once() - s.cacheMock.On("Put", "testdata/repo/somefile1", "a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4").Return(nil).Once() - s.cacheMock.On("Put", "testdata/repo/somefile2", "ff5a972ba33179c7ec67c73e00a362b629c489f9d7c86489644db2bcd8c62c61").Return(nil).Once() - - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version1", "somefile1", "a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4", uint64(5)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version1", "somefile2", "ff5a972ba33179c7ec67c73e00a362b629c489f9d7c86489644db2bcd8c62c61", uint64(5)). - Return(ptr.String(""), nil). - Once() - - fn := s.svc.CreateObject(defaultNamespace, "container1", "version1", "testdata/repo/") - s.Require().NoError(fn(s.ctx)) -} - -func (s *serviceTestSuite) TestCreateObjectWithCache() { - s.cacheMock.On("Get", "testdata/repo/somefile1").Return("a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4", nil).Once() - s.cacheMock.On("Get", "testdata/repo/somefile2").Return("ff5a972ba33179c7ec67c73e00a362b629c489f9d7c86489644db2bcd8c62c61", nil).Once() - - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version1", "somefile1", "a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4", uint64(5)). - Return(ptr.String(""), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version1", "somefile2", "ff5a972ba33179c7ec67c73e00a362b629c489f9d7c86489644db2bcd8c62c61", uint64(5)). - Return(ptr.String(""), nil). - Once() - - fn := s.svc.CreateObject(defaultNamespace, "container1", "version1", "testdata/repo/") - s.Require().NoError(fn(s.ctx)) -} - -func (s *serviceTestSuite) TestCreateObjectWithUploadURL() { - s.cacheMock.On("Get", "testdata/repo/somefile1").Return("a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4", nil).Once() - s.cacheMock.On("Get", "testdata/repo/somefile2").Return("ff5a972ba33179c7ec67c73e00a362b629c489f9d7c86489644db2bcd8c62c61", nil).Once() - - srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { - data, err := io.ReadAll(r.Body) - s.NoError(err) - defer r.Body.Close() - - s.Equal("1234\n", string(data)) - - s.Equal("/test-url", r.RequestURI) - s.Equal(mimeTypeMultipartFormData, r.Header.Get("Content-Type")) - })) - defer srv.Close() - - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version1", "somefile1", "a883dafc480d466ee04e0d6da986bd78eb1fdd2178d04693723da3a8f95d42f4", uint64(5)). - Return(ptr.String(srv.URL+"/test-url"), nil). - Once() - s.cliMock. - On("CreateObject", defaultNamespace, "container1", "version1", "somefile2", "ff5a972ba33179c7ec67c73e00a362b629c489f9d7c86489644db2bcd8c62c61", uint64(5)). - Return(ptr.String(""), nil). - Once() - - fn := s.svc.CreateObject(defaultNamespace, "container1", "version1", "testdata/repo/") - s.Require().NoError(fn(s.ctx)) -} - func (s *serviceTestSuite) TestDeleteObject() { s.cliMock.On("DeleteObject", defaultNamespace, "container1", "version1", "key1").Return(nil).Once() @@ -1012,10 +147,11 @@ func (s *serviceTestSuite) TestGetObjectURL() { type serviceTestSuite struct { suite.Suite - ctx context.Context - cliMock *protoClientMock - cacheMock *cacheMock.Mock - svc Service + ctx context.Context + cliMock *protoClientMock + cacheMock *cacheMock.Mock + svc Service + sourceMock *sourceMock.Mock } func (s *serviceTestSuite) SetupTest() { @@ -1023,6 +159,7 @@ func (s *serviceTestSuite) SetupTest() { s.cliMock = newMock() s.cacheMock = cacheMock.New() + s.sourceMock = sourceMock.New() s.svc = New(s.cliMock, s.cacheMock) } diff --git a/cli/service/source/local/local.go b/cli/service/source/local/local.go new file mode 100644 index 0000000..3f3be66 --- /dev/null +++ b/cli/service/source/local/local.go @@ -0,0 +1,151 @@ +package local + +import ( + "context" + "crypto/sha256" + "encoding/hex" + "io" + "io/fs" + "os" + "path/filepath" + "strings" + + "github.com/pkg/errors" + log "github.com/sirupsen/logrus" + + "github.com/teran/archived/cli/service/source" + cache "github.com/teran/archived/cli/service/stat_cache" +) + +const ( + sourceType = "local" + + processStatusInterval int = 100 +) + +var _ source.Source = (*local)(nil) + +type local struct { + dir string + cache cache.CacheRepository +} + +func New(dir string, c cache.CacheRepository) source.Source { + log.WithFields(log.Fields{ + "dir": dir, + }).Trace("initializing local source ...") + + return &local{ + dir: dir, + cache: c, + } +} + +func (l *local) Process(ctx context.Context, handler func(ctx context.Context, obj source.Object) error) error { + log.WithFields(log.Fields{ + "source_type": sourceType, + "directory": l.dir, + }).Info("scanning directory ...") + + var cnt int + + return filepath.Walk(l.dir, func(path string, info fs.FileInfo, err error) error { + defer func() { cnt++ }() + + if err != nil { + return errors.Wrap(err, "walk: internal error") + } + + if info.IsDir() { + return nil + } + + shortPath := strings.TrimPrefix(path, l.dir) + shortPath = strings.TrimPrefix(shortPath, "/") + size := info.Size() + + log.WithFields(log.Fields{ + "filename": shortPath, + "size": size, + }).Debug("file found") + + log.WithFields(log.Fields{ + "filename": shortPath, + "size": size, + }).Tracef("attempting to retrieve checksum from cache") + + checksum, err := l.cache.Get(ctx, path, info) + if err != nil { + return errors.Wrap(err, "error retrieving checksum from cache") + } + + if checksum == "" { + log.WithFields(log.Fields{ + "filename": shortPath, + "size": size, + }).Debug("generating checksum") + checksum, err = checksumFile(path) + if err != nil { + return errors.Wrap(err, "error calculating file checksum") + } + + err := l.cache.Put(ctx, path, info, checksum) + if err != nil { + log.Warnf("error putting checksum calculation result into cache: %s", err) + } + } + + log.WithFields(log.Fields{ + "filename": shortPath, + "size": size, + "checksum": checksum, + }).Debug("checksum") + + fp, err := os.Open(path) + if err != nil { + return errors.Wrap(err, "error opening file") + } + defer fp.Close() + + if err := handler(ctx, source.Object{ + Path: shortPath, + Contents: fp, + SHA256: checksum, + Size: uint64(size), + }); err != nil { + return err + } + + if cnt%processStatusInterval == 0 { + log.WithFields(log.Fields{ + "directory": l.dir, + }).Infof("%d files processed ...", cnt+1) + } + + return nil + }) +} + +func checksumFile(filename string) (string, error) { + info, err := os.Stat(filename) + if err != nil { + return "", errors.Wrap(err, "error performing stat on file") + } + fp, err := os.Open(filename) + if err != nil { + return "", errors.Wrap(err, "error opening file") + } + defer fp.Close() + + h := sha256.New() + n, err := io.Copy(h, fp) + if err != nil { + return "", errors.Wrap(err, "error reading file") + } + + if n != info.Size() { + return "", errors.Errorf("file size is %d bytes while only %d was copied: early EOF", info.Size(), n) + } + + return hex.EncodeToString(h.Sum(nil)), nil +} diff --git a/cli/service/source/local/local_test.go b/cli/service/source/local/local_test.go new file mode 100644 index 0000000..c8bf79b --- /dev/null +++ b/cli/service/source/local/local_test.go @@ -0,0 +1,65 @@ +package local + +import ( + "context" + "testing" + + log "github.com/sirupsen/logrus" + "github.com/stretchr/testify/require" + + "github.com/teran/archived/cli/service/source" + "github.com/teran/archived/cli/service/source/mock" + statCacheMock "github.com/teran/archived/cli/service/stat_cache/mock" +) + +func init() { + log.SetLevel(log.TraceLevel) +} + +func TestChecksumFile(t *testing.T) { + r := require.New(t) + + cs, err := checksumFile("testdata/checksum/test_file.txt") + r.NoError(err) + r.Equal("0c15e883dee85bb2f3540a47ec58f617a2547117f9096417ba5422268029f501", cs) +} + +func TestSource(t *testing.T) { + r := require.New(t) + ctx := context.TODO() + + statCache := statCacheMock.New() + defer statCache.AssertExpectations(t) + + statCache.On("Get", "testdata/dir/some_file1.txt").Return("", nil).Once() + statCache.On("Put", "testdata/dir/some_file1.txt", "cb330beb8590577eb619d75183b14ac85d6b30a6777e8041d6c2d8a44888e7f1").Return(nil).Once() + + statCache.On("Get", "testdata/dir/some_file2.txt").Return("", nil).Once() + statCache.On("Put", "testdata/dir/some_file2.txt", "e45fbded5effe3178f7ca393f0228fb6799ead901c8a5b1354d6f1c44c2a8fa7").Return(nil).Once() + + statCache.On("Get", "testdata/dir/some_dir/some_file3.txt").Return("", nil).Once() + statCache.On("Put", "testdata/dir/some_dir/some_file3.txt", "94630c0572bba1a7dcc8e69a70ffbaaf132fc7f67f0c40416b73d53c10d9aa7a").Return(nil).Once() + + handle := new(handlerMock) + defer handle.AssertExpectations(t) + + handle.On("Handle", "some_file1.txt", uint64(18), "cb330beb8590577eb619d75183b14ac85d6b30a6777e8041d6c2d8a44888e7f1").Return(nil).Once() + handle.On("Handle", "some_file2.txt", uint64(18), "e45fbded5effe3178f7ca393f0228fb6799ead901c8a5b1354d6f1c44c2a8fa7").Return(nil).Once() + handle.On("Handle", "some_dir/some_file3.txt", uint64(18), "94630c0572bba1a7dcc8e69a70ffbaaf132fc7f67f0c40416b73d53c10d9aa7a").Return(nil).Once() + + s := New("testdata/dir", statCache) + + err := s.Process(ctx, func(ctx context.Context, obj source.Object) error { + return handle.Handle(obj) + }) + r.NoError(err) +} + +type handlerMock struct { + mock.Mock +} + +func (m *handlerMock) Handle(obj source.Object) error { + args := m.Called(obj.Path, obj.Size, obj.SHA256) + return args.Error(0) +} diff --git a/cli/service/source/local/testdata/checksum/test_file.txt b/cli/service/source/local/testdata/checksum/test_file.txt new file mode 100644 index 0000000..082b346 --- /dev/null +++ b/cli/service/source/local/testdata/checksum/test_file.txt @@ -0,0 +1 @@ +test data diff --git a/cli/service/source/local/testdata/dir/some_dir/some_file3.txt b/cli/service/source/local/testdata/dir/some_dir/some_file3.txt new file mode 100644 index 0000000..f3cd689 --- /dev/null +++ b/cli/service/source/local/testdata/dir/some_dir/some_file3.txt @@ -0,0 +1 @@ +test data file #3 diff --git a/cli/service/source/local/testdata/dir/some_file1.txt b/cli/service/source/local/testdata/dir/some_file1.txt new file mode 100644 index 0000000..42ee78a --- /dev/null +++ b/cli/service/source/local/testdata/dir/some_file1.txt @@ -0,0 +1 @@ +test data file #1 diff --git a/cli/service/source/local/testdata/dir/some_file2.txt b/cli/service/source/local/testdata/dir/some_file2.txt new file mode 100644 index 0000000..87928ea --- /dev/null +++ b/cli/service/source/local/testdata/dir/some_file2.txt @@ -0,0 +1 @@ +test data file #2 diff --git a/cli/service/source/mock/mock.go b/cli/service/source/mock/mock.go new file mode 100644 index 0000000..1481c4e --- /dev/null +++ b/cli/service/source/mock/mock.go @@ -0,0 +1,23 @@ +package mock + +import ( + "context" + + "github.com/teran/archived/cli/service/source" + "github.com/teran/archived/cli/service/stat_cache/mock" +) + +var _ source.Source = (*Mock)(nil) + +type Mock struct { + mock.Mock +} + +func New() *Mock { + return &Mock{} +} + +func (m *Mock) Process(ctx context.Context, handler func(ctx context.Context, obj source.Object) error) error { + args := m.Called() + return args.Error(0) +} diff --git a/cli/service/source/source.go b/cli/service/source/source.go new file mode 100644 index 0000000..c149638 --- /dev/null +++ b/cli/service/source/source.go @@ -0,0 +1,17 @@ +package source + +import ( + "context" + "io" +) + +type Object struct { + Path string + Contents io.Reader + SHA256 string + Size uint64 +} + +type Source interface { + Process(ctx context.Context, handler func(ctx context.Context, obj Object) error) error +} diff --git a/cli/service/source/yum/gpg.go b/cli/service/source/yum/gpg.go new file mode 100644 index 0000000..66b7e58 --- /dev/null +++ b/cli/service/source/yum/gpg.go @@ -0,0 +1,78 @@ +package yum + +import ( + "bytes" + "context" + "crypto/sha256" + "encoding/hex" + "io" + "net/http" + "os" + "strings" + + "github.com/ProtonMail/go-crypto/openpgp" + "github.com/pkg/errors" + log "github.com/sirupsen/logrus" +) + +func getGPGKey(ctx context.Context, filepath string, checksum *string) (openpgp.EntityList, error) { + p := strings.SplitN(filepath, "://", 2) + if len(p) != 2 { + return nil, errors.New("unexpected public key file path format. Please use file:///path/to/file.gpg or http://example.com/file.gpg") + } + + var data []byte + switch p[0] { + case "file": + fp, err := os.Open(p[1]) + if err != nil { + return nil, errors.Wrap(err, "error opening public key file") + } + defer fp.Close() + + data, err = io.ReadAll(fp) + if err != nil { + return nil, errors.Wrap(err, "error reading public key file") + } + case "http", "https": + req, err := http.NewRequestWithContext(ctx, http.MethodGet, filepath, nil) + if err != nil { + return nil, errors.Wrap(err, "error constructing HTTP request object") + } + + resp, err := http.DefaultClient.Do(req) + if err != nil { + return nil, errors.Wrap(err, "error performing HTTP request") + } + defer resp.Body.Close() + + data, err = io.ReadAll(resp.Body) + if err != nil { + return nil, errors.Wrap(err, "error reading public key data") + } + default: + return nil, errors.Errorf("unsupported key file access scheme: `%s`", p[0]) + } + + if checksum != nil && *checksum != "" { + h := sha256.New() + n, err := h.Write(data) + if err != nil { + return nil, errors.Wrap(err, "error calculating SHA256") + } + + if n != len(data) { + return nil, errors.Wrap(io.ErrShortWrite, "error writing data to hasher") + } + + if *checksum != hex.EncodeToString(h.Sum(nil)) { + return nil, errors.New("GPG Key checksum mismatch") + } + + log.WithFields(log.Fields{ + "sha256": *checksum, + }).Infof("GPG key checksum verified") + } + + return openpgp.ReadArmoredKeyRing(bytes.NewReader(data)) +} diff --git a/cli/service/source/yum/gpg_test.go b/cli/service/source/yum/gpg_test.go new file mode 100644 index 0000000..df3e772 --- /dev/null +++ b/cli/service/source/yum/gpg_test.go @@ -0,0 +1,127 @@ +package yum + +import ( + "context" + "net/http" + "net/http/httptest" + "os" + "testing" + + "github.com/ProtonMail/go-crypto/openpgp" + echo "github.com/labstack/echo/v4" + "github.com/labstack/echo/v4/middleware" + "github.com/stretchr/testify/require" + ptr "github.com/teran/go-ptr" + + "github.com/teran/archived/repositories/blob/mock" +) + +func TestGetGPGKey(t *testing.T) { + ctx := context.TODO() + + m := &testHandlerMock{} + defer m.AssertExpectations(t) + + data, err := os.ReadFile("./testdata/gpg/somekey.gpg") + if err != nil { + t.Fatal(err) + } + + m.On("StaticFile", "/").Return(http.StatusOK, "text/plain", data).Twice() + + e := echo.New() + e.Use(middleware.Logger()) + e.Use(middleware.Recover()) + e.GET("/*", m.StaticFile) + + srv := httptest.NewServer(e) + defer srv.Close() + + type testCase struct { + name string + url string + keyChecksum *string + expKeyIDs []uint64 + expErrorText *string + } + + tcs := []testCase{ + { + name: "read from file", + url: "file://./testdata/gpg/somekey.gpg", + expKeyIDs: []uint64{11127004574349501168}, + }, + { + name: "read form HTTP URL", + url: srv.URL, + expKeyIDs: []uint64{11127004574349501168}, + }, + { + name: "read from file w/ checksum", + url: "file://./testdata/gpg/somekey.gpg", + keyChecksum: ptr.String("aa392a2005c38f10ce21034d6d1aaace5bbee1c3d98ac1ee06a42336d741473e"), + expKeyIDs: []uint64{11127004574349501168}, + }, + { + name: "read form HTTP URL w/ checksum", + url: srv.URL, + keyChecksum: ptr.String("aa392a2005c38f10ce21034d6d1aaace5bbee1c3d98ac1ee06a42336d741473e"), + expKeyIDs: []uint64{11127004574349501168}, + }, + { + name: "incorrect scheme", + expErrorText: ptr.String( + "unexpected public key file path format. Please use file:///path/to/file.gpg or http://example.com/file.gpg"), + }, + { + name: "unknown scheme", + url: "ftp://example.com/file.gpg", + expErrorText: ptr.String( + "unsupported key file access scheme: `ftp`"), + }, + { + name: "read from file w/ incorrect checksum", + url: "file://./testdata/gpg/somekey.gpg", + keyChecksum: ptr.String("deadbeef"), + expKeyIDs: []uint64{11127004574349501168}, + expErrorText: ptr.String("GPG Key checksum mismatch"), + }, + { + name: "read form HTTP URL w/ incorrect checksum", + url: srv.URL, + keyChecksum: ptr.String("deadbeef"), + expKeyIDs: []uint64{11127004574349501168}, + expErrorText: ptr.String("GPG Key checksum mismatch"), + }, + } + + for _, tc := range tcs { + t.Run(tc.name, func(t *testing.T) { + r := require.New(t) + + keys, err := getGPGKey(ctx, tc.url, tc.keyChecksum) + if tc.expErrorText != nil { + r.Error(err) + r.Equal(*tc.expErrorText, err.Error()) + } else { + r.NoError(err) + r.Equal(tc.expKeyIDs, func(el openpgp.EntityList) []uint64 { + keyIDs := []uint64{} + for _, key := range el { + keyIDs = append(keyIDs, key.PrimaryKey.KeyId) + } + return keyIDs + }(keys)) + } + }) + } +} + +type testHandlerMock struct { + mock.Mock +} + +func (m *testHandlerMock) StaticFile(c echo.Context) error { + args := m.Called(c.Request().RequestURI) + return c.Blob(args.Int(0), args.String(1), args.Get(2).([]byte)) +} diff --git a/cli/service/source/yum/testdata/gpg/somekey.gpg b/cli/service/source/yum/testdata/gpg/somekey.gpg new file mode 100644 index 0000000..be4bdfc --- /dev/null +++ b/cli/service/source/yum/testdata/gpg/somekey.gpg @@ -0,0 +1,41 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQGNBGbB/X4BDADY6EzI0/+PfX4zsxK/jtMV0gzR2xAMlrc3TwIEaHPu7NMMakQv +br22/kQuBsUbgAdSo1HZlcpdaMLvMYHRBoMtxo33RxrTfT7kx57yEIXP2ggbiQtW +JaZ0rF8ro2QSrtmMyof8bRgBhlr4VTxl17hSpGl8oXAhYCUeR+Np51qfXU5RbUtf +8qoFJgxI4QCb/Zwhf9FP5JGRLudCuQx0AvZ7jJXBZ1pH19SPhhl9sMa/kBCMmCz6 +wwIVNNN7tanYGHIA1LJcqwKasyEkDVRtZ5Opts4eiUcJm+nGZj+McdC5sOJ7h0Ft +dxBnlAJTFCyXRnnfdViHBTE8mHmWkcqH+Nz7fU8qKwsj8yQByRo7oOhAmy5pTjzO +0kUXPMG72mZJwm7lET2pDhvLK+20uJzNkSqTHtyxKB7SlUsrbNsnXE0li4N7YqkV +0MqXrL9C/UQhOQs75anBDhygNX4C83bv9yKunlGpRm/1g/ZPA1dBgWnCVFC7ibM4 +X0LJq+zM0r168D8AEQEAAbQuYXJjaGl2ZWQgdGVzdCByZXBvc2l0b3J5IHNhbXBs +ZSA8bWVAdGVyYW4uZGV2PokB2AQTAQgAQhYhBLCj3lTbmHOx27ETgJprD7T8P6Lw +BQJmwf1+AhsDBQkDwmcABQsJCAcCAyICAQYVCgkICwIEFgIDAQIeBwIXgAAKCRCa +aw+0/D+i8JtUDACx4GCYnLUI/wGmeZ3ZjgA8X04Eb9VeZwrJmSV2kfO45ngPnh1r +/SnjMSkvLPCJgE1PYYNAoDYTlQyn5vIftHBRcJ2t3YdhCKPZDvG9zLzhQM/k0xRo +CGHYKAjJaG85S7R6Q+2hr8K5o/NDQYH9zIGsb+vI8zS3T2Ek6cWIJvK6A1DMJq59 +7xdsrXeKNtuTqbr5DSBKqf9/zMsrc3vlULGNw/GRkQxW104jVxbXa9MZfdf9sDAi +6tyKrQ5dmZl48Yxv0vXPMo3tjrOd41J0sRg0AaMeXTo7pO71alx+GSA7g+4ZEG2j +IE1RQHnKV9gQvlVzK8noSJ4DHL4vzSo62o+YelSC53h4yF/yiPBNGqrOhw3svRjL +vXaapU7wm7f7QBkXWVUWS1BdOJL5xOF+IG3j8Y/OeaQXuO4OISM7EAwRmtj4grFz +EtMHJcPkccbitiYa6GwNeV0Dda0lM/CWSZighhnebU3GRCgq8Lpue0Au+ChZhFKK +tIyQ17s4OF4yAZe5AY0EZsH9fgEMAMD89OATBkOArC1OWB/DDPu74C1oP86BA6Ai +TRj2dj/kYARYPvjiAIfEE0/iMwNwKGKbNL0bXC8UKdQFd9iC8RoS9QUMysWXb8Fa +GSR+gERwGVJHTDkF8tZvd3YSct7iyiQeFXYApMhbB/25AgBYNYbeYAzqgUHhsyBu +yZdbRm1IwTupojCLfjHpUY7G4gl86Nuo2CeEE1ThjuSppjh1+MgDKWzAQFMTiIqr +9N2DqIgWpXpQNGJwmWeyuWrCFJrSrxB0O3UVQxclgov7GYRTI35Gi82y0Aesdq0m +HgEbIsk8FWR7is6pUcyLm/shNmNt6butCDd+DHcOSGpwCN2oTqlYI1B6TsOFnOeN +EnFGvwzTr67EvqsAhFd8SHJUnpumK6ZYMERwwzGE/wGu3qLRmVTAzWeqP4QMHeK5 +GvUYoujkUePCJbcKhq3evmDa9xnnR0rucMgWAQmH4cuXMPzm0Ab+xgKsy0UDrDKK +N+P8pDVZtcs4my6fBX9yGzsyTWgaIQARAQABiQG8BBgBCAAmFiEEsKPeVNuYc7Hb +sROAmmsPtPw/ovAFAmbB/X4CGwwFCQPCZwAACgkQmmsPtPw/ovDp7AwAq+O1uY06 +K9Hbgl8Y+5M4TTHf1aRJfDbkqHP/5+SN+1HOH9B7+7pSSaKLUvCRAxnsVfth+f/P +y2dkzcwnfpQ2uDYPNop2dlataW3+wIeD/n2sVo5k0HG0wX6XKixpmkjBdhniCqFg +QmANqeC922I6K9X5kPgXSQNYZCb4i/Bohwd6x8sWRxI7jZkxNPSo52Si6grP15zm +SortrZ6hxgGg/zqDlf/eayd+xfLeKi2LXCre2R4o1hbCLc9Sws8v1l66Y1yTw2hi +oJ2Pcdzsoq9GfNDMKTgheHcgPTSg/CdbbQJFc2BQYixHbQdJsbkG+p0mjlXLP8LN +q+ovP//pMmo82iEfV2CznOvsvBuNe3PJVrgSxzOvFAh+S2Pe6z/YMxTTie1Y9Aap +oTU0pkSqpS4mJ0Mp3ekHj2aGXW9jjPACf1gMFNd0CP1g3lvY+MFojhxqxe86ayya +ype7H70abzIWxSHU2FocDyU8UjmnKdfG/53R+H0iUV09I+uj6Os+D33g +=DV6E +-----END PGP PUBLIC KEY BLOCK----- diff --git a/cli/yum/testdata/repo-sha1/Packages/testpkg-1-1.src.rpm b/cli/service/source/yum/testdata/repo-sha1/Packages/testpkg-1-1.src.rpm similarity index 100% rename from cli/yum/testdata/repo-sha1/Packages/testpkg-1-1.src.rpm rename to cli/service/source/yum/testdata/repo-sha1/Packages/testpkg-1-1.src.rpm diff --git a/cli/yum/testdata/repo-sha1/Packages/testpkg-1-1.x86_64.rpm b/cli/service/source/yum/testdata/repo-sha1/Packages/testpkg-1-1.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo-sha1/Packages/testpkg-1-1.x86_64.rpm rename to cli/service/source/yum/testdata/repo-sha1/Packages/testpkg-1-1.x86_64.rpm diff --git a/cli/yum/testdata/repo-sha1/repodata/4a11e3eeb25d21b08f41e5578d702d2bea21a2e7-filelists.xml.gz b/cli/service/source/yum/testdata/repo-sha1/repodata/4a11e3eeb25d21b08f41e5578d702d2bea21a2e7-filelists.xml.gz similarity index 100% rename from cli/yum/testdata/repo-sha1/repodata/4a11e3eeb25d21b08f41e5578d702d2bea21a2e7-filelists.xml.gz rename to cli/service/source/yum/testdata/repo-sha1/repodata/4a11e3eeb25d21b08f41e5578d702d2bea21a2e7-filelists.xml.gz diff --git a/cli/yum/testdata/repo-sha1/repodata/80779e2ab55e25a77124d370de1d08deae8f1cc6-primary.xml.gz b/cli/service/source/yum/testdata/repo-sha1/repodata/80779e2ab55e25a77124d370de1d08deae8f1cc6-primary.xml.gz similarity index 100% rename from cli/yum/testdata/repo-sha1/repodata/80779e2ab55e25a77124d370de1d08deae8f1cc6-primary.xml.gz rename to cli/service/source/yum/testdata/repo-sha1/repodata/80779e2ab55e25a77124d370de1d08deae8f1cc6-primary.xml.gz diff --git a/cli/yum/testdata/repo-sha1/repodata/b31561a27d014d35b59b27c27859bb1c17ac573e-other.sqlite.bz2 b/cli/service/source/yum/testdata/repo-sha1/repodata/b31561a27d014d35b59b27c27859bb1c17ac573e-other.sqlite.bz2 similarity index 100% rename from cli/yum/testdata/repo-sha1/repodata/b31561a27d014d35b59b27c27859bb1c17ac573e-other.sqlite.bz2 rename to cli/service/source/yum/testdata/repo-sha1/repodata/b31561a27d014d35b59b27c27859bb1c17ac573e-other.sqlite.bz2 diff --git a/cli/yum/testdata/repo-sha1/repodata/c66ce2caa41ed83879f9b3dd9f40e61c65af499e-filelists.sqlite.bz2 b/cli/service/source/yum/testdata/repo-sha1/repodata/c66ce2caa41ed83879f9b3dd9f40e61c65af499e-filelists.sqlite.bz2 similarity index 100% rename from cli/yum/testdata/repo-sha1/repodata/c66ce2caa41ed83879f9b3dd9f40e61c65af499e-filelists.sqlite.bz2 rename to cli/service/source/yum/testdata/repo-sha1/repodata/c66ce2caa41ed83879f9b3dd9f40e61c65af499e-filelists.sqlite.bz2 diff --git a/cli/yum/testdata/repo-sha1/repodata/e7a8a53e7398f6c22894718ea227fea60f2b78ba-primary.sqlite.bz2 b/cli/service/source/yum/testdata/repo-sha1/repodata/e7a8a53e7398f6c22894718ea227fea60f2b78ba-primary.sqlite.bz2 similarity index 100% rename from cli/yum/testdata/repo-sha1/repodata/e7a8a53e7398f6c22894718ea227fea60f2b78ba-primary.sqlite.bz2 rename to cli/service/source/yum/testdata/repo-sha1/repodata/e7a8a53e7398f6c22894718ea227fea60f2b78ba-primary.sqlite.bz2 diff --git a/cli/yum/testdata/repo-sha1/repodata/fdedb6ce109127d52228d01b0239010ddca14c8f-other.xml.gz b/cli/service/source/yum/testdata/repo-sha1/repodata/fdedb6ce109127d52228d01b0239010ddca14c8f-other.xml.gz similarity index 100% rename from cli/yum/testdata/repo-sha1/repodata/fdedb6ce109127d52228d01b0239010ddca14c8f-other.xml.gz rename to cli/service/source/yum/testdata/repo-sha1/repodata/fdedb6ce109127d52228d01b0239010ddca14c8f-other.xml.gz diff --git a/cli/yum/testdata/repo-sha1/repodata/repomd.xml b/cli/service/source/yum/testdata/repo-sha1/repodata/repomd.xml similarity index 100% rename from cli/yum/testdata/repo-sha1/repodata/repomd.xml rename to cli/service/source/yum/testdata/repo-sha1/repodata/repomd.xml diff --git a/cli/yum/testdata/repo-signed/RPMS/x86_64/testpkg-1-1.x86_64.rpm b/cli/service/source/yum/testdata/repo-signed/RPMS/x86_64/testpkg-1-1.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo-signed/RPMS/x86_64/testpkg-1-1.x86_64.rpm rename to cli/service/source/yum/testdata/repo-signed/RPMS/x86_64/testpkg-1-1.x86_64.rpm diff --git a/cli/yum/testdata/repo-signed/SRPMS/testpkg-1-1.src.rpm b/cli/service/source/yum/testdata/repo-signed/SRPMS/testpkg-1-1.src.rpm similarity index 100% rename from cli/yum/testdata/repo-signed/SRPMS/testpkg-1-1.src.rpm rename to cli/service/source/yum/testdata/repo-signed/SRPMS/testpkg-1-1.src.rpm diff --git a/cli/yum/testdata/repo-signed/repodata/0586c412097e75a9420880bb8256802008e79f2cbe7d7d34cebeb55abce6ad40-primary.sqlite.bz2 b/cli/service/source/yum/testdata/repo-signed/repodata/0586c412097e75a9420880bb8256802008e79f2cbe7d7d34cebeb55abce6ad40-primary.sqlite.bz2 similarity index 100% rename from cli/yum/testdata/repo-signed/repodata/0586c412097e75a9420880bb8256802008e79f2cbe7d7d34cebeb55abce6ad40-primary.sqlite.bz2 rename to cli/service/source/yum/testdata/repo-signed/repodata/0586c412097e75a9420880bb8256802008e79f2cbe7d7d34cebeb55abce6ad40-primary.sqlite.bz2 diff --git a/cli/yum/testdata/repo-signed/repodata/464b3eff37b3eee86b7e4f78efcf0e8911afa496a57753ac42a67c2afbdd2d48-filelists.sqlite.bz2 b/cli/service/source/yum/testdata/repo-signed/repodata/464b3eff37b3eee86b7e4f78efcf0e8911afa496a57753ac42a67c2afbdd2d48-filelists.sqlite.bz2 similarity index 100% rename from cli/yum/testdata/repo-signed/repodata/464b3eff37b3eee86b7e4f78efcf0e8911afa496a57753ac42a67c2afbdd2d48-filelists.sqlite.bz2 rename to cli/service/source/yum/testdata/repo-signed/repodata/464b3eff37b3eee86b7e4f78efcf0e8911afa496a57753ac42a67c2afbdd2d48-filelists.sqlite.bz2 diff --git a/cli/yum/testdata/repo-signed/repodata/4c25d51dbded8086515c32ce5753f7bd22d4b0d0ee9c45d3f580751fbd26e05a-other.xml.gz b/cli/service/source/yum/testdata/repo-signed/repodata/4c25d51dbded8086515c32ce5753f7bd22d4b0d0ee9c45d3f580751fbd26e05a-other.xml.gz similarity index 100% rename from cli/yum/testdata/repo-signed/repodata/4c25d51dbded8086515c32ce5753f7bd22d4b0d0ee9c45d3f580751fbd26e05a-other.xml.gz rename to cli/service/source/yum/testdata/repo-signed/repodata/4c25d51dbded8086515c32ce5753f7bd22d4b0d0ee9c45d3f580751fbd26e05a-other.xml.gz diff --git a/cli/yum/testdata/repo-signed/repodata/64f76a79439371fc632b7cac21b68f322142bc183b706332314e97d1007f8f0c-filelists.xml.gz b/cli/service/source/yum/testdata/repo-signed/repodata/64f76a79439371fc632b7cac21b68f322142bc183b706332314e97d1007f8f0c-filelists.xml.gz similarity index 100% rename from cli/yum/testdata/repo-signed/repodata/64f76a79439371fc632b7cac21b68f322142bc183b706332314e97d1007f8f0c-filelists.xml.gz rename to cli/service/source/yum/testdata/repo-signed/repodata/64f76a79439371fc632b7cac21b68f322142bc183b706332314e97d1007f8f0c-filelists.xml.gz diff --git a/cli/yum/testdata/repo-signed/repodata/c99064d5c98a01f3720c735431ab1f449c56a1c4e233efd99353716d856c245f-primary.xml.gz b/cli/service/source/yum/testdata/repo-signed/repodata/c99064d5c98a01f3720c735431ab1f449c56a1c4e233efd99353716d856c245f-primary.xml.gz similarity index 100% rename from cli/yum/testdata/repo-signed/repodata/c99064d5c98a01f3720c735431ab1f449c56a1c4e233efd99353716d856c245f-primary.xml.gz rename to cli/service/source/yum/testdata/repo-signed/repodata/c99064d5c98a01f3720c735431ab1f449c56a1c4e233efd99353716d856c245f-primary.xml.gz diff --git a/cli/yum/testdata/repo-signed/repodata/f16e9edf15ee11cb5a79dd9466f58bbe2a481db47cfad8f6287540beda0779f6-other.sqlite.bz2 b/cli/service/source/yum/testdata/repo-signed/repodata/f16e9edf15ee11cb5a79dd9466f58bbe2a481db47cfad8f6287540beda0779f6-other.sqlite.bz2 similarity index 100% rename from cli/yum/testdata/repo-signed/repodata/f16e9edf15ee11cb5a79dd9466f58bbe2a481db47cfad8f6287540beda0779f6-other.sqlite.bz2 rename to cli/service/source/yum/testdata/repo-signed/repodata/f16e9edf15ee11cb5a79dd9466f58bbe2a481db47cfad8f6287540beda0779f6-other.sqlite.bz2 diff --git a/cli/yum/testdata/repo-signed/repodata/repomd.xml b/cli/service/source/yum/testdata/repo-signed/repodata/repomd.xml similarity index 100% rename from cli/yum/testdata/repo-signed/repodata/repomd.xml rename to cli/service/source/yum/testdata/repo-signed/repodata/repomd.xml diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg1-1-1.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg1-1-1.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg1-1-1.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg1-1-1.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg1-1-2.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg1-1-2.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg1-1-2.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg1-1-2.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg1-1-3.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg1-1-3.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg1-1-3.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg1-1-3.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg10-1-1.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg10-1-1.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg10-1-1.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg10-1-1.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg10-1-2.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg10-1-2.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg10-1-2.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg10-1-2.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg10-1-3.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg10-1-3.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg10-1-3.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg10-1-3.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg2-1-1.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg2-1-1.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg2-1-1.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg2-1-1.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg2-1-2.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg2-1-2.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg2-1-2.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg2-1-2.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg2-1-3.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg2-1-3.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg2-1-3.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg2-1-3.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg3-1-1.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg3-1-1.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg3-1-1.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg3-1-1.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg3-1-2.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg3-1-2.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg3-1-2.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg3-1-2.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg3-1-3.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg3-1-3.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg3-1-3.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg3-1-3.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg4-1-1.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg4-1-1.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg4-1-1.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg4-1-1.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg4-1-2.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg4-1-2.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg4-1-2.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg4-1-2.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg4-1-3.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg4-1-3.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg4-1-3.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg4-1-3.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg5-1-1.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg5-1-1.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg5-1-1.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg5-1-1.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg5-1-2.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg5-1-2.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg5-1-2.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg5-1-2.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg5-1-3.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg5-1-3.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg5-1-3.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg5-1-3.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg6-1-1.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg6-1-1.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg6-1-1.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg6-1-1.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg6-1-2.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg6-1-2.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg6-1-2.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg6-1-2.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg6-1-3.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg6-1-3.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg6-1-3.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg6-1-3.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg7-1-1.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg7-1-1.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg7-1-1.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg7-1-1.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg7-1-2.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg7-1-2.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg7-1-2.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg7-1-2.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg7-1-3.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg7-1-3.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg7-1-3.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg7-1-3.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg8-1-1.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg8-1-1.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg8-1-1.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg8-1-1.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg8-1-2.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg8-1-2.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg8-1-2.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg8-1-2.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg8-1-3.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg8-1-3.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg8-1-3.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg8-1-3.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg9-1-1.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg9-1-1.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg9-1-1.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg9-1-1.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg9-1-2.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg9-1-2.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg9-1-2.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg9-1-2.x86_64.rpm diff --git a/cli/yum/testdata/repo/RPMS/x86_64/testpkg9-1-3.x86_64.rpm b/cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg9-1-3.x86_64.rpm similarity index 100% rename from cli/yum/testdata/repo/RPMS/x86_64/testpkg9-1-3.x86_64.rpm rename to cli/service/source/yum/testdata/repo/RPMS/x86_64/testpkg9-1-3.x86_64.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg1-1-1.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg1-1-1.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg1-1-1.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg1-1-1.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg1-1-2.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg1-1-2.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg1-1-2.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg1-1-2.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg1-1-3.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg1-1-3.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg1-1-3.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg1-1-3.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg10-1-1.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg10-1-1.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg10-1-1.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg10-1-1.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg10-1-2.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg10-1-2.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg10-1-2.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg10-1-2.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg10-1-3.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg10-1-3.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg10-1-3.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg10-1-3.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg2-1-1.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg2-1-1.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg2-1-1.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg2-1-1.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg2-1-2.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg2-1-2.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg2-1-2.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg2-1-2.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg2-1-3.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg2-1-3.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg2-1-3.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg2-1-3.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg3-1-1.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg3-1-1.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg3-1-1.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg3-1-1.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg3-1-2.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg3-1-2.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg3-1-2.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg3-1-2.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg3-1-3.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg3-1-3.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg3-1-3.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg3-1-3.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg4-1-1.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg4-1-1.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg4-1-1.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg4-1-1.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg4-1-2.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg4-1-2.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg4-1-2.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg4-1-2.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg4-1-3.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg4-1-3.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg4-1-3.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg4-1-3.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg5-1-1.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg5-1-1.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg5-1-1.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg5-1-1.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg5-1-2.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg5-1-2.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg5-1-2.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg5-1-2.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg5-1-3.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg5-1-3.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg5-1-3.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg5-1-3.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg6-1-1.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg6-1-1.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg6-1-1.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg6-1-1.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg6-1-2.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg6-1-2.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg6-1-2.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg6-1-2.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg6-1-3.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg6-1-3.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg6-1-3.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg6-1-3.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg7-1-1.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg7-1-1.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg7-1-1.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg7-1-1.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg7-1-2.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg7-1-2.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg7-1-2.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg7-1-2.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg7-1-3.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg7-1-3.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg7-1-3.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg7-1-3.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg8-1-1.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg8-1-1.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg8-1-1.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg8-1-1.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg8-1-2.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg8-1-2.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg8-1-2.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg8-1-2.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg8-1-3.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg8-1-3.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg8-1-3.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg8-1-3.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg9-1-1.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg9-1-1.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg9-1-1.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg9-1-1.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg9-1-2.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg9-1-2.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg9-1-2.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg9-1-2.src.rpm diff --git a/cli/yum/testdata/repo/SRPMS/testpkg9-1-3.src.rpm b/cli/service/source/yum/testdata/repo/SRPMS/testpkg9-1-3.src.rpm similarity index 100% rename from cli/yum/testdata/repo/SRPMS/testpkg9-1-3.src.rpm rename to cli/service/source/yum/testdata/repo/SRPMS/testpkg9-1-3.src.rpm diff --git a/cli/yum/testdata/repo/repodata/12fd2c7242e8f946c5a99b40acc94e297144685022f23f08f5d4932a37387053-primary.xml.gz b/cli/service/source/yum/testdata/repo/repodata/12fd2c7242e8f946c5a99b40acc94e297144685022f23f08f5d4932a37387053-primary.xml.gz similarity index 100% rename from cli/yum/testdata/repo/repodata/12fd2c7242e8f946c5a99b40acc94e297144685022f23f08f5d4932a37387053-primary.xml.gz rename to cli/service/source/yum/testdata/repo/repodata/12fd2c7242e8f946c5a99b40acc94e297144685022f23f08f5d4932a37387053-primary.xml.gz diff --git a/cli/yum/testdata/repo/repodata/27c7a0b93802b0173730c713cf74c0ac80e402880e3a87f12c5dc3efcfa0ec32-other.sqlite.bz2 b/cli/service/source/yum/testdata/repo/repodata/27c7a0b93802b0173730c713cf74c0ac80e402880e3a87f12c5dc3efcfa0ec32-other.sqlite.bz2 similarity index 100% rename from cli/yum/testdata/repo/repodata/27c7a0b93802b0173730c713cf74c0ac80e402880e3a87f12c5dc3efcfa0ec32-other.sqlite.bz2 rename to cli/service/source/yum/testdata/repo/repodata/27c7a0b93802b0173730c713cf74c0ac80e402880e3a87f12c5dc3efcfa0ec32-other.sqlite.bz2 diff --git a/cli/yum/testdata/repo/repodata/3228a79e4328e912dc272ea29a6e627187e4d1ecdb41c39f17e67b0a4f1ea1a5-primary.sqlite.bz2 b/cli/service/source/yum/testdata/repo/repodata/3228a79e4328e912dc272ea29a6e627187e4d1ecdb41c39f17e67b0a4f1ea1a5-primary.sqlite.bz2 similarity index 100% rename from cli/yum/testdata/repo/repodata/3228a79e4328e912dc272ea29a6e627187e4d1ecdb41c39f17e67b0a4f1ea1a5-primary.sqlite.bz2 rename to cli/service/source/yum/testdata/repo/repodata/3228a79e4328e912dc272ea29a6e627187e4d1ecdb41c39f17e67b0a4f1ea1a5-primary.sqlite.bz2 diff --git a/cli/yum/testdata/repo/repodata/3af4f502859773f9b5b5a3b8033f8561f01b270414cabb3b46612703c85d731f-other.xml.gz b/cli/service/source/yum/testdata/repo/repodata/3af4f502859773f9b5b5a3b8033f8561f01b270414cabb3b46612703c85d731f-other.xml.gz similarity index 100% rename from cli/yum/testdata/repo/repodata/3af4f502859773f9b5b5a3b8033f8561f01b270414cabb3b46612703c85d731f-other.xml.gz rename to cli/service/source/yum/testdata/repo/repodata/3af4f502859773f9b5b5a3b8033f8561f01b270414cabb3b46612703c85d731f-other.xml.gz diff --git a/cli/yum/testdata/repo/repodata/a362c47ae86d8ee5f6e623fcb09e309d5b701316fe356e7642fa24ca47610c52-filelists.sqlite.bz2 b/cli/service/source/yum/testdata/repo/repodata/a362c47ae86d8ee5f6e623fcb09e309d5b701316fe356e7642fa24ca47610c52-filelists.sqlite.bz2 similarity index 100% rename from cli/yum/testdata/repo/repodata/a362c47ae86d8ee5f6e623fcb09e309d5b701316fe356e7642fa24ca47610c52-filelists.sqlite.bz2 rename to cli/service/source/yum/testdata/repo/repodata/a362c47ae86d8ee5f6e623fcb09e309d5b701316fe356e7642fa24ca47610c52-filelists.sqlite.bz2 diff --git a/cli/yum/testdata/repo/repodata/f47c809e5e0589800a672ee64fd4f4fd7bc71152596bcf8ebcd6a582d40ca9dd-filelists.xml.gz b/cli/service/source/yum/testdata/repo/repodata/f47c809e5e0589800a672ee64fd4f4fd7bc71152596bcf8ebcd6a582d40ca9dd-filelists.xml.gz similarity index 100% rename from cli/yum/testdata/repo/repodata/f47c809e5e0589800a672ee64fd4f4fd7bc71152596bcf8ebcd6a582d40ca9dd-filelists.xml.gz rename to cli/service/source/yum/testdata/repo/repodata/f47c809e5e0589800a672ee64fd4f4fd7bc71152596bcf8ebcd6a582d40ca9dd-filelists.xml.gz diff --git a/cli/yum/testdata/repo/repodata/repomd.xml b/cli/service/source/yum/testdata/repo/repodata/repomd.xml similarity index 100% rename from cli/yum/testdata/repo/repodata/repomd.xml rename to cli/service/source/yum/testdata/repo/repodata/repomd.xml diff --git a/cli/service/source/yum/utils.go b/cli/service/source/yum/utils.go new file mode 100644 index 0000000..fa4e525 --- /dev/null +++ b/cli/service/source/yum/utils.go @@ -0,0 +1,34 @@ +package yum + +import ( + "crypto/sha256" + "encoding/hex" + "io" + "os" + + "github.com/pkg/errors" +) + +func checksumFile(filename string) (string, error) { + info, err := os.Stat(filename) + if err != nil { + return "", errors.Wrap(err, "error performing stat on file") + } + fp, err := os.Open(filename) + if err != nil { + return "", errors.Wrap(err, "error opening file") + } + defer fp.Close() + + h := sha256.New() + n, err := io.Copy(h, fp) + if err != nil { + return "", errors.Wrap(err, "error reading file") + } + + if n != info.Size() { + return "", errors.Errorf("file size is %d bytes while only %d was copied: early EOF", info.Size(), n) + } + + return hex.EncodeToString(h.Sum(nil)), nil +} diff --git a/cli/service/source/yum/utils_test.go b/cli/service/source/yum/utils_test.go new file mode 100644 index 0000000..3ce26ba --- /dev/null +++ b/cli/service/source/yum/utils_test.go @@ -0,0 +1,23 @@ +package yum + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +func TestChecksumFile(t *testing.T) { + r := require.New(t) + + sha256, err := checksumFile("testdata/gpg/somekey.gpg") + r.NoError(err) + r.Equal("aa392a2005c38f10ce21034d6d1aaace5bbee1c3d98ac1ee06a42336d741473e", sha256) +} + +func TestChecksumFileNotExistent(t *testing.T) { + r := require.New(t) + + _, err := checksumFile("testdata/gpg/not-existent.gpg") + r.Error(err) + r.Equal("error performing stat on file: stat testdata/gpg/not-existent.gpg: no such file or directory", err.Error()) +} diff --git a/cli/service/source/yum/yum.go b/cli/service/source/yum/yum.go new file mode 100644 index 0000000..90eff17 --- /dev/null +++ b/cli/service/source/yum/yum.go @@ -0,0 +1,175 @@ +package yum + +import ( + "bytes" + "context" + "crypto/sha256" + "encoding/hex" + "io" + "os" + "strings" + + "github.com/ProtonMail/go-crypto/openpgp" + "github.com/pkg/errors" + "github.com/sassoftware/go-rpmutils" + log "github.com/sirupsen/logrus" + + "github.com/teran/archived/cli/lazyblob" + "github.com/teran/archived/cli/service/source" + yum "github.com/teran/archived/cli/service/source/yum/yum_repo" +) + +const processStatusInterval = 100 + +var ( + _ source.Source = (*repository)(nil) + + ErrFileNotFound = errors.New("file not found") +) + +type repository struct { + repo yum.YumRepo + repoURL string + rpmGPGKeyURL *string + rpmGPGKeySHA256 *string +} + +func New(repoURL string, rpmGPGKeyURL, rpmGPGKeySHA256 *string) source.Source { + log.WithFields(log.Fields{ + "url": repoURL, + "gpg_key_url": rpmGPGKeyURL, + "gpg_key_sha256": rpmGPGKeySHA256, + }).Trace("initializing YUM source ...") + + return &repository{ + repo: yum.New(repoURL), + repoURL: repoURL, + rpmGPGKeyURL: rpmGPGKeyURL, + rpmGPGKeySHA256: rpmGPGKeySHA256, + } +} + +func (r *repository) Process(ctx context.Context, handler func(ctx context.Context, obj source.Object) error) error { + log.WithFields(log.Fields{ + "repository_url": r.repoURL, + }).Info("running creating version from YUM repository ...") + + packages, err := r.repo.Packages(ctx) + if err != nil { + return errors.Wrap(err, "error getting repository data") + } + + var gpgKeyring openpgp.EntityList = nil + + if r.rpmGPGKeyURL != nil && *r.rpmGPGKeyURL != "" { + log.Tracef("RPM GPG Key was passed so initialing GPG keyring ...") + gpgKeyring, err = getGPGKey(ctx, *r.rpmGPGKeyURL, r.rpmGPGKeySHA256) + if err != nil { + return err + } + } + + log.WithFields(log.Fields{ + "repository_url": r.repoURL, + }).Info("handling YUM repository metadata files ...") + for k, v := range r.repo.Metadata() { + size := len(v) + + hasher := sha256.New() + n, err := hasher.Write(v) + if err != nil { + return err + } + + if n != size { + return io.ErrShortWrite + } + + checksum := hex.EncodeToString(hasher.Sum(nil)) + + log.Tracef("handler(%s, %s, %d)", k, checksum, size) + if err := handler(ctx, source.Object{ + Path: k, + Contents: bytes.NewReader(v), + SHA256: checksum, + Size: uint64(size), + }); err != nil { + return errors.Wrap(err, "error calling object handler") + } + } + + log.WithFields(log.Fields{ + "repository_url": r.repoURL, + "packages_count": len(packages), + }).Info("handling package files ...") + + for cnt, pkg := range packages { + log.WithFields(log.Fields{ + "name": pkg.Name, + "checksum": pkg.Checksum, + "path": strings.TrimSuffix(r.repoURL, "/") + "/" + strings.TrimPrefix(pkg.Name, "/"), + "size": pkg.Size, + }).Trace("processing package ...") + + err := func(name, checksum, sourceURL string, size uint64) error { + lb := lazyblob.New(sourceURL, os.TempDir(), size) + defer func() { + if err := lb.Close(); err != nil { + log.Warnf("error removing scratch data: %s", err) + } + }() + + if pkg.ChecksumType != "sha256" { + filename, err := lb.Filename(ctx) + if err != nil { + return errors.Wrap(err, "error getting package filename") + } + + checksum, err = checksumFile(filename) + if err != nil { + return errors.Wrap(err, "error calculating checksum") + } + } + + fp, err := lb.Reader(ctx) + if err != nil { + return errors.Wrap(err, "error getting object reader") + } + + _, sigs, err := rpmutils.Verify(fp, gpgKeyring) + if err != nil { + return errors.Wrapf(err, "error verifying package signature: %s", name) + } + + if len(sigs) == 0 { + log.Warnf("package `%s` does not contain signature", name) + } + + fp, err = lb.Reader(ctx) + if err != nil { + return errors.Wrap(err, "error getting object reader") + } + + if err := handler(ctx, source.Object{ + Path: name, + Contents: fp, + SHA256: checksum, + Size: size, + }); err != nil { + return errors.Wrap(err, "error calling object handler") + } + + if cnt%processStatusInterval == 0 { + log.WithFields(log.Fields{ + "repository_url": r.repoURL, + }).Infof("%d files processed ...", cnt+1) + } + + return nil + }(pkg.Name, pkg.Checksum, strings.TrimSuffix(r.repoURL, "/")+"/"+strings.TrimPrefix(pkg.Name, "/"), pkg.Size) + if err != nil { + return err + } + } + return nil +} diff --git a/cli/yum/README.md b/cli/service/source/yum/yum_repo/README.md similarity index 100% rename from cli/yum/README.md rename to cli/service/source/yum/yum_repo/README.md diff --git a/cli/yum/mirrorlist/mirrorlist.go b/cli/service/source/yum/yum_repo/mirrorlist/mirrorlist.go similarity index 98% rename from cli/yum/mirrorlist/mirrorlist.go rename to cli/service/source/yum/yum_repo/mirrorlist/mirrorlist.go index 4c70945..5d19377 100644 --- a/cli/yum/mirrorlist/mirrorlist.go +++ b/cli/service/source/yum/yum_repo/mirrorlist/mirrorlist.go @@ -7,8 +7,8 @@ import ( "net/http" "strings" - "github.com/labstack/gommon/log" "github.com/pkg/errors" + log "github.com/sirupsen/logrus" ) type Mirrorlist interface { diff --git a/cli/yum/mirrorlist/mirrorlist_test.go b/cli/service/source/yum/yum_repo/mirrorlist/mirrorlist_test.go similarity index 100% rename from cli/yum/mirrorlist/mirrorlist_test.go rename to cli/service/source/yum/yum_repo/mirrorlist/mirrorlist_test.go diff --git a/cli/yum/models/packages.go b/cli/service/source/yum/yum_repo/models/packages.go similarity index 100% rename from cli/yum/models/packages.go rename to cli/service/source/yum/yum_repo/models/packages.go diff --git a/cli/yum/models/primarymd.go b/cli/service/source/yum/yum_repo/models/primarymd.go similarity index 100% rename from cli/yum/models/primarymd.go rename to cli/service/source/yum/yum_repo/models/primarymd.go diff --git a/cli/yum/models/repomd.go b/cli/service/source/yum/yum_repo/models/repomd.go similarity index 100% rename from cli/yum/models/repomd.go rename to cli/service/source/yum/yum_repo/models/repomd.go diff --git a/cli/service/source/yum/yum_repo/testdata/repo-sha1/Packages/testpkg-1-1.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo-sha1/Packages/testpkg-1-1.src.rpm new file mode 100644 index 0000000..6b82ce9 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo-sha1/Packages/testpkg-1-1.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo-sha1/Packages/testpkg-1-1.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo-sha1/Packages/testpkg-1-1.x86_64.rpm new file mode 100644 index 0000000..42da835 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo-sha1/Packages/testpkg-1-1.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/4a11e3eeb25d21b08f41e5578d702d2bea21a2e7-filelists.xml.gz b/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/4a11e3eeb25d21b08f41e5578d702d2bea21a2e7-filelists.xml.gz new file mode 100644 index 0000000..560d9c5 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/4a11e3eeb25d21b08f41e5578d702d2bea21a2e7-filelists.xml.gz differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/80779e2ab55e25a77124d370de1d08deae8f1cc6-primary.xml.gz b/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/80779e2ab55e25a77124d370de1d08deae8f1cc6-primary.xml.gz new file mode 100644 index 0000000..035f301 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/80779e2ab55e25a77124d370de1d08deae8f1cc6-primary.xml.gz differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/b31561a27d014d35b59b27c27859bb1c17ac573e-other.sqlite.bz2 b/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/b31561a27d014d35b59b27c27859bb1c17ac573e-other.sqlite.bz2 new file mode 100644 index 0000000..42b37e7 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/b31561a27d014d35b59b27c27859bb1c17ac573e-other.sqlite.bz2 differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/c66ce2caa41ed83879f9b3dd9f40e61c65af499e-filelists.sqlite.bz2 b/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/c66ce2caa41ed83879f9b3dd9f40e61c65af499e-filelists.sqlite.bz2 new file mode 100644 index 0000000..cb0a597 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/c66ce2caa41ed83879f9b3dd9f40e61c65af499e-filelists.sqlite.bz2 differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/e7a8a53e7398f6c22894718ea227fea60f2b78ba-primary.sqlite.bz2 b/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/e7a8a53e7398f6c22894718ea227fea60f2b78ba-primary.sqlite.bz2 new file mode 100644 index 0000000..1705454 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/e7a8a53e7398f6c22894718ea227fea60f2b78ba-primary.sqlite.bz2 differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/fdedb6ce109127d52228d01b0239010ddca14c8f-other.xml.gz b/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/fdedb6ce109127d52228d01b0239010ddca14c8f-other.xml.gz new file mode 100644 index 0000000..0c159de Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/fdedb6ce109127d52228d01b0239010ddca14c8f-other.xml.gz differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/repomd.xml b/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/repomd.xml new file mode 100644 index 0000000..d4d9fed --- /dev/null +++ b/cli/service/source/yum/yum_repo/testdata/repo-sha1/repodata/repomd.xml @@ -0,0 +1,55 @@ + + + 1723748954 + + 80779e2ab55e25a77124d370de1d08deae8f1cc6 + 5f05d943af6b59a3a4b432b76eb417862335a35f + + 1723748954 + 688 + 2096 + + + 4a11e3eeb25d21b08f41e5578d702d2bea21a2e7 + c183131be21f5f7c5ddd9706c59e0589bf91a770 + + 1723748954 + 282 + 465 + + + fdedb6ce109127d52228d01b0239010ddca14c8f + d2838f0858a8a20576d663f9996b586272e6e6b7 + + 1723748954 + 247 + 394 + + + e7a8a53e7398f6c22894718ea227fea60f2b78ba + aa51549db14b4d21b28f426cf93fd25142aeedab + + 1723748954 + 1937 + 106496 + 10 + + + c66ce2caa41ed83879f9b3dd9f40e61c65af499e + 5d2cc3bac662e0dbea5a034cf99e236b1d9affcf + + 1723748954 + 787 + 28672 + 10 + + + b31561a27d014d35b59b27c27859bb1c17ac573e + 2dddccb3427bb9b2d5d81a3ae4b2e6668c57f651 + + 1723748954 + 669 + 24576 + 10 + + diff --git a/cli/service/source/yum/yum_repo/testdata/repo-signed/RPMS/x86_64/testpkg-1-1.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo-signed/RPMS/x86_64/testpkg-1-1.x86_64.rpm new file mode 100644 index 0000000..c1c1806 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo-signed/RPMS/x86_64/testpkg-1-1.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo-signed/SRPMS/testpkg-1-1.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo-signed/SRPMS/testpkg-1-1.src.rpm new file mode 100644 index 0000000..bd83186 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo-signed/SRPMS/testpkg-1-1.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/0586c412097e75a9420880bb8256802008e79f2cbe7d7d34cebeb55abce6ad40-primary.sqlite.bz2 b/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/0586c412097e75a9420880bb8256802008e79f2cbe7d7d34cebeb55abce6ad40-primary.sqlite.bz2 new file mode 100644 index 0000000..4d8c7fc Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/0586c412097e75a9420880bb8256802008e79f2cbe7d7d34cebeb55abce6ad40-primary.sqlite.bz2 differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/464b3eff37b3eee86b7e4f78efcf0e8911afa496a57753ac42a67c2afbdd2d48-filelists.sqlite.bz2 b/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/464b3eff37b3eee86b7e4f78efcf0e8911afa496a57753ac42a67c2afbdd2d48-filelists.sqlite.bz2 new file mode 100644 index 0000000..bbb7f06 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/464b3eff37b3eee86b7e4f78efcf0e8911afa496a57753ac42a67c2afbdd2d48-filelists.sqlite.bz2 differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/4c25d51dbded8086515c32ce5753f7bd22d4b0d0ee9c45d3f580751fbd26e05a-other.xml.gz b/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/4c25d51dbded8086515c32ce5753f7bd22d4b0d0ee9c45d3f580751fbd26e05a-other.xml.gz new file mode 100644 index 0000000..8e325df Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/4c25d51dbded8086515c32ce5753f7bd22d4b0d0ee9c45d3f580751fbd26e05a-other.xml.gz differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/64f76a79439371fc632b7cac21b68f322142bc183b706332314e97d1007f8f0c-filelists.xml.gz b/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/64f76a79439371fc632b7cac21b68f322142bc183b706332314e97d1007f8f0c-filelists.xml.gz new file mode 100644 index 0000000..0ec4d93 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/64f76a79439371fc632b7cac21b68f322142bc183b706332314e97d1007f8f0c-filelists.xml.gz differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/c99064d5c98a01f3720c735431ab1f449c56a1c4e233efd99353716d856c245f-primary.xml.gz b/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/c99064d5c98a01f3720c735431ab1f449c56a1c4e233efd99353716d856c245f-primary.xml.gz new file mode 100644 index 0000000..39ab29e Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/c99064d5c98a01f3720c735431ab1f449c56a1c4e233efd99353716d856c245f-primary.xml.gz differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/f16e9edf15ee11cb5a79dd9466f58bbe2a481db47cfad8f6287540beda0779f6-other.sqlite.bz2 b/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/f16e9edf15ee11cb5a79dd9466f58bbe2a481db47cfad8f6287540beda0779f6-other.sqlite.bz2 new file mode 100644 index 0000000..610326b Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/f16e9edf15ee11cb5a79dd9466f58bbe2a481db47cfad8f6287540beda0779f6-other.sqlite.bz2 differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/repomd.xml b/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/repomd.xml new file mode 100644 index 0000000..c5075c2 --- /dev/null +++ b/cli/service/source/yum/yum_repo/testdata/repo-signed/repodata/repomd.xml @@ -0,0 +1,55 @@ + + + 1723990826 + + c99064d5c98a01f3720c735431ab1f449c56a1c4e233efd99353716d856c245f + 28cdc729e15f2869c655e87d4dc4d0f5a7d73000456ef469a0c9676f73cd7e60 + + 1723990826 + 718 + 2134 + + + 64f76a79439371fc632b7cac21b68f322142bc183b706332314e97d1007f8f0c + faba64fb9bf3aef0b8db23555f8d5c3808f718f6c21b08022e648a88c5b8ec75 + + 1723990826 + 314 + 513 + + + 4c25d51dbded8086515c32ce5753f7bd22d4b0d0ee9c45d3f580751fbd26e05a + bc8c9289c9a6619affee0f23d75f35ce8ceec63f61259269ab450db389bdfa8f + + 1723990826 + 282 + 442 + + + 0586c412097e75a9420880bb8256802008e79f2cbe7d7d34cebeb55abce6ad40 + 9583ed783f7ea07a4d8765aefd06b03be0e3320948c2f821b07b917990abf3d3 + + 1723990826 + 1985 + 106496 + 10 + + + 464b3eff37b3eee86b7e4f78efcf0e8911afa496a57753ac42a67c2afbdd2d48 + db74eec925446cb538de265886293b4b2cb73e0b67e1f917bd80e8cf18e8f8a0 + + 1723990826 + 859 + 28672 + 10 + + + f16e9edf15ee11cb5a79dd9466f58bbe2a481db47cfad8f6287540beda0779f6 + 23304cf8cfcc2abf8d4fd0b4eccc3bf39caef0f67ca2511ec2ffa8e64bce3249 + + 1723990826 + 743 + 24576 + 10 + + diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg1-1-1.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg1-1-1.x86_64.rpm new file mode 100644 index 0000000..8384000 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg1-1-1.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg1-1-2.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg1-1-2.x86_64.rpm new file mode 100644 index 0000000..7b41c88 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg1-1-2.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg1-1-3.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg1-1-3.x86_64.rpm new file mode 100644 index 0000000..0c75120 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg1-1-3.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg10-1-1.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg10-1-1.x86_64.rpm new file mode 100644 index 0000000..e66e5d1 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg10-1-1.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg10-1-2.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg10-1-2.x86_64.rpm new file mode 100644 index 0000000..60d97dd Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg10-1-2.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg10-1-3.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg10-1-3.x86_64.rpm new file mode 100644 index 0000000..95ff8ca Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg10-1-3.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg2-1-1.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg2-1-1.x86_64.rpm new file mode 100644 index 0000000..f7bddff Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg2-1-1.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg2-1-2.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg2-1-2.x86_64.rpm new file mode 100644 index 0000000..48c10c7 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg2-1-2.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg2-1-3.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg2-1-3.x86_64.rpm new file mode 100644 index 0000000..a454690 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg2-1-3.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg3-1-1.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg3-1-1.x86_64.rpm new file mode 100644 index 0000000..309eb22 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg3-1-1.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg3-1-2.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg3-1-2.x86_64.rpm new file mode 100644 index 0000000..fdcd379 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg3-1-2.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg3-1-3.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg3-1-3.x86_64.rpm new file mode 100644 index 0000000..2f5f359 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg3-1-3.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg4-1-1.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg4-1-1.x86_64.rpm new file mode 100644 index 0000000..3a0c214 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg4-1-1.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg4-1-2.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg4-1-2.x86_64.rpm new file mode 100644 index 0000000..1cc31e6 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg4-1-2.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg4-1-3.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg4-1-3.x86_64.rpm new file mode 100644 index 0000000..2fdbb46 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg4-1-3.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg5-1-1.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg5-1-1.x86_64.rpm new file mode 100644 index 0000000..42efd23 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg5-1-1.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg5-1-2.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg5-1-2.x86_64.rpm new file mode 100644 index 0000000..a9fd933 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg5-1-2.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg5-1-3.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg5-1-3.x86_64.rpm new file mode 100644 index 0000000..624ce5b Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg5-1-3.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg6-1-1.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg6-1-1.x86_64.rpm new file mode 100644 index 0000000..0965268 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg6-1-1.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg6-1-2.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg6-1-2.x86_64.rpm new file mode 100644 index 0000000..3a65e7b Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg6-1-2.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg6-1-3.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg6-1-3.x86_64.rpm new file mode 100644 index 0000000..860a626 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg6-1-3.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg7-1-1.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg7-1-1.x86_64.rpm new file mode 100644 index 0000000..b8d9191 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg7-1-1.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg7-1-2.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg7-1-2.x86_64.rpm new file mode 100644 index 0000000..4ea5fa6 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg7-1-2.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg7-1-3.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg7-1-3.x86_64.rpm new file mode 100644 index 0000000..bf6bcc4 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg7-1-3.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg8-1-1.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg8-1-1.x86_64.rpm new file mode 100644 index 0000000..89045ad Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg8-1-1.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg8-1-2.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg8-1-2.x86_64.rpm new file mode 100644 index 0000000..0673118 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg8-1-2.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg8-1-3.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg8-1-3.x86_64.rpm new file mode 100644 index 0000000..d9a56b0 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg8-1-3.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg9-1-1.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg9-1-1.x86_64.rpm new file mode 100644 index 0000000..2062bbd Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg9-1-1.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg9-1-2.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg9-1-2.x86_64.rpm new file mode 100644 index 0000000..21f45a7 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg9-1-2.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg9-1-3.x86_64.rpm b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg9-1-3.x86_64.rpm new file mode 100644 index 0000000..075f9f8 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/RPMS/x86_64/testpkg9-1-3.x86_64.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg1-1-1.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg1-1-1.src.rpm new file mode 100644 index 0000000..ca55414 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg1-1-1.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg1-1-2.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg1-1-2.src.rpm new file mode 100644 index 0000000..ec0126e Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg1-1-2.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg1-1-3.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg1-1-3.src.rpm new file mode 100644 index 0000000..440dbaf Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg1-1-3.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg10-1-1.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg10-1-1.src.rpm new file mode 100644 index 0000000..9d5d46c Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg10-1-1.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg10-1-2.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg10-1-2.src.rpm new file mode 100644 index 0000000..1e67c0f Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg10-1-2.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg10-1-3.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg10-1-3.src.rpm new file mode 100644 index 0000000..c913ffa Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg10-1-3.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg2-1-1.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg2-1-1.src.rpm new file mode 100644 index 0000000..138abd6 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg2-1-1.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg2-1-2.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg2-1-2.src.rpm new file mode 100644 index 0000000..b906b79 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg2-1-2.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg2-1-3.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg2-1-3.src.rpm new file mode 100644 index 0000000..36e2770 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg2-1-3.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg3-1-1.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg3-1-1.src.rpm new file mode 100644 index 0000000..8e31773 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg3-1-1.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg3-1-2.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg3-1-2.src.rpm new file mode 100644 index 0000000..ce6507c Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg3-1-2.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg3-1-3.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg3-1-3.src.rpm new file mode 100644 index 0000000..5df70ed Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg3-1-3.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg4-1-1.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg4-1-1.src.rpm new file mode 100644 index 0000000..b7b1c53 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg4-1-1.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg4-1-2.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg4-1-2.src.rpm new file mode 100644 index 0000000..6f18341 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg4-1-2.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg4-1-3.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg4-1-3.src.rpm new file mode 100644 index 0000000..c6f2b63 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg4-1-3.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg5-1-1.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg5-1-1.src.rpm new file mode 100644 index 0000000..9851e09 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg5-1-1.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg5-1-2.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg5-1-2.src.rpm new file mode 100644 index 0000000..9fa8e8c Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg5-1-2.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg5-1-3.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg5-1-3.src.rpm new file mode 100644 index 0000000..8367399 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg5-1-3.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg6-1-1.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg6-1-1.src.rpm new file mode 100644 index 0000000..04f3c53 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg6-1-1.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg6-1-2.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg6-1-2.src.rpm new file mode 100644 index 0000000..84988a1 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg6-1-2.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg6-1-3.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg6-1-3.src.rpm new file mode 100644 index 0000000..28df2b5 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg6-1-3.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg7-1-1.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg7-1-1.src.rpm new file mode 100644 index 0000000..d4b9530 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg7-1-1.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg7-1-2.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg7-1-2.src.rpm new file mode 100644 index 0000000..88bf9f8 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg7-1-2.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg7-1-3.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg7-1-3.src.rpm new file mode 100644 index 0000000..e6c9df4 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg7-1-3.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg8-1-1.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg8-1-1.src.rpm new file mode 100644 index 0000000..4945cfa Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg8-1-1.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg8-1-2.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg8-1-2.src.rpm new file mode 100644 index 0000000..5f7d3b7 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg8-1-2.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg8-1-3.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg8-1-3.src.rpm new file mode 100644 index 0000000..5fe2ac7 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg8-1-3.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg9-1-1.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg9-1-1.src.rpm new file mode 100644 index 0000000..25f5673 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg9-1-1.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg9-1-2.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg9-1-2.src.rpm new file mode 100644 index 0000000..bf3b724 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg9-1-2.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg9-1-3.src.rpm b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg9-1-3.src.rpm new file mode 100644 index 0000000..0d088ed Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/SRPMS/testpkg9-1-3.src.rpm differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/repodata/12fd2c7242e8f946c5a99b40acc94e297144685022f23f08f5d4932a37387053-primary.xml.gz b/cli/service/source/yum/yum_repo/testdata/repo/repodata/12fd2c7242e8f946c5a99b40acc94e297144685022f23f08f5d4932a37387053-primary.xml.gz new file mode 100644 index 0000000..0f7d106 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/repodata/12fd2c7242e8f946c5a99b40acc94e297144685022f23f08f5d4932a37387053-primary.xml.gz differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/repodata/27c7a0b93802b0173730c713cf74c0ac80e402880e3a87f12c5dc3efcfa0ec32-other.sqlite.bz2 b/cli/service/source/yum/yum_repo/testdata/repo/repodata/27c7a0b93802b0173730c713cf74c0ac80e402880e3a87f12c5dc3efcfa0ec32-other.sqlite.bz2 new file mode 100644 index 0000000..dcafd4d Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/repodata/27c7a0b93802b0173730c713cf74c0ac80e402880e3a87f12c5dc3efcfa0ec32-other.sqlite.bz2 differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/repodata/3228a79e4328e912dc272ea29a6e627187e4d1ecdb41c39f17e67b0a4f1ea1a5-primary.sqlite.bz2 b/cli/service/source/yum/yum_repo/testdata/repo/repodata/3228a79e4328e912dc272ea29a6e627187e4d1ecdb41c39f17e67b0a4f1ea1a5-primary.sqlite.bz2 new file mode 100644 index 0000000..229e5ea Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/repodata/3228a79e4328e912dc272ea29a6e627187e4d1ecdb41c39f17e67b0a4f1ea1a5-primary.sqlite.bz2 differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/repodata/3af4f502859773f9b5b5a3b8033f8561f01b270414cabb3b46612703c85d731f-other.xml.gz b/cli/service/source/yum/yum_repo/testdata/repo/repodata/3af4f502859773f9b5b5a3b8033f8561f01b270414cabb3b46612703c85d731f-other.xml.gz new file mode 100644 index 0000000..64ea301 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/repodata/3af4f502859773f9b5b5a3b8033f8561f01b270414cabb3b46612703c85d731f-other.xml.gz differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/repodata/a362c47ae86d8ee5f6e623fcb09e309d5b701316fe356e7642fa24ca47610c52-filelists.sqlite.bz2 b/cli/service/source/yum/yum_repo/testdata/repo/repodata/a362c47ae86d8ee5f6e623fcb09e309d5b701316fe356e7642fa24ca47610c52-filelists.sqlite.bz2 new file mode 100644 index 0000000..7e9de65 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/repodata/a362c47ae86d8ee5f6e623fcb09e309d5b701316fe356e7642fa24ca47610c52-filelists.sqlite.bz2 differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/repodata/f47c809e5e0589800a672ee64fd4f4fd7bc71152596bcf8ebcd6a582d40ca9dd-filelists.xml.gz b/cli/service/source/yum/yum_repo/testdata/repo/repodata/f47c809e5e0589800a672ee64fd4f4fd7bc71152596bcf8ebcd6a582d40ca9dd-filelists.xml.gz new file mode 100644 index 0000000..60be9c0 Binary files /dev/null and b/cli/service/source/yum/yum_repo/testdata/repo/repodata/f47c809e5e0589800a672ee64fd4f4fd7bc71152596bcf8ebcd6a582d40ca9dd-filelists.xml.gz differ diff --git a/cli/service/source/yum/yum_repo/testdata/repo/repodata/repomd.xml b/cli/service/source/yum/yum_repo/testdata/repo/repodata/repomd.xml new file mode 100644 index 0000000..d523279 --- /dev/null +++ b/cli/service/source/yum/yum_repo/testdata/repo/repodata/repomd.xml @@ -0,0 +1,55 @@ + + + 1724586932 + + 12fd2c7242e8f946c5a99b40acc94e297144685022f23f08f5d4932a37387053 + 19eaf72d65b6569c7a48db679fe3ad4f1b192feeacffd621aa680ab3eddf7908 + + 1724586932 + 4550 + 59442 + + + f47c809e5e0589800a672ee64fd4f4fd7bc71152596bcf8ebcd6a582d40ca9dd + be118981c8d338cd0d9c438a4d02d738176e9425658a5de27953eab1c2e271ac + + 1724586932 + 3000 + 11865 + + + 3af4f502859773f9b5b5a3b8033f8561f01b270414cabb3b46612703c85d731f + e6cec808ab4fbf19593584f6e6ba864c97444b19a04aea84d8db23bf15bcce53 + + 1724586932 + 2848 + 9818 + + + 3228a79e4328e912dc272ea29a6e627187e4d1ecdb41c39f17e67b0a4f1ea1a5 + 32c96f8cd06748ed11291b6af3b760355b5968cb3b4569f14c5830fa3c1b3e1e + + 1724586932 + 9036 + 131072 + 10 + + + a362c47ae86d8ee5f6e623fcb09e309d5b701316fe356e7642fa24ca47610c52 + 480736c13a3be24e6f9794f88c027bf15439d6b1dc8561c60ceac2c2e63a6cb8 + + 1724586932 + 5554 + 45056 + 10 + + + 27c7a0b93802b0173730c713cf74c0ac80e402880e3a87f12c5dc3efcfa0ec32 + a627da6d535abd2d69d8795e22350f6daf7fa03c5320f7137fa23f9fd2ed58e2 + + 1724586932 + 4351 + 40960 + 10 + + diff --git a/cli/yum/yum.go b/cli/service/source/yum/yum_repo/yum.go similarity index 97% rename from cli/yum/yum.go rename to cli/service/source/yum/yum_repo/yum.go index 74db4e8..abb8fd1 100644 --- a/cli/yum/yum.go +++ b/cli/service/source/yum/yum_repo/yum.go @@ -19,7 +19,7 @@ import ( "github.com/pkg/errors" log "github.com/sirupsen/logrus" - "github.com/teran/archived/cli/yum/models" + "github.com/teran/archived/cli/service/source/yum/yum_repo/models" ) var ( @@ -48,7 +48,7 @@ type yumRepo struct { metadata map[string][]byte } -func New(url string) *yumRepo { +func New(url string) YumRepo { return &yumRepo{ url: strings.TrimSuffix(url, "/"), metadata: make(map[string][]byte), diff --git a/cli/yum/yum_test.go b/cli/service/source/yum/yum_repo/yum_test.go similarity index 99% rename from cli/yum/yum_test.go rename to cli/service/source/yum/yum_repo/yum_test.go index c074848..9fb0703 100644 --- a/cli/yum/yum_test.go +++ b/cli/service/source/yum/yum_repo/yum_test.go @@ -12,7 +12,8 @@ import ( "github.com/labstack/echo/v4/middleware" log "github.com/sirupsen/logrus" "github.com/stretchr/testify/require" - "github.com/teran/archived/cli/yum/models" + + "github.com/teran/archived/cli/service/source/yum/yum_repo/models" ) func init() { diff --git a/cli/service/source/yum/yum_test.go b/cli/service/source/yum/yum_test.go new file mode 100644 index 0000000..7196c48 --- /dev/null +++ b/cli/service/source/yum/yum_test.go @@ -0,0 +1,123 @@ +package yum + +import ( + "context" + "net/http/httptest" + "testing" + + echo "github.com/labstack/echo/v4" + "github.com/labstack/echo/v4/middleware" + "github.com/stretchr/testify/suite" + "github.com/teran/archived/cli/service/source" + ptr "github.com/teran/go-ptr" +) + +func (s *yumTestSuite) TestRepo() { + result := []source.Object{} + + repo := New(s.srv.URL+"/repo/", nil, nil) + err := repo.Process(s.ctx, func(ctx context.Context, obj source.Object) error { + result = append(result, obj) + return nil + }) + s.Require().NoError(err) + s.Require().Len(result, 67) +} + +func (s *yumTestSuite) TestRepoWithGPGKey() { + result := []source.Object{} + + repo := New(s.srv.URL+"/repo-signed/", ptr.String(s.srv.URL+"/gpg/somekey.gpg"), nil) + err := repo.Process(s.ctx, func(ctx context.Context, obj source.Object) error { + result = append(result, obj) + return nil + }) + s.Require().NoError(err) + s.Require().Len(result, 9) +} + +func (s *yumTestSuite) TestRepoWithGPGKeyAndChecksum() { + result := []source.Object{} + + repo := New( + s.srv.URL+"/repo-signed/", + ptr.String(s.srv.URL+"/gpg/somekey.gpg"), + ptr.String("aa392a2005c38f10ce21034d6d1aaace5bbee1c3d98ac1ee06a42336d741473e"), + ) + err := repo.Process(s.ctx, func(ctx context.Context, obj source.Object) error { + result = append(result, obj) + return nil + }) + s.Require().NoError(err) + s.Require().Len(result, 9) +} + +func (s *yumTestSuite) TestRepoWithGPGKeyAndInvalidChecksum() { + result := []source.Object{} + + repo := New( + s.srv.URL+"/repo-signed/", + ptr.String(s.srv.URL+"/gpg/somekey.gpg"), + ptr.String("invalid"), + ) + err := repo.Process(s.ctx, func(ctx context.Context, obj source.Object) error { + result = append(result, obj) + return nil + }) + s.Require().Error(err) + s.Require().Equal( + "GPG Key checksum mismatch", + err.Error(), + ) +} + +func (s *yumTestSuite) TestRepoSHA1() { + result := []source.Object{} + + repo := New(s.srv.URL+"/repo/", nil, nil) + err := repo.Process(s.ctx, func(ctx context.Context, obj source.Object) error { + result = append(result, obj) + return nil + }) + s.Require().NoError(err) + s.Require().Len(result, 67) +} + +func (s *yumTestSuite) TestRepoWithGPGKeyMissedSignature() { + repo := New(s.srv.URL+"/repo/", ptr.String(s.srv.URL+"/gpg/somekey.gpg"), nil) + err := repo.Process(s.ctx, func(ctx context.Context, obj source.Object) error { + return nil + }) + s.Require().Error(err) + s.Require().Equal( + "error verifying package signature: SRPMS/testpkg1-1-1.src.rpm: keyid 93a645a017898e46 not found", + err.Error(), + ) +} + +// Definitions ... +type yumTestSuite struct { + suite.Suite + + ctx context.Context + srv *httptest.Server +} + +func (s *yumTestSuite) SetupTest() { + s.ctx = context.Background() + + e := echo.New() + e.Use(middleware.Logger()) + e.Use(middleware.Recover()) + e.Static("/", "testdata/") + + s.srv = httptest.NewServer(e) +} + +func (s *yumTestSuite) TearDownTest() { + s.srv.Close() +} + +func TestYumTestSuite(t *testing.T) { + suite.Run(t, &yumTestSuite{}) +} diff --git a/cmd/cli/main.go b/cmd/cli/main.go index ec93466..d2379ba 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -17,8 +17,11 @@ import ( "github.com/teran/archived/cli/router" "github.com/teran/archived/cli/service" + "github.com/teran/archived/cli/service/source" + localSource "github.com/teran/archived/cli/service/source/local" + yumSource "github.com/teran/archived/cli/service/source/yum" + "github.com/teran/archived/cli/service/source/yum/yum_repo/mirrorlist" "github.com/teran/archived/cli/service/stat_cache/local" - "github.com/teran/archived/cli/yum/mirrorlist" v1proto "github.com/teran/archived/manager/presenter/grpc/proto/v1" ) @@ -127,11 +130,6 @@ var ( objectListContainer = objectList.Arg("container", "name of the container to list objects from").Required().String() objectListVersion = objectList.Arg("version", "version to list objects from").Required().String() - objectCreate = object.Command("create", "create object(s) from location") - objectCreateContainer = objectCreate.Arg("container", "name of the container to publish object from").Required().String() - objectCreateVersion = objectCreate.Arg("version", "version to publish object from").Required().String() - objectCreatePath = objectCreate.Arg("path", "local path of the object to create").Required().String() - objectURL = object.Command("url", "get URL for the object") objectURLContainer = objectURL.Arg("container", "name of the container to publish object from").Required().String() objectURLVersion = objectURL.Arg("version", "version to publish object from").Required().String() @@ -210,20 +208,26 @@ func main() { panic(err) } - yumRepository := *versionCreateFromYumRepo - if versionCreateFromYumMirrorlist != nil && *versionCreateFromYumMirrorlist != "" { + cliSvc := service.New(cli, cacheRepo) + + r := router.New(ctx) + + var src source.Source + switch { + case *versionCreateFromDir != "": + src = localSource.New(*versionCreateFromDir, cacheRepo) + case *versionCreateFromYumRepo != "": + src = yumSource.New(*versionCreateFromYumRepo, versionCreateFromYumRepoGPGKey, versionCreateFromYumRepoGPGKeyChecksum) + case *versionCreateFromYumMirrorlist != "": ml, err := mirrorlist.New(ctx, *versionCreateFromYumMirrorlist) if err != nil { panic(err) } - yumRepository = ml.URL(mirrorlist.SelectModeRandom) + yumRepository := ml.URL(mirrorlist.SelectModeRandom) + src = yumSource.New(yumRepository, versionCreateFromYumRepoGPGKey, versionCreateFromYumRepoGPGKeyChecksum) } - cliSvc := service.New(cli, cacheRepo) - - r := router.New(ctx) - r.Register(namespaceCreate.FullCommand(), cliSvc.CreateNamespace(*namespaceCreateName)) r.Register(namespaceRename.FullCommand(), cliSvc.RenameNamespace(*namespaceRenameOldName, *namespaceRenameNewName)) r.Register(namespaceList.FullCommand(), cliSvc.ListNamespaces()) @@ -237,13 +241,11 @@ func main() { r.Register(versionList.FullCommand(), cliSvc.ListVersions(*namespaceName, *versionListContainer)) r.Register(versionCreate.FullCommand(), cliSvc.CreateVersion( - *namespaceName, *versionCreateContainer, *versionCreatePublish, versionCreateFromDir, - &yumRepository, versionCreateFromYumRepoGPGKey, versionCreateFromYumRepoGPGKeyChecksum, + *namespaceName, *versionCreateContainer, *versionCreatePublish, src, )) r.Register(versionDelete.FullCommand(), cliSvc.DeleteVersion(*namespaceName, *versionDeleteContainer, *versionDeleteVersion)) r.Register(versionPublish.FullCommand(), cliSvc.PublishVersion(*namespaceName, *versionPublishContainer, *versionPublishVersion)) - r.Register(objectCreate.FullCommand(), cliSvc.CreateObject(*namespaceName, *objectCreateContainer, *objectCreateVersion, *objectCreatePath)) r.Register(objectList.FullCommand(), cliSvc.ListObjects(*namespaceName, *objectListContainer, *objectListVersion)) r.Register(objectURL.FullCommand(), cliSvc.GetObjectURL(*namespaceName, *objectURLContainer, *objectURLVersion, *objectURLKey)) r.Register(deleteObject.FullCommand(), cliSvc.DeleteObject(*namespaceName, *deleteObjectContainer, *deleteObjectVersion, *deleteObjectKey)) @@ -267,8 +269,9 @@ func normalizeHomeDir(in string) (out string) { } log.WithFields(log.Fields{ - "function": "normalizeHomeDir", - }).Tracef("`%s` resolved to `%s`", in, out) + "from": in, + "to": out, + }).Tracef("directory path normalized") return out }