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
..
2025-03-01 15:40:29 +01:00
2025-02-20 18:10:36 +01:00
2025-02-17 15:24:54 +01:00
2025-02-17 15:24:53 +01:00
2025-01-08 18:11:19 +01:00
2025-02-17 23:00:13 +01:00
2025-02-03 12:21:00 +01:00
2024-10-19 00:48:16 +02:00
2025-02-18 13:15:28 +01:00
2025-02-17 15:24:54 +01:00
2025-02-20 18:10:36 +01:00
2023-04-03 11:27:26 +02:00
2025-02-17 15:24:54 +01:00
2019-01-29 11:26:40 +00:00
2021-10-11 16:54:22 +02:00
2022-06-28 17:32:09 +02:00
2025-02-17 15:24:52 +01:00
2025-02-21 12:55:57 +01:00
2024-07-05 03:35:14 +02:00
2024-08-26 13:55:28 +02:00