Skip to content

feat: Handle resolving of empty maps and slices#430

Merged
kodiakhq[bot] merged 3 commits intocloudquery:mainfrom
shimonp21:feat_json_handling_map_stringstring
Nov 25, 2022
Merged

feat: Handle resolving of empty maps and slices#430
kodiakhq[bot] merged 3 commits intocloudquery:mainfrom
shimonp21:feat_json_handling_map_stringstring

Conversation

@shimonp21
Copy link
Copy Markdown
Contributor

In fields like 'Tags', 'Annotations' - it is more consistent if empty/null dictionaries show up as an empty JSON object {}, rather than being a postgres "null" or a JSON "null".

Summary


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

  • Read the contribution guidelines 🧑‍🎓
  • Run go fmt to format your code 🖊
  • Lint your changes via golangci-lint run 🚨 (install golangci-lint here)
  • Update or add tests 🧪
  • Ensure the status checks below are successful ✅

Copy link
Copy Markdown
Contributor

@yevgenypats yevgenypats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good but it needs to be implemented in different place.

@shimonp21 shimonp21 changed the title feat: Handle resolving of map[string]string to JSON feat: Handle resolving of empty maps and slices Nov 25, 2022
@github-actions github-actions bot added feat and removed feat labels Nov 25, 2022
Copy link
Copy Markdown
Contributor

@yevgenypats yevgenypats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good. One more improvement.

hermanschaaf added a commit that referenced this pull request Nov 25, 2022
We need slightly elevated permissions to make a comment when the PR
comes from a fork, and I believe this should do the trick.

Github Actions security when it comes to external PRs is a bit of a
minefield, but because we're avoiding the `pull_request_target` trigger
here, and not running any repository code in the delta-action itself, I
believe this is safe.

This should fix the issue we're seeing here
#430
Copy link
Copy Markdown
Contributor

@hermanschaaf hermanschaaf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this change, is it possible to ever get a null entry in a column that has type map or slice? I guess not, so any queries checking for null to see if a particular config exists will need to be updated. That said, I think this change will solve more issues than it will create, and we have to choose one way or another, so I say we go for it.

Copy link
Copy Markdown
Contributor

@yevgenypats yevgenypats left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wanted to request small change

shimonp21 and others added 2 commits November 25, 2022 13:06
In fields like 'Tags', 'Annotations' - it is more consistent if empty/null
dictionaries show up as an empty JSON object `{}`, rather than being a postgres "null"
or a JSON "null". Same for slices.

Note that this PR will not handle the case of nested fields - but it should already be an improvement on current behavior.
@kodiakhq kodiakhq bot merged commit a5672b5 into cloudquery:main Nov 25, 2022
kodiakhq bot pushed a commit that referenced this pull request Nov 25, 2022
🤖 I have created a release *beep* *boop*
---


## [1.9.0](v1.8.2...v1.9.0) (2022-11-25)


### Features

* Handle resolving of empty maps and slices ([#430](#430)) ([a5672b5](a5672b5))


### Bug Fixes

* Fix docs for deeply nested tables ([#434](#434)) ([48e0466](48e0466))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
shimonp21 added a commit to cloudquery/cloudquery that referenced this pull request Nov 28, 2022
<!-- 🎉 Thank you for making CloudQuery awesome by submitting a PR 🎉 -->

#### Summary

1) Depends on cloudquery/plugin-sdk#430.
2) Caveat: This API doesn't support all authentication options (if
trying to use application-default credentials, returns:
```
2:50PM ERR table resolver finished with error error="rpc error: code = PermissionDenied desc = Your application has authenticated using end user credentials from the Google Cloud SDK or Google Cloud Shell which are not supported by the apikeys.googleapis.com. We recommend configuring the billing/quota_project setting in gcloud or using a service account through the auth/impersonate_service_account setting. For more information about service accounts and how to use them in your application, see https://cloud.google.com/docs/authentication/. If you are getting this error with curl or similar tools, you may need to specify 'X-Goog-User-Project' HTTP header for quota and billing purposes. For more information regarding 'X-Goog-User-Project' header, please check https://cloud.google.com/apis/docs/system-parameters.\nerror details: name = ErrorInfo reason = SERVICE_DISABLED domain = googleapis.com metadata = map[consumer:projects/<...> service:apikeys.googleapis.com]" client=cq-playground module=gcp-src table=gcp_apikeys_keys
```
The API was tested with service-account credentials (via
GOOGLE_APPLICATION_CREDENTIALS) and worked OK.

<!--
Explain what problem this PR addresses
-->

<!--
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants