mirror of
https://github.com/thegeeklab/wp-docker-buildx.git
synced 2024-11-26 15:40:35 +00:00
Merge pull request #159 from AKoetsier/master
Allow ecr login with default aws credential chain
This commit is contained in:
commit
59816a2ad1
@ -11,7 +11,6 @@ import (
|
|||||||
|
|
||||||
"github.com/aws/aws-sdk-go/aws"
|
"github.com/aws/aws-sdk-go/aws"
|
||||||
"github.com/aws/aws-sdk-go/aws/awserr"
|
"github.com/aws/aws-sdk-go/aws/awserr"
|
||||||
"github.com/aws/aws-sdk-go/aws/credentials"
|
|
||||||
"github.com/aws/aws-sdk-go/aws/session"
|
"github.com/aws/aws-sdk-go/aws/session"
|
||||||
"github.com/aws/aws-sdk-go/service/ecr"
|
"github.com/aws/aws-sdk-go/service/ecr"
|
||||||
)
|
)
|
||||||
@ -32,14 +31,14 @@ func main() {
|
|||||||
region = defaultRegion
|
region = defaultRegion
|
||||||
}
|
}
|
||||||
|
|
||||||
os.Setenv("AWS_ACCESS_KEY_ID", key)
|
|
||||||
os.Setenv("AWS_SECRET_ACCESS_KEY", secret)
|
|
||||||
os.Setenv("AWS_REGION", region)
|
os.Setenv("AWS_REGION", region)
|
||||||
|
|
||||||
sess, err := session.NewSession(&aws.Config{
|
if key != "" && secret != "" {
|
||||||
Credentials: credentials.NewEnvCredentials(),
|
os.Setenv("AWS_ACCESS_KEY_ID", key)
|
||||||
Region: ®ion,
|
os.Setenv("AWS_SECRET_ACCESS_KEY", secret)
|
||||||
})
|
}
|
||||||
|
|
||||||
|
sess, err := session.NewSession(&aws.Config{Region: ®ion})
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(fmt.Sprintf("error creating aws session: %v", err))
|
log.Fatal(fmt.Sprintf("error creating aws session: %v", err))
|
||||||
@ -48,7 +47,7 @@ func main() {
|
|||||||
svc := ecr.New(sess)
|
svc := ecr.New(sess)
|
||||||
username, password, registry, err := getAuthInfo(svc)
|
username, password, registry, err := getAuthInfo(svc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
os.Exit(1)
|
log.Fatal(fmt.Sprintf("error getting ECR auth: %v", err))
|
||||||
}
|
}
|
||||||
|
|
||||||
if !strings.HasPrefix(repo, registry) {
|
if !strings.HasPrefix(repo, registry) {
|
||||||
|
Loading…
Reference in New Issue
Block a user