Browse Source

Include parsed string in error for ParseRef()

Roland Schilter 1 year ago
parent
commit
eb22200b0c
1 changed files with 4 additions and 4 deletions
  1. 4
    4
      image/image.go

+ 4
- 4
image/image.go View File

@@ -136,16 +136,16 @@ func (i Ref) String() string {
136 136
 func ParseRef(s string) (Ref, error) {
137 137
 	var id Ref
138 138
 	if s == "" {
139
-		return id, ErrBlankImageID
139
+		return id, errors.Wrapf(ErrBlankImageID, "parsing %q", s)
140 140
 	}
141 141
 	if strings.HasPrefix(s, "/") || strings.HasSuffix(s, "/") {
142
-		return id, ErrMalformedImageID
142
+		return id, errors.Wrapf(ErrMalformedImageID, "parsing %q", s)
143 143
 	}
144 144
 
145 145
 	elements := strings.Split(s, "/")
146 146
 	switch len(elements) {
147 147
 	case 0: // NB strings.Split will never return []
148
-		return id, ErrBlankImageID
148
+		return id, errors.Wrapf(ErrMalformedImageID, "parsing %q", s)
149 149
 	case 1: // no slashes, e.g., "alpine:1.5"; treat as library image
150 150
 		id.Image = s
151 151
 	case 2: // may have a domain e.g., "localhost/foo", or not e.g., "weaveworks/scope"
@@ -167,7 +167,7 @@ func ParseRef(s string) (Ref, error) {
167 167
 		break
168 168
 	case 2:
169 169
 		if imageParts[0] == "" || imageParts[1] == "" {
170
-			return id, ErrMalformedImageID
170
+			return id, errors.Wrapf(ErrMalformedImageID, "parsing %q", s)
171 171
 		}
172 172
 		id.Image = imageParts[0]
173 173
 		id.Tag = imageParts[1]

Loading…
Cancel
Save