registry.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  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. import "github.com/distribution/reference"
  15. const (
  16. // IndexHostname is the index hostname, used for authentication and image search.
  17. IndexHostname = "index.docker.io"
  18. // IndexServer is used for user auth and image search
  19. IndexServer = "https://index.docker.io/v1/"
  20. // IndexName is the name of the index
  21. IndexName = "docker.io"
  22. )
  23. // GetAuthConfigKey special-cases using the full index address of the official
  24. // index as the AuthConfig key, and uses the (host)name[:port] for private indexes.
  25. func GetAuthConfigKey(reposName reference.Named) string {
  26. indexName := reference.Domain(reposName)
  27. if indexName == IndexName || indexName == IndexHostname {
  28. return IndexServer
  29. }
  30. return indexName
  31. }