Browse Source

Merge pull request #46361 from thaJeztah/registry_update_godoc

registry: update some godoc
Sebastiaan van Stijn 1 năm trước cách đây
mục cha
commit
2832886761
3 tập tin đã thay đổi với 14 bổ sung8 xóa
  1. 4 2
      registry/auth.go
  2. 8 4
      registry/config.go
  3. 2 2
      registry/service.go

+ 4 - 2
registry/auth.go

@@ -125,8 +125,10 @@ func v2AuthHTTPClient(endpoint *url.URL, authTransport http.RoundTripper, modifi
 	}, nil
 }
 
-// ConvertToHostname converts a registry url which has http|https prepended
-// to just an hostname.
+// ConvertToHostname normalizes a registry URL which has http|https prepended
+// to just its hostname. It is used to match credentials, which may be either
+// stored as hostname or as hostname including scheme (in legacy configuration
+// files).
 func ConvertToHostname(url string) string {
 	stripped := url
 	if strings.HasPrefix(url, "http://") {

+ 8 - 4
registry/config.go

@@ -320,7 +320,8 @@ func isCIDRMatch(cidrs []*registry.NetIPNet, URLHost string) bool {
 	return false
 }
 
-// ValidateMirror validates an HTTP(S) registry mirror
+// ValidateMirror validates an HTTP(S) registry mirror. It is used by the daemon
+// to validate the daemon configuration.
 func ValidateMirror(val string) (string, error) {
 	uri, err := url.Parse(val)
 	if err != nil {
@@ -340,7 +341,8 @@ func ValidateMirror(val string) (string, error) {
 	return strings.TrimSuffix(val, "/") + "/", nil
 }
 
-// ValidateIndexName validates an index name.
+// ValidateIndexName validates an index name. It is used by the daemon to
+// validate the daemon configuration.
 func ValidateIndexName(val string) (string, error) {
 	// TODO: upstream this to check to reference package
 	if val == "index.docker.io" {
@@ -426,8 +428,10 @@ func newRepositoryInfo(config *serviceConfig, name reference.Named) (*Repository
 	}, nil
 }
 
-// ParseRepositoryInfo performs the breakdown of a repository name into a RepositoryInfo, but
-// lacks registry configuration.
+// ParseRepositoryInfo performs the breakdown of a repository name into a
+// [RepositoryInfo], but lacks registry configuration.
+//
+// It is used by the Docker cli to interact with registry-related endpoints.
 func ParseRepositoryInfo(reposName reference.Named) (*RepositoryInfo, error) {
 	return newRepositoryInfo(emptyServiceConfig, reposName)
 }

+ 2 - 2
registry/service.go

@@ -20,8 +20,8 @@ type Service struct {
 	mu     sync.RWMutex
 }
 
-// NewService returns a new instance of defaultService ready to be
-// installed into an engine.
+// NewService returns a new instance of [Service] ready to be installed into
+// an engine.
 func NewService(options ServiceOptions) (*Service, error) {
 	config, err := newServiceConfig(options)