Skip to content

Commit

Permalink
[mirror] Support mirroring of modules without images
Browse files Browse the repository at this point in the history
Signed-off-by: Maxim Vasilenko <maksim.vasilenko@flant.com>
  • Loading branch information
mvasl committed May 30, 2024
1 parent 4abab07 commit 4307e1a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
9 changes: 7 additions & 2 deletions internal/mirror/layouts/layouts.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ package layouts

import (
"encoding/json"
"errors"
"fmt"
"io/fs"
"os"
"path/filepath"
"strings"
Expand Down Expand Up @@ -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())
Expand Down
9 changes: 7 additions & 2 deletions internal/mirror/modules/modules.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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())
Expand Down

0 comments on commit 4307e1a

Please sign in to comment.