familiarizeName returns a shortened version of the name familiar to the Docker UI. Familiar names have the default domain "docker.io" and "library/" repository prefix removed. For example, "docker.io/library/redis" will have the familiar name "redis" and "docker.io/dmcgowan/myapp" will be "dmcgowan/
(named namedRepository)
| 110 | // name "redis" and "docker.io/dmcgowan/myapp" will be "dmcgowan/myapp". |
| 111 | // Returns a familiarized named only reference. |
| 112 | func familiarizeName(named namedRepository) repository { |
| 113 | repo := repository{ |
| 114 | domain: named.Domain(), |
| 115 | path: named.Path(), |
| 116 | } |
| 117 | |
| 118 | if repo.domain == defaultDomain { |
| 119 | repo.domain = "" |
| 120 | // Handle official repositories which have the pattern "library/<official repo name>" |
| 121 | if split := strings.Split(repo.path, "/"); len(split) == 2 && split[0] == officialRepoName { |
| 122 | repo.path = split[1] |
| 123 | } |
| 124 | } |
| 125 | return repo |
| 126 | } |
| 127 | |
| 128 | func (r reference) Familiar() Named { |
| 129 | return reference{ |