registry.go 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. Copyright 2023 Docker Compose CLI authors
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. */
  13. package registry
  14. const (
  15. // DefaultNamespace is the default namespace
  16. DefaultNamespace = "docker.io"
  17. // DefaultRegistryHost is the hostname for the default (Docker Hub) registry
  18. // used for pushing and pulling images. This hostname is hard-coded to handle
  19. // the conversion from image references without registry name (e.g. "ubuntu",
  20. // or "ubuntu:latest"), as well as references using the "docker.io" domain
  21. // name, which is used as canonical reference for images on Docker Hub, but
  22. // does not match the domain-name of Docker Hub's registry.
  23. DefaultRegistryHost = "registry-1.docker.io"
  24. // IndexHostname is the index hostname, used for authentication and image search.
  25. IndexHostname = "index.docker.io"
  26. // IndexServer is used for user auth and image search
  27. IndexServer = "https://" + IndexHostname + "/v1/"
  28. // IndexName is the name of the index
  29. IndexName = "docker.io"
  30. )
  31. // GetAuthConfigKey special-cases using the full index address of the official
  32. // index as the AuthConfig key, and uses the (host)name[:port] for private indexes.
  33. func GetAuthConfigKey(indexName string) string {
  34. if indexName == IndexName || indexName == IndexHostname || indexName == DefaultRegistryHost {
  35. return IndexServer
  36. }
  37. return indexName
  38. }