From 4307e1a7aa391390024bc2d4fa5ed009b5e85eac Mon Sep 17 00:00:00 2001 From: Maxim Vasilenko Date: Thu, 30 May 2024 12:55:45 +0300 Subject: [PATCH] [mirror] Support mirroring of modules without images Signed-off-by: Maxim Vasilenko --- internal/mirror/layouts/layouts.go | 9 +++++++-- internal/mirror/modules/modules.go | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/internal/mirror/layouts/layouts.go b/internal/mirror/layouts/layouts.go index b2bb284a..5c4c6989 100644 --- a/internal/mirror/layouts/layouts.go +++ b/internal/mirror/layouts/layouts.go @@ -18,7 +18,9 @@ package layouts import ( "encoding/json" + "errors" "fmt" + "io/fs" "os" "path/filepath" "strings" @@ -249,8 +251,11 @@ func FindDeckhouseModulesImages(mirrorCtx *contexts.PullContext, layouts *ImageL } imagesDigestsJSON, err := images.ExtractFileFromImage(img, "images_digests.json") - if err != nil { - return fmt.Errorf("get digests for %q version: %w", imageTag, err) + switch { + case errors.Is(err, fs.ErrNotExist): + continue + case err != nil: + return fmt.Errorf("extract digests for %q version: %w", imageTag, err) } digests := images.ExtractDigestsFromJSONFile(imagesDigestsJSON.Bytes()) diff --git a/internal/mirror/modules/modules.go b/internal/mirror/modules/modules.go index a612ad59..57dc13ad 100644 --- a/internal/mirror/modules/modules.go +++ b/internal/mirror/modules/modules.go @@ -17,7 +17,9 @@ limitations under the License. package modules import ( + "errors" "fmt" + "io/fs" "github.com/google/go-containerregistry/pkg/authn" "github.com/google/go-containerregistry/pkg/name" @@ -155,8 +157,11 @@ func FindExternalModuleImages( } imagesDigestsJSON, err := images.ExtractFileFromImage(img, "images_digests.json") - if err != nil { - return nil, nil, fmt.Errorf("Get digests for %q version: %w", imageTag, err) + switch { + case errors.Is(err, fs.ErrNotExist): + continue + case err != nil: + return nil, nil, fmt.Errorf("Extract digests for %q version: %w", imageTag, err) } digests := images.ExtractDigestsFromJSONFile(imagesDigestsJSON.Bytes())