fix(policy): Use firebase instead of GitHub to get latest version#618
Merged
Conversation
erezrokah
commented
May 2, 2022
| } | ||
|
|
||
| valid := make([]*version.Version, 0) | ||
| for _, d := range doc.Documents { |
Member
Author
There was a problem hiding this comment.
This is how our UI does it https://github.com/cloudquery/cq-website/blob/ef3e714533610edfbd50d842d87bd13019dcad91/hub/src/services/firebase.ts#L37 (internal link).
We could make the data easier to consume, but that will probably be a breaking change for our Website
erezrokah
commented
May 2, 2022
|
|
||
| var ( | ||
| repoToFirebasePath = map[string]string{ | ||
| "cloudquery-policies": "cloudquery", |
Member
Author
There was a problem hiding this comment.
Mapping between the repo name to the Firebase path
erezrokah
commented
May 2, 2022
| } | ||
|
|
||
| func (h Hub) getLatestRelease(ctx context.Context, organization, providerName string) (string, error) { | ||
| versions, err := url.Parse(fmt.Sprintf(h.url+"/versions", organization, providerName)) |
Member
Author
There was a problem hiding this comment.
Extracted to a new Firebase struct
Member
Author
|
Looking at the failed tests |
erezrokah
commented
May 2, 2022
| ExpectedFound bool | ||
| ExpectedError error | ||
| }{ | ||
| { |
Member
Author
There was a problem hiding this comment.
The test_policy is not in our Hub
disq
approved these changes
May 2, 2022
| url string | ||
| } | ||
|
|
||
| func NewFirebaseClient(registryUrl string) *FirebaseClient { |
Member
There was a problem hiding this comment.
Suggested change
| func NewFirebaseClient(registryUrl string) *FirebaseClient { | |
| func New(registryUrl string) *Client { |
Member
Author
There was a problem hiding this comment.
Thanks for the review! Good point, done in 1c8f776
This was referenced May 2, 2022
This was referenced May 8, 2022
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes https://github.com/cloudquery/cloudquery-issues/issues/324 (internal issue).
This PR gets the policy latest version from Firebase instead of GitHub to avoid hitting rate limits.
To reproduce run
cloudquery policy run github::github.com/cloudquery-policies/awsmultiple times.This is the smallest change I could think of to fix the issue.
Example data https://firestore.googleapis.com/v1/projects/hub-cloudquery/databases/(default)/documents/orgs/cloudquery/policies/aws/versions?mask.fieldPaths=policy.Name