Fix sync extension logging (#2537)

* fix: nil pointer dereference on localimagestore

fixes https://github.com/project-zot/zot/issues/2527

Signed-off-by: Anders Bennedsgaard <abbennedsgaard@gmail.com>

* fix: no logging from sync extension imagestore

Signed-off-by: Anders Bennedsgaard <abbennedsgaard@gmail.com>

* feat: create local imagestore not found error

Signed-off-by: Anders Bennedsgaard <abbennedsgaard@gmail.com>

* fix: add test

Signed-off-by: Anders Bennedsgaard <abbennedsgaard@gmail.com>

---------

Signed-off-by: Anders Bennedsgaard <abbennedsgaard@gmail.com>
This commit is contained in:
Anders Bennedsgaard
2024-07-15 19:30:43 +02:00
committed by GitHub
parent e5eacaa082
commit 8262c46ad7
5 changed files with 22 additions and 9 deletions
+10 -2
View File
@@ -83,6 +83,14 @@ func TestInjectSyncUtils(t *testing.T) {
})
}
func TestNilDefaultStore(t *testing.T) {
Convey("Nil default store", t, func() {
ols := NewOciLayoutStorage(storage.StoreController{})
_, err := ols.GetImageReference(testImage, testImageTag)
So(err, ShouldEqual, zerr.ErrLocalImgStoreNotFound)
})
}
func TestSyncInternal(t *testing.T) {
Convey("Verify parseRepositoryReference func", t, func() {
repositoryReference := fmt.Sprintf("%s/%s", host, testImage)
@@ -214,7 +222,7 @@ func TestDestinationRegistry(t *testing.T) {
So(err, ShouldBeNil)
So(imageReference, ShouldNotBeNil)
imgStore := getImageStoreFromImageReference(imageReference, repoName, "1.0")
imgStore := getImageStoreFromImageReference(imageReference, repoName, "1.0", log)
// create a blob/layer
upload, err := imgStore.NewBlobUpload(repoName)
@@ -393,7 +401,7 @@ func TestDestinationRegistry(t *testing.T) {
So(err, ShouldBeNil)
So(imageReference, ShouldNotBeNil)
imgStore := getImageStoreFromImageReference(imageReference, repoName, "2.0")
imgStore := getImageStoreFromImageReference(imageReference, repoName, "2.0", log)
// upload image