forked from notaryproject/notation
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(test): E2E test cases for OCI layout (notaryproject#692)
- Loading branch information
Showing
12 changed files
with
126 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package notation | ||
|
||
import ( | ||
"context" | ||
"os" | ||
"path/filepath" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
"oras.land/oras-go/v2" | ||
"oras.land/oras-go/v2/content/oci" | ||
) | ||
|
||
// OCILayout is a OCI layout directory for | ||
type OCILayout struct { | ||
// Path is the path of the OCI layout directory. | ||
Path string | ||
// Tag is the tag of artifact in the OCI layout. | ||
Tag string | ||
// Digest is the digest of artifact in the OCI layout. | ||
Digest string | ||
} | ||
|
||
// GenerateOCILayout creates a new OCI layout in a temporary directory. | ||
func GenerateOCILayout(srcRepoName string) (*OCILayout, error) { | ||
ctx := context.Background() | ||
|
||
if srcRepoName == "" { | ||
srcRepoName = TestRepoUri | ||
} | ||
|
||
destPath := filepath.Join(GinkgoT().TempDir(), newRepoName()) | ||
// create a local store from OCI layout directory. | ||
srcStore, err := oci.NewFromFS(ctx, os.DirFS(filepath.Join(OCILayoutPath, srcRepoName))) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// create a dest store for store the generated oci layout. | ||
destStore, err := oci.New(destPath) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
// copy data | ||
desc, err := oras.ExtendedCopy(ctx, srcStore, TestTag, destStore, "", oras.DefaultExtendedCopyOptions) | ||
if err != nil { | ||
return nil, err | ||
} | ||
return &OCILayout{ | ||
Path: destPath, | ||
Tag: TestTag, | ||
Digest: desc.Digest.String(), | ||
}, nil | ||
} | ||
|
||
// ReferenceWithTag returns the reference with tag. | ||
func (o *OCILayout) ReferenceWithTag() string { | ||
return o.Path + ":" + o.Tag | ||
} | ||
|
||
// ReferenceWithDigest returns the reference with digest. | ||
func (o *OCILayout) ReferenceWithDigest() string { | ||
return o.Path + "@" + o.Digest | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
...-layout/e2e/blobs/sha256/0d10372ee4448bf319929720bc465c1a6242cc68e82e12c152bc10d541cce578
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
...-layout/e2e/blobs/sha256/cc2ae4e91a31a77086edbdbf4711de48e5fa3ebdacad3403e61777a9e1a53b6f
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.