Skip to content

Commit f5e3735

Browse files
authored
GetProjectFromRegionalSelfLink: Accept projects with a colon in the name (#12628)
Signed-off-by: Norbert Kamiński <[email protected]>
1 parent bcbb098 commit f5e3735

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

mmv1/third_party/terraform/tpgresource/self_link_helpers.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func GetRegionFromRegionalSelfLink(selfLink string) string {
172172
}
173173

174174
func GetProjectFromRegionalSelfLink(selfLink string) string {
175-
re := regexp.MustCompile("projects/([a-zA-Z0-9-]*)/(?:locations|regions)/[a-zA-Z0-9-]*")
175+
re := regexp.MustCompile("projects/([a-zA-Z0-9-:]*)/(?:locations|regions)/[a-zA-Z0-9-:]*")
176176
switch {
177177
case re.MatchString(selfLink):
178178
if res := re.FindStringSubmatch(selfLink); len(res) == 2 && res[1] != "" {

mmv1/third_party/terraform/tpgresource/self_link_helpers_test.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ func TestGetRegionFromRegionalSelfLink(t *testing.T) {
125125

126126
func TestGetProjectFromRegionalSelfLink(t *testing.T) {
127127
cases := map[string]string{
128-
"projects/foo/locations/europe-north1/datasets/bar/operations/foobar": "foo",
129-
"projects/REDACTED/regions/europe-north1/subnetworks/tf-test-net-xbwhsmlfm8": "REDACTED",
128+
"projects/foo/locations/europe-north1/datasets/bar/operations/foobar": "foo",
129+
"projects/REDACTED/regions/europe-north1/subnetworks/tf-test-net-xbwhsmlfm8": "REDACTED",
130+
"projects/REDA:CT-ED09/regions/europe-north1/subnetworks/tf-test-net-xbwhsmlfm8": "REDA:CT-ED09",
130131
}
131132
for input, expected := range cases {
132133
if result := GetProjectFromRegionalSelfLink(input); result != expected {

0 commit comments

Comments
 (0)