Skip to content

Commit

Permalink
add validate support
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav Singh <[email protected]>
  • Loading branch information
theBeginner86 committed Jan 10, 2024
1 parent 8a971b8 commit d42ce1a
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions models/oci/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"github.com/fluxcd/pkg/tar"
"github.com/google/go-containerregistry/pkg/crane"
gcrv1 "github.com/google/go-containerregistry/pkg/v1"
"github.com/google/go-containerregistry/pkg/v1/tarball"
"github.com/google/go-containerregistry/pkg/v1/validate"
"github.com/layer5io/meshkit/utils"
)

Expand All @@ -32,8 +34,19 @@ func SaveOCIArtifact(img gcrv1.Image, artifactPath, name string) error {
return nil
}

// uncompress the OCI Artifact tarball at the given path
func UnCompressOCIArtifact(img gcrv1.Image, destination string) error {
// uncompress the OCI Artifact tarball at the given destination path
func UnCompressOCIArtifact(source, destination string) error {
img, err := tarball.ImageFromPath(source, nil)
if err != nil {
return ErrGettingImage(err)
}

opt := []validate.Option{}

if err := validate.Image(img, opt...); err != nil {
return ErrValidatingImage(err)
}

layers, err := img.Layers()
if err != nil {
return ErrGettingLayer(err)
Expand Down

0 comments on commit d42ce1a

Please sign in to comment.