agent/dockerclient/dockerauth/ecr.go
func (authProvider *ecrAuthProvider) getAuthConfigFromECR(image string, key cacheKey, authData *apicontainer.ECRAuthData) (types.AuthConfig, error) {
	// Create ECR client to get the token
	client, err := authProvider.factory.GetClient(authData)
	if err != nil {
		return types.AuthConfig{}, err
	}

	log.Debugf("Calling ECR.GetAuthorizationToken for %s", image)
	ecrAuthData, err := client.GetAuthorizationToken(authData.RegistryID)
	if err != nil {
		return types.AuthConfig{}, err
	}
	if ecrAuthData == nil {
		return types.AuthConfig{}, fmt.Errorf("ecr auth: missing AuthorizationData in ECR response for %s", image)
	}

	// Verify the auth data has the correct format for ECR
	if ecrAuthData.ProxyEndpoint != nil &&
		strings.HasPrefix(proxyEndpointScheme+image, aws.StringValue(ecrAuthData.ProxyEndpoint)) &&
		ecrAuthData.AuthorizationToken != nil {

		// Cache the new token
		authProvider.tokenCache.Set(key.String(), ecrAuthData)
		return extractToken(ecrAuthData)
	}
	return types.AuthConfig{}, fmt.Errorf("ecr auth: AuthorizationData is malformed for %s", image)
}
func (authProvider *ecrAuthProvider) getAuthConfigFromECR(image string, key cacheKey, authData *apicontainer.ECRAuthData) (types.AuthConfig, error) {
	// Create ECR client to get the token
	client, err := authProvider.factory.GetClient(authData)
	if err != nil {
		return types.AuthConfig{}, err
	}

	log.Debugf("Calling ECR.GetAuthorizationToken for %s", image)
	ecrAuthData, err := client.GetAuthorizationToken(authData.RegistryID)
	if err != nil {
		return types.AuthConfig{}, err
	}
	if ecrAuthData == nil {
		return types.AuthConfig{}, fmt.Errorf("ecr auth: missing AuthorizationData in ECR response for %s", image)
	}

	// Verify the auth data has the correct format for ECR
	if ecrAuthData.ProxyEndpoint != nil &&
		strings.HasPrefix(proxyEndpointScheme+image, aws.StringValue(ecrAuthData.ProxyEndpoint)) &&
		ecrAuthData.AuthorizationToken != nil {

		// Cache the new token
		authProvider.tokenCache.Set(key.String(), ecrAuthData)
		return extractToken(ecrAuthData)
	}
	return types.AuthConfig{}, fmt.Errorf("ecr auth: AuthorizationData is malformed for %s", image)
}
// getAuthConfigFromECR calls the ECR API to get docker auth config