WithName returns a named object representing the given string. If the input is invalid ErrReferenceInvalidFormat will be returned.
(name string)
| 252 | // WithName returns a named object representing the given string. If the input |
| 253 | // is invalid ErrReferenceInvalidFormat will be returned. |
| 254 | func WithName(name string) (Named, error) { |
| 255 | if len(name) > NameTotalLengthMax { |
| 256 | return nil, ErrNameTooLong |
| 257 | } |
| 258 | |
| 259 | match := anchoredNameRegexp.FindStringSubmatch(name) |
| 260 | if match == nil || len(match) != 3 { |
| 261 | return nil, ErrReferenceInvalidFormat |
| 262 | } |
| 263 | return repository{ |
| 264 | domain: match[1], |
| 265 | path: match[2], |
| 266 | }, nil |
| 267 | } |
| 268 | |
| 269 | // WithTag combines the name from "name" and the tag from "tag" to form a |
| 270 | // reference incorporating both the name and the tag. |
searching dependent graphs…