Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add support for jsonschema #1214

Merged
merged 4 commits into from
Sep 20, 2023
Merged

feat: Add support for jsonschema #1214

merged 4 commits into from
Sep 20, 2023

Conversation

yevgenypats
Copy link
Member

I was a bit blocked on the backend so took a short detour on our SDK. This will be needed for our upcoming cloud version as we need to generate forms automatically for every plugin version.

The JSON schema will also go into the registry backend and we can also integrate it nicely with the hub - with something like https://codesandbox.io/s/material-ui-json-schema-viewer-2u6zq

@codecov
Copy link

codecov bot commented Sep 16, 2023

Codecov Report

Patch coverage: 4.54% and project coverage change: -0.12% ⚠️

Comparison is base (aa01b1f) 48.75% compared to head (b6cd5c5) 48.63%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1214      +/-   ##
==========================================
- Coverage   48.75%   48.63%   -0.12%     
==========================================
  Files          88       88              
  Lines        8240     8262      +22     
==========================================
+ Hits         4017     4018       +1     
- Misses       3850     3869      +19     
- Partials      373      375       +2     
Files Changed Coverage Δ
plugin/options.go 0.00% <0.00%> (ø)
plugin/plugin.go 28.75% <5.55%> (-6.74%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@yevgenypats
Copy link
Member Author

Seems something is off with main tests as don't think this PR relates to the failed tests.

@@ -120,6 +140,17 @@ func (p *Plugin) Init(ctx context.Context, spec []byte, options NewClientOptions
}
defer p.mu.Unlock()
var err error

if p.schemaValidator != nil {
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to validate the top level schema too via JSON schema? Otherwise the validation error messages might be confusing (some in the JSON schema validator format and others in the JSON decoder format). We'll probably need to do this in the CLI

Copy link
Member

Choose a reason for hiding this comment

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

Also maybe you can share how a validation error looks like from the console

@hermanschaaf
Copy link
Member

To fix the test error, I think you need to run go mod tidy in the example plugin directory: https://github.com/cloudquery/plugin-sdk/blob/main/examples/simple_plugin/go.mod

@hermanschaaf
Copy link
Member

For this to be useful in the cloud version, or if we wanted to generate docs from it like the cloudquery tables command, or do basic validation in the CLI before starting a sync, I would have expected this to be added to the gRPC protocol in plugin-pb? Is that still part of the plan?

@yevgenypats
Copy link
Member Author

For this to be useful in the cloud version, or if we wanted to generate docs from it like the cloudquery tables command, or do basic validation in the CLI before starting a sync, I would have expected this to be added to the gRPC protocol in plugin-pb? Is that still part of the plan?

I thought initially that we don't need to expose it via gRPC because we can upload it to the hub as json - this way it's very easy for the frontend to use this JSONschema .

@kodiakhq kodiakhq bot merged commit 2d766dc into main Sep 20, 2023
6 checks passed
@kodiakhq kodiakhq bot deleted the feat/json_schema branch September 20, 2023 09:38
@github-actions
Copy link

⏱️ Benchmark results

  • Glob-8 ns/op: 99.64

kodiakhq bot pushed a commit that referenced this pull request Sep 20, 2023
🤖 I have created a release *beep* *boop*
---


## [4.9.0](v4.8.0...v4.9.0) (2023-09-20)


### Features

* Add support for jsonschema ([#1214](#1214)) ([2d766dc](2d766dc))


### Bug Fixes

* **deps:** Update module github.com/cloudquery/plugin-pb-go to v1.10.0 ([#1220](#1220)) ([aa01b1f](aa01b1f))

---
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 Sep 20, 2023
Documentation generation will fail otherwise.
Follow-up for #1214
kodiakhq bot pushed a commit to cloudquery/cloudquery that referenced this pull request Sep 22, 2023
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.

4 participants