From a283f5d80c12dc87d8fd69ee528905f48cb5326b Mon Sep 17 00:00:00 2001 From: Amelia Crate <95060558+a-crate@users.noreply.github.com> Date: Tue, 6 Feb 2024 16:50:40 -0800 Subject: [PATCH] Respect subnet region when the user specifies one (#39) --- subnetwork.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/subnetwork.go b/subnetwork.go index 20ddf3e8..457620a7 100644 --- a/subnetwork.go +++ b/subnetwork.go @@ -53,7 +53,11 @@ func (sn *Subnetwork) populate(ctx context.Context, s *Step) DError { sn.Name, errs = sn.Resource.populateWithGlobal(ctx, s, sn.Name) sn.Description = strOr(sn.Description, defaultDescription("Subnetwork", s.w.Name, s.w.username)) - sn.link = fmt.Sprintf("projects/%s/regions/%s/subnetworks/%s", sn.Project, getRegionFromZone(s.w.Zone), sn.Name) + r := sn.Region + if r == "" { + r = getRegionFromZone(s.w.Zone) + } + sn.link = fmt.Sprintf("projects/%s/regions/%s/subnetworks/%s", sn.Project, r, sn.Name) return errs }