diff --git a/docs/configuration.md b/docs/configuration.md index d2c9e05c..42aab1e4 100644 --- a/docs/configuration.md +++ b/docs/configuration.md @@ -170,6 +170,7 @@ The AWS Account ID and Region is primarily used to construct the ECR domain `[AC aws: accountId: 123456789 region: ap-southeast-2 + prefix: /cache ``` #### ECR Options diff --git a/pkg/config/config.go b/pkg/config/config.go index 89945567..e3c20d6b 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -70,6 +70,7 @@ type AWS struct { AccountID string `yaml:"accountId"` Region string `yaml:"region"` Role string `yaml:"role"` + Prefix string `yaml:"prefix"` ECROptions ECROptions `yaml:"ecrOptions"` } @@ -107,7 +108,7 @@ func (a *AWS) EcrDomain() string { if strings.HasPrefix(a.Region, "cn-") { domain = "amazonaws.com.cn" } - return fmt.Sprintf("%s.dkr.ecr.%s.%s", a.AccountID, a.Region, domain) + return fmt.Sprintf("%s.dkr.ecr.%s.%s%s", a.AccountID, a.Region, domain, a.Prefix) } func (g *GCP) GarDomain() string { diff --git a/pkg/config/config_test.go b/pkg/config/config_test.go index 3b4da817..1e59ec05 100644 --- a/pkg/config/config_test.go +++ b/pkg/config/config_test.go @@ -264,6 +264,20 @@ func TestEcrDomain(t *testing.T) { }, domain: "123456789.dkr.ecr.cn-north-1.amazonaws.com.cn", }, + { + name: "aws with prefix", + cfg: Config{ + Target: Registry{ + Type: "aws", + AWS: AWS{ + AccountID: "123456789", + Region: "ap-southeast-2", + Prefix: "/prefix", + }, + }, + }, + domain: "123456789.dkr.ecr.ap-southeast-2.amazonaws.com/prefix", + }, } for _, test := range tests { t.Run(test.name, func(t *testing.T) {