Skip to content

Commit

Permalink
If no tag or digest specified when pulling, return error (#440)
Browse files Browse the repository at this point in the history
Signed-off-by: Billy Zha <[email protected]>
  • Loading branch information
qweeah authored Jul 7, 2022
1 parent 09fbc0e commit 209b945
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
27 changes: 27 additions & 0 deletions cmd/oras/errors.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
Copyright The ORAS Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package main

import (
"fmt"

"oras.land/oras-go/v2/registry"
)

// newErrInvalidReference creates a new error based on the reference string.
func newErrInvalidReference(ref registry.Reference) error {
return fmt.Errorf("%s: invalid image reference, expecting <name:tag|name@digest>", ref)
}
3 changes: 3 additions & 0 deletions cmd/oras/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ func runPull(opts pullOptions) error {
if err != nil {
return err
}
if repo.Reference.Reference == "" {
return newErrInvalidReference(repo.Reference)
}
var src oras.Target = repo
if opts.cacheRoot != "" {
ociStore, err := oci.New(opts.cacheRoot)
Expand Down

0 comments on commit 209b945

Please sign in to comment.