Skip to content

feat: Addon CLI#14564

Merged
disq merged 17 commits intomainfrom
feat/addon_cli
Oct 18, 2023
Merged

feat: Addon CLI#14564
disq merged 17 commits intomainfrom
feat/addon_cli

Conversation

@disq
Copy link
Copy Markdown
Member

@disq disq commented Oct 16, 2023

Implements https://github.com/cloudquery/cloudquery-issues/issues/600

cloudquery install is now cloudquery plugin install (cloudquery install still works...)
cloudquery publish => cloudquery plugin publish

new command: cloudquery addon publish

TeamName string `json:"team_name"`
AddonName string `json:"addon_name"`
// AddonType string `json:"addon_type"` // unused
// AddonFormat string `json:"addon_format"` // unused
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

These fields belong to the addon entry and not addon_version, so there's no use for them here. We could try to GET the addon and compare/verify the values if we really want to make sure.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Seems fine, though I would probably still read the properties, but just not use them

name := fmt.Sprintf("%s/%s@%s", manifest.TeamName, manifest.AddonName, version)
fmt.Printf("Publishing %s to CloudQuery Hub...\n", name)

c, err := cloudquery_api.NewClientWithResponses(getEnvOrDefault("CLOUDQUERY_API_URL", defaultAPIURL),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Let's create a constant in constants.go for CLOUDQUERY_API_URL, since it's used in multiple places now

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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.

Nice, looks good 👍

manifest.PluginDeps = []string{}
}
if manifest.AddonDeps == nil {
manifest.AddonDeps = []string{}
Copy link
Copy Markdown
Member Author

@disq disq Oct 18, 2023

Choose a reason for hiding this comment

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

Otherwise we get:

Error: failed to create new draft version: 400: request body has an error: doesn't match schema: Error at "/addon_deps": Value is not nullable


func createNewAddonDraftVersion(ctx context.Context, c *cloudquery_api.ClientWithResponses, manifest ManifestJSONV1, version, manifestDir, zipPath string) error {
if manifest.PluginDeps == nil {
manifest.PluginDeps = []string{}
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This shouldn't happen, but it's better to get a better error if the plugin_deps is empty, something like:

Error: failed to create new draft version: 400: request body has an error: doesn't match schema: Error at "/plugin_deps": minimum number of items is 1

Rather than:

Error: failed to create new draft version: 400: request body has an error: doesn't match schema: Error at "/plugin_deps": Value is not nullable

@disq disq added the automerge Automatically merge once required checks pass label Oct 18, 2023
mkdir -p ~/.local/share/cloudquery
echo ${{ secrets.CQ_CI_CLOUDQUERY_HUB_TOKEN }} > ~/.local/share/cloudquery/token
cloudquery publish cloudquery/${{ needs.prepare.outputs.plugin_name }} --finalize
cloudquery plugin publish cloudquery/${{ needs.prepare.outputs.plugin_name }} --finalize
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For this to work we actually need to release a new CLI version and update it in the workflow here

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See https://github.com/cloudquery/cloudquery/actions/runs/6562442141/job/17824393847#step:11:7.

I'll release #14659 and renovate should handle the update for us

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


## [3.25.0](cli-v3.24.0...cli-v3.25.0) (2023-10-18)


### Features

* Addon CLI ([#14564](#14564)) ([33e7833](33e7833))


### Bug Fixes

* **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.15.2 ([#14662](#14662)) ([e274fe4](e274fe4))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
hydratim pushed a commit to hydratim/cloudquery that referenced this pull request Oct 20, 2023
Co-authored-by: Kemal Hadimli <disq@users.noreply.github.com>
hydratim pushed a commit to hydratim/cloudquery that referenced this pull request Oct 20, 2023
🤖 I have created a release *beep* *boop*
---


## [3.25.0](cloudquery/cloudquery@cli-v3.24.0...cli-v3.25.0) (2023-10-18)


### Features

* Addon CLI ([cloudquery#14564](cloudquery#14564)) ([33e7833](cloudquery@33e7833))


### Bug Fixes

* **deps:** Update module github.com/cloudquery/plugin-sdk/v4 to v4.15.2 ([cloudquery#14662](cloudquery#14662)) ([e274fe4](cloudquery@e274fe4))

---
This PR was generated with [Release Please](https://github.com/googleapis/release-please). See [documentation](https://github.com/googleapis/release-please#release-please).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/ci area/cli area/website automerge Automatically merge once required checks pass

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants