-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed the error unsupported region northamerica-south1 for the table …
- Loading branch information
Showing
3 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package gcp | ||
|
||
import ( | ||
"context" | ||
|
||
"github.com/turbot/steampipe-plugin-sdk/v5/plugin" | ||
) | ||
|
||
// Based on the available documentation, there is no indication that the Cloud Run Admin API v1 supports specific locations that v2 does not. | ||
// Both API versions are designed to operate across all regions where Cloud Run is available. | ||
// The primary differences between v1 and v2 pertain to API design and compatibility, rather than regional support. | ||
// Using the Cloud Run V1 API to list supported regions will not have any negative impact, even though the Cloud Run V2 API is used in the gcp_cloud_run_* tables for building the region matrix. The region data remains consistent across both API versions, ensuring accurate coverage without affecting functionality. | ||
|
||
// https://cloud.google.com/run/docs/locations | ||
// BuildCloudRunLocationList :: return a list of matrix items, one per region specified | ||
func BuildCloudRunLocationList(ctx context.Context, d *plugin.QueryData) []map[string]interface{} { | ||
|
||
// have we already created and cached the locations? | ||
locationCacheKey := "CloudRunLocation" | ||
if cachedData, ok := d.ConnectionManager.Cache.Get(locationCacheKey); ok { | ||
plugin.Logger(ctx).Trace("listlocationDetails:", cachedData.([]map[string]interface{})) | ||
return cachedData.([]map[string]interface{}) | ||
} | ||
|
||
// Create Service Connection | ||
service, err := CloudRunServiceV1(ctx, d) | ||
if err != nil { | ||
return nil | ||
} | ||
|
||
// Get project details | ||
projectData, err := activeProject(ctx, d) | ||
if err != nil { | ||
return nil | ||
} | ||
project := projectData.Project | ||
|
||
|
||
resp, err := service.Projects.Locations.List("projects/" + project).Do() | ||
if err != nil { | ||
return nil | ||
} | ||
// validate location list | ||
matrix := make([]map[string]interface{}, len(resp.Locations)) | ||
for i, location := range resp.Locations { | ||
matrix[i] = map[string]interface{}{matrixKeyLocation: location.LocationId} | ||
} | ||
d.ConnectionManager.Cache.Set(locationCacheKey, matrix) | ||
return matrix | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters