WithTag combines the name from "name" and the tag from "tag" to form a reference incorporating both the name and the tag.
(name Named, tag string)
| 269 | // WithTag combines the name from "name" and the tag from "tag" to form a |
| 270 | // reference incorporating both the name and the tag. |
| 271 | func WithTag(name Named, tag string) (NamedTagged, error) { |
| 272 | if !anchoredTagRegexp.MatchString(tag) { |
| 273 | return nil, ErrTagInvalidFormat |
| 274 | } |
| 275 | var repo repository |
| 276 | if r, ok := name.(namedRepository); ok { |
| 277 | repo.domain = r.Domain() |
| 278 | repo.path = r.Path() |
| 279 | } else { |
| 280 | repo.path = name.Name() |
| 281 | } |
| 282 | if canonical, ok := name.(Canonical); ok { |
| 283 | return reference{ |
| 284 | namedRepository: repo, |
| 285 | tag: tag, |
| 286 | digest: canonical.Digest(), |
| 287 | }, nil |
| 288 | } |
| 289 | return taggedReference{ |
| 290 | namedRepository: repo, |
| 291 | tag: tag, |
| 292 | }, nil |
| 293 | } |
| 294 | |
| 295 | // WithDigest combines the name from "name" and the digest from "digest" to form |
| 296 | // a reference incorporating both the name and the digest. |
searching dependent graphs…