Skip to content

Commit 39fc65e

Browse files
authored
feat: Update package command (#1211)
This updates the plugin `package` command (previously called `publish`) to build executables into a `dist` directory that will be consumed by the `cloudquery publish` command for publishing to the registry. Usage example: ``` go run main.go package . v1.2.3 ```
1 parent 179769a commit 39fc65e

File tree

12 files changed

+417
-296
lines changed

12 files changed

+417
-296
lines changed

.github/workflows/lint_markdown.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ jobs:
1616
- name: Vale
1717
uses: errata-ai/vale-action@v2
1818
with:
19-
vale_flags: "--glob=!{docs/testdata/*,CHANGELOG.md,.github/styles/proselint/README.md}"
19+
vale_flags: "--glob=!{docs/testdata/*,CHANGELOG.md,.github/styles/proselint/README.md,examples/simple_plugin/docs/*.md}"
2020
filter_mode: nofilter
2121
env:
2222
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
@@ -31,4 +31,4 @@ jobs:
3131
with:
3232
files: .
3333
config_file: .markdownlint.yaml
34-
ignore_files: "{docs/testdata/*,CHANGELOG.md}"
34+
ignore_files: "{docs/testdata/*,CHANGELOG.md,examples/simple_plugin/docs/*.md}"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Configuration
3+
slug: configuration
4+
description: How to configure the simple_plugin example.
5+
---
6+
7+
# Configuration
8+
9+
This plugin requires no configuration.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
title: Overview
3+
slug: overview
4+
description: Overview of the simple_plugin example.
5+
---
6+
7+
# Overview
8+
9+
This is a simple example of a plugin that is used to test the SDK.

plugin/options.go

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,9 @@ func (m MigrateMode) String() string {
1717

1818
type Option func(*Plugin)
1919

20-
func WithTitle(title string) Option {
20+
func WithBuildTargets(targets []BuildTarget) Option {
2121
return func(p *Plugin) {
22-
p.title = title
23-
}
24-
}
25-
26-
func WithDescription(description string) Option {
27-
return func(p *Plugin) {
28-
p.description = description
29-
}
30-
}
31-
32-
func WithShortDescription(shortDescription string) Option {
33-
return func(p *Plugin) {
34-
p.shortDescription = shortDescription
22+
p.targets = targets
3523
}
3624
}
3725

plugin/plugin.go

Lines changed: 2 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -47,18 +47,10 @@ func (UnimplementedSource) Tables(context.Context, TableOptions) (schema.Tables,
4747
// Plugin is the base structure required to pass to sdk.serve
4848
// We take a declarative approach to API here similar to Cobra
4949
type Plugin struct {
50-
// Name of plugin i.e aws,gcp, azure etc'
50+
// Name of plugin i.e aws, gcp, azure etc
5151
name string
5252
// Version of the plugin
5353
version string
54-
// Title of the plugin as appears in CloudQuery registry
55-
title string
56-
// Short description of the plugin as appears in CloudQuery registry
57-
shortDescription string
58-
// Long description of the plugin as appears in CloudQuery registry
59-
description string
60-
// categories of the plugin as appears in CloudQuery registry
61-
categories []string
6254
// targets to build plugin for
6355
targets []BuildTarget
6456
// Called upon init call to validate and init configuration
@@ -84,9 +76,7 @@ func NewPlugin(name string, version string, newClient NewClientFunc, options ...
8476
version: version,
8577
internalColumns: true,
8678
newClient: newClient,
87-
title: name,
88-
categories: []string{},
89-
targets: buildTargets,
79+
targets: DefaultBuildTargets,
9080
}
9181
for _, opt := range options {
9282
opt(&p)
@@ -104,22 +94,6 @@ func (p *Plugin) Version() string {
10494
return p.version
10595
}
10696

107-
func (p *Plugin) Title() string {
108-
return p.title
109-
}
110-
111-
func (p *Plugin) Description() string {
112-
return p.description
113-
}
114-
115-
func (p *Plugin) ShortDescription() string {
116-
return p.shortDescription
117-
}
118-
119-
func (p *Plugin) Categories() []string {
120-
return p.categories
121-
}
122-
12397
func (p *Plugin) Targets() []BuildTarget {
12498
return p.targets
12599
}

plugin/plugin_package.go

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package plugin
2+
3+
const (
4+
GoOSLinux = "linux"
5+
GoOSWindows = "windows"
6+
GoOSDarwin = "darwin"
7+
8+
GoArchAmd64 = "amd64"
9+
GoArchArm64 = "arm64"
10+
)
11+
12+
type PackageType string
13+
14+
const (
15+
PackageTypeNative PackageType = "native"
16+
)
17+
18+
type BuildTarget struct {
19+
OS string `json:"os"`
20+
Arch string `json:"arch"`
21+
}
22+
23+
var DefaultBuildTargets = []BuildTarget{
24+
{GoOSLinux, GoArchAmd64},
25+
{GoOSWindows, GoArchAmd64},
26+
{GoOSDarwin, GoArchAmd64},
27+
{GoOSDarwin, GoArchArm64},
28+
}

plugin/plugin_publish.go

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)