55a83aff23
[ParseRepositoryInfo] parses an image reference and returns information about the Repository and the registry. As part of this, it validates if the registry's hostname is considered valid using [ValidateIndexName], as well as normalizing the image reference to strip tags and digests using [reference.TrimNamed]. ValidateIndexName only provides very limited value; the only validation happening is to check for the hostname to not start, or end with a hyphen. The cli/command/manifest package used ParseRepositoryInfo in various locations where only the repository name was used (i.e., the result of `reference.TrimNamed` on the given reference), and in one location only used it to validate the registry name. For buildPushRequest, the call was fully redundant, as [RepoNameForReference] was used on the result, calling [newDefaultRepositoryEndpoint], which uses ParseRepositoryInfo internally, so we were only repeating that work. This patch removes uses of ParseRepositoryInfo in those places, and instead calling [reference.TrimNamed] directly. [ParseRepositoryInfo]: https://github.com/moby/moby/blob/41f781fab3cae181cc9be3ec93cd91b99466fa84/registry/config.go#L375-L381 [ValidateIndexName]: https://github.com/moby/moby/blob/41f781fab3cae181cc9be3ec93cd91b99466fa84/registry/config.go#L288-L299 [reference.TrimNamed]: https://github.com/moby/moby/blob/41f781fab3cae181cc9be3ec93cd91b99466fa84/registry/config.go#L369 [RepoNameForReference]: https://github.com/docker/cli/blob/fe0a8d27912dc6fddc60cedcd35bbef27b776355/cli/registry/client/endpoint.go#L107-L110 [newDefaultRepositoryEndpoint]: https://github.com/docker/cli/blob/fe0a8d27912dc6fddc60cedcd35bbef27b776355/cli/registry/client/endpoint.go#L33-L38 Signed-off-by: Sebastiaan van Stijn <github@gone.nl>