[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>
Docker CLI
About
This repository is the home of the Docker CLI.
Development
docker/cli is developed using Docker.
Build CLI from source:
docker buildx bake
Build binaries for all supported platforms:
docker buildx bake cross
Build for a specific platform:
docker buildx bake --set binary.platform=linux/arm64
Build dynamic binary for glibc or musl:
USE_GLIBC=1 docker buildx bake dynbinary
Run all linting:
docker buildx bake lint shellcheck
Run test:
docker buildx bake test
List all the available targets:
make help
In-container development environment
Start an interactive development environment:
make -f docker.Makefile shell
Legal
Brought to you courtesy of our legal counsel. For more context, see the NOTICE document in this repo.
Use and transfer of Docker may be subject to certain restrictions by the United States and other governments.
It is your responsibility to ensure that your use and/or transfer does not violate applicable laws.
For more information, see https://www.bis.doc.gov
Licensing
docker/cli is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.