Skip to content

Commit

Permalink
add support for new aws partitions in credential provider
Browse files Browse the repository at this point in the history
  • Loading branch information
kmala committed Jun 27, 2024
1 parent 12e418e commit 424f2d6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
4 changes: 2 additions & 2 deletions cmd/ecr-credential-provider/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ import (

metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/klog/v2"
"k8s.io/kubelet/pkg/apis/credentialprovider/v1"
v1 "k8s.io/kubelet/pkg/apis/credentialprovider/v1"
)

var ecrPattern = regexp.MustCompile(`^(\d{12})\.dkr\.ecr(\-fips)?\.([a-zA-Z0-9][a-zA-Z0-9-_]*)\.(amazonaws\.com(\.cn)?|sc2s\.sgov\.gov|c2s\.ic\.gov)$`)
var ecrPattern = regexp.MustCompile(`^(\d{12})\.dkr\.ecr(\-fips)?\.([a-zA-Z0-9][a-zA-Z0-9-_]*)\.(amazonaws\.com(\.cn)?|sc2s\.sgov\.gov|c2s\.ic\.gov|cloud\.adc-e\.uk|csp\.hci\.ic\.gov)$`)

// ECR abstracts the calls we make to aws-sdk for testing purposes
type ECR interface {
Expand Down
10 changes: 10 additions & 0 deletions cmd/ecr-credential-provider/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,16 @@ func TestRegistryPatternMatch(t *testing.T) {
{"123456789012.dkr.cat.lala-land-1.awsamazon.com", false},
// too short
{"123456789012.lala-land-1.amazonaws.com", false},
// iso
{"123456789012.dkr.ecr.us-iso-east-1.c2s.ic.gov", true},
// iso-b
{"123456789012.dkr.ecr.us-isob-east-1.sc2s.sgov.gov", true},
// iso-e
{"123456789012.dkr.ecr.eu-isoe-west-1.cloud.adc-e.uk", true},
// iso-f
{"123456789012.dkr.ecr.us-isof-east-1.csp.hci.ic.gov", true},
// invalid gov endpoint
{"123456789012.dkr.ecr.us-iso-east-1.amazonaws.gov", false},
}
for _, g := range grid {
actual := ecrPattern.MatchString(g.Registry)
Expand Down

0 comments on commit 424f2d6

Please sign in to comment.