code: func (authProvider *dockerAuthProvider) GetAuthconfig(image string, registryAuthData *apicontainer.RegistryAuthenticationData) (types.AuthConfig, error) {
  	// Ignore 'tag', not used in auth determination
  	repository, _ := utils.ParseRepositoryTag(image)
  	authDataMap := authProvider.authMap
  
  	// Ignore repo/image name for some auth checks (see use of 'image' below for where it's not ignored.
  	indexName, _ := splitReposName(repository)
  
  	if isDockerhubHostname(indexName) {
  		return authDataMap[dockerRegistryKey], nil
  	}
  
  	// Try to find the longest match that at least matches the hostname
  	// This is to support e.g. 'registry.tld: auth1, registry.tld/username:
  	// auth2' for multiple different auths on the same registry.
  	longestKey := ""
  	authConfigKey := indexName
  
  	// Take a direct match of the index hostname as a sane default
  	if _, found := authDataMap[authConfigKey]; found && len(authConfigKey) > len(longestKey) {
  		longestKey = authConfigKey
  	}
  
  	for registry := range authDataMap {
  		nameParts := strings.SplitN(registry, "/", 2)
  		hostname := nameParts[0]
  
  		// Only ever take a new key if the hostname matches in normal cases
  		if authConfigKey == hostname {
  			if longestKey == "" {
  				longestKey = registry
  			} else if len(registry) > len(longestKey) && strings.HasPrefix(image, registry) {
  				// If we have a longer match, that indicates a username / namespace appended
  				longestKey = registry
  			}
  		}
  	}
  	if longestKey != "" {
  		return authDataMap[longestKey], nil
  	}
  	return types.AuthConfig{}, nil
  }
docs: // GetAuthconfig retrieves the correct auth configuration for the given repository