This gets rid of those annoying logs like: ``` time="2024-09-11T15:22:04Z" level=error msg="Error parsing the serverURL" error="docker-credential-ecr-login can only be used with Amazon Elastic Container Registry." serverURL="localhost:5000" time="2024-09-11T15:22:04Z" level=error msg="Error parsing the serverURL" error="docker-credential-ecr-login can only be used with Amazon Elastic Container Registry." serverURL="localhost:5000" time="2024-09-11T15:22:04Z" level=error msg="Error parsing the serverURL" error="docker-credential-ecr-login can only be used with Amazon Elastic Container Registry." serverURL="localhost:5000" time="2024-09-11T15:22:04Z" level=error msg="Error parsing the serverURL" error="docker-credential-ecr-login can only be used with Amazon Elastic Container Registry." serverURL="localhost:5000" ```
24 lines
648 B
Go
24 lines
648 B
Go
package oci
|
|
|
|
import (
|
|
"io"
|
|
|
|
ecr "github.com/awslabs/amazon-ecr-credential-helper/ecr-login"
|
|
"github.com/google/go-containerregistry/pkg/authn"
|
|
"github.com/google/go-containerregistry/pkg/v1/google"
|
|
"github.com/google/go-containerregistry/pkg/v1/remote"
|
|
)
|
|
|
|
func MultiKeychainOption() remote.Option {
|
|
return remote.WithAuthFromKeychain(MultiKeychainAll())
|
|
}
|
|
|
|
func MultiKeychainAll() authn.Keychain {
|
|
// Create a multi-keychain that will use the default Docker, Google, or ECR keychain
|
|
return authn.NewMultiKeychain(
|
|
authn.DefaultKeychain,
|
|
google.Keychain,
|
|
authn.NewKeychainFromHelper(ecr.NewECRHelper(ecr.WithLogger(io.Discard))),
|
|
)
|
|
}
|