diff --git a/cmd/oras/internal/option/spec.go b/cmd/oras/internal/option/spec.go index 9d994ff02..ccbb204fb 100644 --- a/cmd/oras/internal/option/spec.go +++ b/cmd/oras/internal/option/spec.go @@ -71,7 +71,7 @@ func (opts *distributionSpec) Parse() error { isApi := true opts.referrersAPI = &isApi default: - return fmt.Errorf("unknown image specification flag: %q", opts.specFlag) + return fmt.Errorf("unknown distribution specification flag: %q", opts.specFlag) } return nil } diff --git a/test/e2e/suite/command/attach.go b/test/e2e/suite/command/attach.go index e761a1a0e..54c35f6c3 100644 --- a/test/e2e/suite/command/attach.go +++ b/test/e2e/suite/command/attach.go @@ -60,6 +60,16 @@ var _ = Describe("ORAS beginners:", func() { ORAS("attach", "--artifact-type", "oras.test", LayoutRef(root, foobar.Tag)). ExpectFailure().MatchErrKeyWords("Error: no blob or manifest annotation are provided").Exec() }) + + It("should fail if distribution spec is unkown", func() { + ORAS("attach", "--artifact-type", "oras.test", RegistryRef(Host, ImageRepo, foobar.Tag), "--distribution-spec", "???"). + ExpectFailure().MatchErrKeyWords("unknown distribution specification flag").Exec() + }) + + It("should fail if image spec is unkown", func() { + ORAS("attach", "--artifact-type", "oras.test", RegistryRef(Host, ImageRepo, foobar.Tag), "--image-spec", "???"). + ExpectFailure().MatchErrKeyWords("unknown image specification flag").Exec() + }) }) })