-
Notifications
You must be signed in to change notification settings - Fork 26
feat: Add publish command #1143
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
Conversation
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1143 +/- ##
==========================================
- Coverage 48.71% 48.68% -0.03%
==========================================
Files 85 86 +1
Lines 7833 8000 +167
==========================================
+ Hits 3816 3895 +79
- Misses 3682 3755 +73
- Partials 335 350 +15
☔ View full report in Codecov by Sentry. |
⏱️ Benchmark results
|
plugin/plugin_publish.go
Outdated
| ShortDescription: p.shortDescription, | ||
| Description: p.description, | ||
| Categories: p.categories, | ||
| Protocols: []int{3}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small thing but it would be nice if we can rather import the supported protocols as a constant from the relevant package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree. It was outdated, It's moved now to serve.
erezrokah
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR has two features:
- Adding a manifest file to describe a plugin
- Adding a publish command for plugins to replace Go Releaser (depends on 1.)
Regarding the first feature, I think usually it's done the other way around, where you have a static manifest file, and the runtime reads properties from it (for example in Go we can embed a JSON file will all the properties).
Then during publishing we just copy the file.
Having a static file makes it easier to declare, modify (for example during release to inject a version) and validate (e.g. if we have a JSON schema of the manifest).
At the moment the plugin manifest properties are spread around the code, and you need to invoke publish to know what is the manifest.
Regarding 2. I think it's good to have plugins more "self contained", we should make sure we don't reimplement Go Releaser, for example at the moment we:
- Set some env variables
- Pack policies with plugins
- Sign plugins with a checksum
- Some plugins can only run
publishin a specific environment https://github.com/cloudquery/cloudquery/blob/db142bc867e631f00cb06f21a4a0566210fc7fd0/.github/workflows/release_plugin_dest_duckdb.yml#L11
I would maybe split this PR into 2:
- Create the designated manifest file format, embed it and read the properties from it
- The publish command
With that being said since this is a new feature and doesn't breaking anything we can move forward and see how it work
| func (s *PluginServe) writeManifest(ctx context.Context, dir string) error { | ||
| manifest := Manifest{ | ||
| Name: s.plugin.Name(), | ||
| Version: s.plugin.Version(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we're missing the part of injecting the plugin version via Go Releaser here https://github.com/cloudquery/cloudquery/blob/db142bc867e631f00cb06f21a4a0566210fc7fd0/plugins/.goreleaser.yaml#L12
Not sure how this would work in this approach. We could configure release please maybe to update the version in the go code like we do with python, see https://github.com/cloudquery/cloudquery/pull/12869/files#diff-e10085e6cd58ab584a2a0fd98e5b4bcdda801327fe2f8e571ee049a3bceaf1e0L13
serve/publish.go
Outdated
| }); err != nil { | ||
| return err | ||
| } | ||
| if err := s.writeTablesJson(cmd.Context(), distPath); err != nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's a bit of overlap here with the CLI tables command. Not sure what to do about it yet, just stating it.
Also this is for our internal usage so maybe better to have it separated.
I would create a schema.json for both the manifest and tables so we can validate those. We'll need to be aware that changing/adding things in the Column/Table structs can break the JSON
Thanks for the review. Few notes on 1,2.
|
Good point, maybe for other SDKs it would make sense to use a static file instead of code to define the plugin. Chrome extensions also use a static file, VS Code extensions too, they (ab)use
The user still needs to look up the docs to know which methods to implement. If we read the data from a file they would only need to create the file, instead of implementing the
Plugins can declare which SDK version they use (see Terraform and Figma).
👍 Mostly pointing out that we would need the build command to support the current features we use. Also we would need to somehow handle the case it can only run in a specific environment gracefully. |
|
Looks like the tests are failing on MacOS |
🤖 I have created a release *beep* *boop* --- ## [4.5.0](v4.4.0...v4.5.0) (2023-08-14) ### Features * Add publish command ([#1143](#1143)) ([fdd44d5](fdd44d5)) ### Bug Fixes * **deps:** Update github.com/cloudquery/arrow/go/v13 digest to e9683e1 ([#1144](#1144)) ([763c549](763c549)) * Scalar timestamp parsing ([#1109](#1109)) ([c15b214](c15b214)) --- This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
As we are productionizing and rolling out our own registry we need to move from our format being documented in a yaml file inside goreleaser to being part of our code and part of the sdk.
Right now this just build the package without publishing as our backend is not ready but nailing down this will also help finalize the backend which Im working on as well.
The idea here is not to introduce a
package.jsonfile like in npm and then create yet another language insidejsonoryamlconfig but rather the other way around and use all the information we already have from the plugin author and build a package with a manifest.json so everything is configurable in the code.we will have two types of packages in our registry:
native(for languages like Go/Rust/C)docker(for runtime language like .net, Java, Python)For native this will looks the following:
manifest will look the following:
This will make sure the cloudquery package registry has all the information needed to publish it, display it on CloudQuery Hub and give it for client to download without running the plugins itself. Not running the plugin itself is important for the following reasons:
Once it gets a first review I'll also add tests.