Files
docker-cli/cli/command
Sebastiaan van Stijn 55a83aff23 cli/command/manifest: remove redundant uses of ParseRepositoryInfo
[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>
2025-03-01 15:40:29 +01:00
..
2024-07-04 01:35:12 +02:00
2024-11-12 12:38:18 +01:00
2024-11-12 12:38:18 +01:00