File tree 2 files changed +27
-1
lines changed
2 files changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -37,7 +37,9 @@ import (
37
37
"github.com/fluxcd/pkg/oci"
38
38
)
39
39
40
- var registryPartRe = regexp .MustCompile (`([0-9+]*).dkr.ecr(?:-fips)?\.([^/.]*)\.(amazonaws\.com[.cn]*)` )
40
+ // This regex is sourced from the AWS ECR Credential Helper (https://github.com/awslabs/amazon-ecr-credential-helper).
41
+ // It covers both public AWS partitions like amazonaws.com, China partitions like amazonaws.com.cn, and non-public partitions.
42
+ var registryPartRe = regexp .MustCompile (`([0-9+]*).dkr.ecr(?:-fips)?\.([^/.]*)\.(amazonaws\.com[.cn]*|sc2s\.sgov\.gov|c2s\.ic\.gov|cloud\.adc-e\.uk|csp\.hci\.ic\.gov)` )
41
43
42
44
// ParseRegistry returns the AWS account ID and region and `true` if
43
45
// the image registry/repository is hosted in AWS's Elastic Container Registry,
Original file line number Diff line number Diff line change @@ -77,6 +77,30 @@ func TestParseRegistry(t *testing.T) {
77
77
wantRegion : "us-gov-west-1" ,
78
78
wantOK : true ,
79
79
},
80
+ {
81
+ registry : "012345678901.dkr.ecr.us-secret-region.sc2s.sgov.gov" ,
82
+ wantAccountID : "012345678901" ,
83
+ wantRegion : "us-secret-region" ,
84
+ wantOK : true ,
85
+ },
86
+ {
87
+ registry : "012345678901.dkr.ecr-fips.us-ts-region.c2s.ic.gov" ,
88
+ wantAccountID : "012345678901" ,
89
+ wantRegion : "us-ts-region" ,
90
+ wantOK : true ,
91
+ },
92
+ {
93
+ registry : "012345678901.dkr.ecr.uk-region.cloud.adc-e.uk" ,
94
+ wantAccountID : "012345678901" ,
95
+ wantRegion : "uk-region" ,
96
+ wantOK : true ,
97
+ },
98
+ {
99
+ registry : "012345678901.dkr.ecr.us-ts-region.csp.hci.ic.gov" ,
100
+ wantAccountID : "012345678901" ,
101
+ wantRegion : "us-ts-region" ,
102
+ wantOK : true ,
103
+ },
80
104
// TODO: Fix: this invalid registry is allowed by the regex.
81
105
// {
82
106
// registry: ".dkr.ecr.error.amazonaws.com",
You can’t perform that action at this time.
0 commit comments