func projectRunLocations()

in cmd/cloudshell_open/cloudrun.go [35:53]


func projectRunLocations(ctx context.Context, project string) ([]string, error) {
	runSvc, err := runapi.NewService(ctx)
	if err != nil {
		return nil, fmt.Errorf("failed to initialize Run API client: %+v", err)
	}

	var locations []string
	if err := runapi.NewProjectsLocationsService(runSvc).
		List("projects/"+project).Pages(ctx, func(resp *runapi.ListLocationsResponse) error {
		for _, v := range resp.Locations {
			locations = append(locations, v.LocationId)
		}
		return nil
	}); err != nil {
		return nil, fmt.Errorf("request to query Cloud Run locations failed: %+v", err)
	}
	sort.Strings(locations)
	return locations, nil
}