Skip to content

fix(gcp): List locations before getting run services#5919

Merged
kodiakhq[bot] merged 2 commits intocloudquery:mainfrom
erezrokah:feat/gcp_cloud_run
Dec 22, 2022
Merged

fix(gcp): List locations before getting run services#5919
kodiakhq[bot] merged 2 commits intocloudquery:mainfrom
erezrokah:feat/gcp_cloud_run

Conversation

@erezrokah
Copy link
Copy Markdown
Member

@erezrokah erezrokah commented Dec 22, 2022

Summary

Fixes #5385.

In order to list run services we need to pass a location (can't use the wildcard). The v2 API of cloud run doesn't support listing locations, so we use the v1 API to list the locations, and v2 to list the services.
Thank you @bernays for pointing me to the right API.

This is implemented as a relation since it's a list->list.

Notes:

  1. This is not a breaking change as if someone had gcp_run_services in the config it will now work + get the locations top level table
  2. Tried writing tests for it, but it's requires a bigger change to how we test. For testing locations we need to use HTTP server, but for testing services we need to use the gRPC server. Those have different endpoints, so we need to support replacing the client endpoint mid sync during the test. My suggestion is to wait for the v2 API to support listing locations, so we can use the gRPC approach

@github-actions
Copy link
Copy Markdown

This PR has the following changes to source plugin(s) tables:

  • Table gcp_run_locations was added

@erezrokah erezrokah added the automerge Automatically merge once required checks pass label Dec 22, 2022
@kodiakhq kodiakhq bot merged commit 7581466 into cloudquery:main Dec 22, 2022
@erezrokah erezrokah deleted the feat/gcp_cloud_run branch December 22, 2022 17:39
kodiakhq bot pushed a commit that referenced this pull request Dec 27, 2022
🤖 I have created a release *beep* *boop*
---


## [5.3.0](plugins-source-gcp-v5.2.0...plugins-source-gcp-v5.3.0) (2022-12-27)


### Features

* **gcp:** Fetch Only enabled services ([#5534](#5534)) ([667b567](667b567))
* **resources:** Add API Gateway ([#5926](#5926)) ([7bb33a8](7bb33a8))


### Bug Fixes

* **deps:** Update module github.com/cloudquery/plugin-sdk to v1.13.1 ([#5897](#5897)) ([ad15915](ad15915))
* **gcp:** List locations before getting run services ([#5919](#5919)) ([7581466](7581466))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
kodiakhq bot pushed a commit that referenced this pull request Dec 27, 2022

#### Summary

Follow up to #5919. Fixes the description link for the `run_locations` table

<!--
erezrokah added a commit that referenced this pull request Dec 29, 2022
<!-- 🎉 Thank you for making CloudQuery awesome by submitting a PR 🎉 -->

#### Summary

Relevant API -
https://cloud.google.com/artifact-registry/docs/reference/rest

Similar to #5919, we need
the locations to list the resources (tried using different types of
wildcards like `-`, `global`, `*` and they don't work).
Same as #5919 the locations
list method is only on the old API, so again we can't test this as our
testing framework uses HTTP for old API and gRPC server for new, which
means we need 2 different endpoints and to change the client endpoint
mid sync.

I did ran it on our `cq-playground` account and it synced data for all
the tables successfully

### Notes

The API has a few other list methods, neither part of the Go SDK nor
supported by `gcloud` so I didn't add them:
-
https://cloud.google.com/artifact-registry/docs/reference/rest/v1/projects.locations.repositories.mavenArtifacts/list
-
https://cloud.google.com/artifact-registry/docs/reference/rest/v1/projects.locations.repositories.npmPackages/list
-
https://cloud.google.com/artifact-registry/docs/reference/rest/v1/projects.locations.repositories.pythonPackages/list

<!--
Use the following steps to ensure your PR is ready to be reviewed

- [ ] Read the [contribution guidelines](../blob/main/CONTRIBUTING.md)
🧑‍🎓
- [ ] Test locally on your own infrastructure
- [ ] Run `go fmt` to format your code 🖊
- [ ] Lint your changes via `golangci-lint run` 🚨 (install golangci-lint
[here](https://golangci-lint.run/usage/install/#local-installation))
- [ ] Update or add tests 🧪
- [ ] Ensure the status checks below are successful ✅
--->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Automatically merge once required checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GCP Fails to Fetch Cloud Run Services

4 participants