Description
Client
cloud.google.com/go/run/apiv2.NewLocationsClient(...)
Environment
e.g. Alpine Docker on GKE
MacOS development environment (redundant, it's sdk related)
e.g. $ go version
1.24.3
Code and Dependencies
package run
import (
v2 "cloud.google.com/go/run/apiv2"
locationpb "google.golang.org/genproto/googleapis/cloud/location"
)
func fetchLocations(ctx context.Context, meta schema.ClientMeta, _ *schema.Resource, res chan<- any) error {
c := meta.(*client.Client)
gcpClient, err := v2.NewLocationsClient(ctx, c.ClientOptions...)
if err != nil {
return err
}
it := gcpClient.ListLocations(ctx, &locationpb.ListLocationsRequest{Name: "projects/" + c.ProjectId}, c.CallOptions...)
return client.Iterate(ctx, it, c, res)
}
Expected behavior
The locations fetched by the SDK call above to be the regions where the Cloud Run API is supported for the given project.
Actual behavior
The API call above returns a full list of locations, including regional, zonal as well as the continent.
Additional context
This happens due to the fact that the DefaultEndpoint for the locations client is cloud.googleapis.com:443
, rather than run.googleapis.com:443
. Setting the option.WithEndpoint("run.googleapis.com:443")
when instantiating the v2.NewLocationsClient(ctx, c.ClientOptions...)
above solves the issue.
However, due to the fact that
- the CLI returns the regions supported by Cloud Run and
- Cloud Run is also a regional service
i believe that by default the endpoint should always berun.googleapis.com:443
.
Thanks in advance for any feedback you might have!