Skip to content

Commit e23cc87

Browse files
GetProjectFromRegionalSelfLink: Accept projects with a colon in the name (#12628) (#20789)
[upstream:f5e373575e0c43293f7f4a2402e90bc960c5d03b] Signed-off-by: Modular Magician <magic-modules@google.com>
1 parent 9c9f5b7 commit e23cc87

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

.changelog/12628.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
```release-note:bug
2+
compute: GetProjectFromRegionalSelfLink accepts projects with a colon in the name
3+
```

google/tpgresource/self_link_helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func GetRegionFromRegionalSelfLink(selfLink string) string {
174174
}
175175

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

google/tpgresource/self_link_helpers_test.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,9 @@ func TestGetRegionFromRegionalSelfLink(t *testing.T) {
127127

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

0 commit comments

Comments
 (0)