Skip to content

Commit

Permalink
bugfix: pouch pull should handle space input as an error
Browse files Browse the repository at this point in the history
Signed-off-by: xiechengsheng <XIE1995@whut.edu.cn>
  • Loading branch information
xiechengsheng committed Jul 19, 2018
1 parent f251319 commit 450fc55
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 5 additions & 1 deletion cli/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,11 @@ func pullMissingImage(ctx context.Context, apiClient client.CommonAPIClient, ima
}
}

namedRef, _ := reference.Parse(image)
namedRef, err := reference.Parse(image)
if err != nil {
return err
}

namedRef = reference.TrimTagForDigest(reference.WithDefaultTagIfMissing(namedRef))

var name, tag string
Expand Down
5 changes: 1 addition & 4 deletions pkg/reference/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,14 @@ import (
)

var (
// ErrInvalid is used to return error if reference is invalid
ErrInvalid = errors.New("invalid reference")

// defaultTag is latest if there is no tag
defaultTag = "latest"
)

// Parse parses ref into reference.Named.
func Parse(ref string) (Named, error) {
if ok := regRef.MatchString(ref); !ok {
return nil, ErrInvalid
return nil, errors.New("invalid reference: " + ref)
}

name, tag, digStr := splitReference(ref)
Expand Down

0 comments on commit 450fc55

Please sign in to comment.