diff --git a/cmd/oras/internal/meta/type.go b/cmd/oras/internal/meta/type.go index 20dad7097..19d6d7956 100644 --- a/cmd/oras/internal/meta/type.go +++ b/cmd/oras/internal/meta/type.go @@ -35,6 +35,7 @@ func ToDigestReference(name string, digest string) DigestReference { // Descriptor is a descriptor with digest reference. type Descriptor struct { DigestReference + // MediaType is the media type of the object this schema refers to. MediaType string diff --git a/test/e2e/suite/command/attach.go b/test/e2e/suite/command/attach.go index d045b866d..3fece16c2 100644 --- a/test/e2e/suite/command/attach.go +++ b/test/e2e/suite/command/attach.go @@ -20,6 +20,7 @@ import ( "fmt" "path/filepath" "regexp" + "strings" . "github.com/onsi/ginkgo/v2" "github.com/onsi/gomega" @@ -126,10 +127,13 @@ var _ = Describe("1.1 registry users:", func() { subjectRef := RegistryRef(ZOTHost, testRepo, foobar.Tag) CopyZOTRepo(ImageRepo, testRepo) // test - ref := ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia), "--export-manifest", exportName, "--format", "{{.Ref}}"). + delimitter := "|" + output := ORAS("attach", "--artifact-type", "test/attach", subjectRef, fmt.Sprintf("%s:%s", foobar.AttachFileName, foobar.AttachFileMedia), "--export-manifest", exportName, "--format", fmt.Sprintf("{{.Ref%s.ArtifactType}}", delimitter)). WithWorkDir(tempDir).Exec().Out.Contents() + ref, artifactType, _ := strings.Cut(string(output), delimitter) // validate - fetched := ORAS("manifest", "fetch", string(ref)).Exec().Out.Contents() + Expect(artifactType).To(Equal("test/attach")) + fetched := ORAS("manifest", "fetch", ref).Exec().Out.Contents() MatchFile(filepath.Join(tempDir, exportName), string(fetched), DefaultTimeout) })