Skip to content

Commit b67d27e

Browse files
authored
Merge branch 'main' into remove-reflect-methods
2 parents 948fce1 + c82d006 commit b67d27e

File tree

24 files changed

+539
-115
lines changed

24 files changed

+539
-115
lines changed

.release-please-manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
".": "4.78.0"
2+
".": "4.80.1"
33
}

CHANGELOG.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,53 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [4.80.1](https://github.com/cloudquery/plugin-sdk/compare/v4.80.0...v4.80.1) (2025-05-12)
9+
10+
11+
### Bug Fixes
12+
13+
* **deps:** Update module github.com/cloudquery/codegen to v0.3.27 ([#2148](https://github.com/cloudquery/plugin-sdk/issues/2148)) ([1fd7b1e](https://github.com/cloudquery/plugin-sdk/commit/1fd7b1e95a262017152616290da791e08fc497b8))
14+
* **deps:** Update module github.com/cloudquery/codegen to v0.3.28 ([#2150](https://github.com/cloudquery/plugin-sdk/issues/2150)) ([4d1409c](https://github.com/cloudquery/plugin-sdk/commit/4d1409c402fd5e8b793ee0586e9d2ec8c3812cd5))
15+
* **deps:** Update module github.com/cloudquery/plugin-pb-go to v1.26.11 ([#2149](https://github.com/cloudquery/plugin-sdk/issues/2149)) ([a904b46](https://github.com/cloudquery/plugin-sdk/commit/a904b461a5ca7eebb0c6f4c807db9aa23011a2b5))
16+
* **deps:** Update module github.com/samber/lo to v1.49.1 ([#2139](https://github.com/cloudquery/plugin-sdk/issues/2139)) ([f11b5e6](https://github.com/cloudquery/plugin-sdk/commit/f11b5e67d95af1f54410236bbefb071c01c5df82))
17+
18+
## [4.80.0](https://github.com/cloudquery/plugin-sdk/compare/v4.79.1...v4.80.0) (2025-05-09)
19+
20+
21+
### Features
22+
23+
* Add SensitiveColumns to tables schema ([#2134](https://github.com/cloudquery/plugin-sdk/issues/2134)) ([e95674f](https://github.com/cloudquery/plugin-sdk/commit/e95674f255c7225a9b5d593daf54c0a373c2ef50))
24+
25+
26+
### Bug Fixes
27+
28+
* **deps:** Update module github.com/cloudquery/cloudquery-api-go to v1.13.9 ([#2143](https://github.com/cloudquery/plugin-sdk/issues/2143)) ([77d4b9b](https://github.com/cloudquery/plugin-sdk/commit/77d4b9b317dfa06ccbf4c0696adcdaa6de724173))
29+
30+
## [4.79.1](https://github.com/cloudquery/plugin-sdk/compare/v4.79.0...v4.79.1) (2025-05-03)
31+
32+
33+
### Bug Fixes
34+
35+
* **deps:** Update golang.org/x/exp digest to 7e4ce0a ([#2135](https://github.com/cloudquery/plugin-sdk/issues/2135)) ([efb8813](https://github.com/cloudquery/plugin-sdk/commit/efb8813182f813a25ec9bf0ba465f5a1419c937d))
36+
* **deps:** Update module github.com/grpc-ecosystem/go-grpc-middleware/v2 to v2.3.1 ([#2136](https://github.com/cloudquery/plugin-sdk/issues/2136)) ([5534187](https://github.com/cloudquery/plugin-sdk/commit/553418708ebc1fcbc1eb13ea29907346258aa36b))
37+
* **deps:** Update module github.com/rs/zerolog to v1.34.0 ([#2138](https://github.com/cloudquery/plugin-sdk/issues/2138)) ([e1bcb05](https://github.com/cloudquery/plugin-sdk/commit/e1bcb0532b7b1b42e38571254c655769296240e4))
38+
* **deps:** Update module google.golang.org/grpc to v1.72.0 ([#2141](https://github.com/cloudquery/plugin-sdk/issues/2141)) ([a0f27a3](https://github.com/cloudquery/plugin-sdk/commit/a0f27a3ca01a870912ad7afb9ec92fb8e52f78b7))
39+
* Pass installation ID from env for usage report ([#2140](https://github.com/cloudquery/plugin-sdk/issues/2140)) ([4d36bfb](https://github.com/cloudquery/plugin-sdk/commit/4d36bfba0a572995c11e10fc2e448e36beb67208))
40+
41+
## [4.79.0](https://github.com/cloudquery/plugin-sdk/compare/v4.78.0...v4.79.0) (2025-04-28)
42+
43+
44+
### Features
45+
46+
* Add transformer to update table description with its table options ([#2128](https://github.com/cloudquery/plugin-sdk/issues/2128)) ([2387b57](https://github.com/cloudquery/plugin-sdk/commit/2387b5765133a03e202f332290bfd94c2ac50eab))
47+
* Show plugin version in plugin server logs ([#2124](https://github.com/cloudquery/plugin-sdk/issues/2124)) ([be08606](https://github.com/cloudquery/plugin-sdk/commit/be08606413a4392d04d3e388ccc1edbe64439c14))
48+
49+
50+
### Bug Fixes
51+
52+
* **deps:** Update module github.com/cloudquery/plugin-pb-go to v1.26.10 ([#2132](https://github.com/cloudquery/plugin-sdk/issues/2132)) ([775d537](https://github.com/cloudquery/plugin-sdk/commit/775d537cc9ee69ee548d69be67e7172baa03fcab))
53+
* Prevent deadlock in transformer ([#2130](https://github.com/cloudquery/plugin-sdk/issues/2130)) ([a65b101](https://github.com/cloudquery/plugin-sdk/commit/a65b101d05ee43bc1f1f0033736ede756ee55604))
54+
855
## [4.78.0](https://github.com/cloudquery/plugin-sdk/compare/v4.77.0...v4.78.0) (2025-04-22)
956

1057

CONTRIBUTING.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ This is the repository for CloudQuery SDK. If you are looking for CloudQuery CLI
77
## Links
88

99
- [Homepage](https://cloudquery.io)
10-
- [Documentation](https://docs.cloudquery.io)
10+
- [Platform](https://docs.cloudquery.io)
11+
- [Documentation](https://cli-docs.cloudquery.io)
1112
- [CLI and Plugins Monorepo](https://github.com/cloudquery/cloudquery)
1213
- [Community](https://community.cloudquery.io)
1314

docs/table_options.go

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
package docs
2+
3+
import (
4+
"encoding/json"
5+
"errors"
6+
"reflect"
7+
"regexp"
8+
"strings"
9+
10+
schemaDocs "github.com/cloudquery/codegen/jsonschema/docs"
11+
"github.com/cloudquery/plugin-sdk/v4/schema"
12+
invoschema "github.com/invopop/jsonschema"
13+
)
14+
15+
func TableOptionsDescriptionTransformer(tableOptions any, jsonSchema string) (schema.Transform, error) {
16+
var sc invoschema.Schema
17+
if err := json.Unmarshal([]byte(jsonSchema), &sc); err != nil {
18+
return nil, err
19+
}
20+
tableNamesToOptionsDocs := make(map[string]string)
21+
tableOptionsType := reflect.ValueOf(tableOptions).Elem().Type()
22+
for i := range tableOptionsType.NumField() {
23+
field := tableOptionsType.Field(i)
24+
fieldType := field.Type.String()
25+
if strings.Contains(fieldType, ".") {
26+
fieldType = strings.Split(fieldType, ".")[1]
27+
}
28+
defValue, ok := sc.Definitions[fieldType]
29+
if !ok {
30+
return nil, errors.New("definition not found for " + field.Name)
31+
}
32+
tableName := strings.Split(field.Tag.Get("json"), ",")[0]
33+
if tableName == "" {
34+
return nil, errors.New("json tag not found for table " + field.Name)
35+
}
36+
newRoot := sc
37+
newRoot.ID = "Table Options"
38+
newRoot.Ref = "#/$defs/" + "Table Options"
39+
newRoot.Definitions["Table Options"] = defValue
40+
sch, _ := json.Marshal(newRoot)
41+
doc, _ := schemaDocs.Generate(sch, 1)
42+
tocRegex := regexp.MustCompile(`# Table of contents[\s\S]+?##`)
43+
tableNamesToOptionsDocs[tableName] = tocRegex.ReplaceAllString(doc, "##")
44+
}
45+
46+
return func(table *schema.Table) error {
47+
if tableNamesToOptionsDocs[table.Name] != "" {
48+
table.Description = table.Description + "\n\n" + tableNamesToOptionsDocs[table.Name]
49+
}
50+
return nil
51+
}, nil
52+
}

docs/table_options_test.go

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
package docs
2+
3+
import (
4+
_ "embed"
5+
"testing"
6+
7+
"github.com/cloudquery/plugin-sdk/v4/docs/testdata"
8+
"github.com/cloudquery/plugin-sdk/v4/schema"
9+
"github.com/stretchr/testify/require"
10+
)
11+
12+
//go:embed testdata/schema.json
13+
var testSchema string
14+
15+
type testTableOptions struct {
16+
Dummy testdata.DummyTableOptions `json:"dummy,omitempty"`
17+
}
18+
19+
var testTable = &schema.Table{
20+
Name: "dummy",
21+
Description: "This is a dummy table",
22+
}
23+
24+
func TestTableOptionsDescriptionTransformer(t *testing.T) {
25+
type args struct {
26+
tableOptions any
27+
jsonSchema string
28+
table *schema.Table
29+
}
30+
tests := []struct {
31+
name string
32+
args args
33+
wantDesc string
34+
wantErr bool
35+
}{
36+
{
37+
name: "adds table options to description",
38+
args: args{tableOptions: &testTableOptions{}, jsonSchema: testSchema, table: testTable},
39+
wantDesc: "This is a dummy table\n\n## <a name=\"Table Options\"></a>Table Options\n\n DummyTableOptions contains configuration for the dummy table\n\n* `filter` (`string`)\n",
40+
},
41+
{
42+
name: "leaves description unchanged when table doesn't have options",
43+
args: args{tableOptions: &testTableOptions{}, jsonSchema: testSchema, table: &schema.Table{Description: "Foobar"}},
44+
wantDesc: "Foobar",
45+
},
46+
{
47+
name: "errors out when table options don't match schema",
48+
wantErr: true,
49+
args: args{tableOptions: &testTableOptions{}, jsonSchema: "", table: testTable},
50+
},
51+
}
52+
for _, tt := range tests {
53+
t.Run(tt.name, func(t *testing.T) {
54+
transformer, err := TableOptionsDescriptionTransformer(tt.args.tableOptions, tt.args.jsonSchema)
55+
if tt.wantErr {
56+
require.Error(t, err)
57+
return
58+
}
59+
require.NoError(t, transformer(tt.args.table))
60+
require.Equal(t, tt.wantDesc, tt.args.table.Description)
61+
})
62+
}
63+
}

docs/testdata/schema.json

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "test/spec",
4+
"$ref": "#/$defs/Spec",
5+
"$defs": {
6+
"Spec": {
7+
"properties": {
8+
"table_options": {
9+
"$ref": "#/$defs/TableOptions",
10+
"description": "TableOptions is a set of options to override the defaults for certain tables."
11+
}
12+
},
13+
"additionalProperties": false,
14+
"type": "object"
15+
},
16+
"TableOptions": {
17+
"properties": {
18+
"dummy": {
19+
"oneOf": [
20+
{
21+
"$ref": "#/$defs/DummyTableOptions",
22+
"description": "Options for the dummy table."
23+
},
24+
{
25+
"type": "null"
26+
}
27+
]
28+
}
29+
},
30+
"additionalProperties": false,
31+
"type": "object"
32+
},
33+
"DummyTableOptions": {
34+
"properties": {
35+
"filter": {
36+
"type": "string"
37+
}
38+
},
39+
"additionalProperties": false,
40+
"type": "object",
41+
"description": "DummyTableOptions contains configuration for the dummy table"
42+
}
43+
}
44+
}

docs/testdata/tableoptions.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package testdata
2+
3+
type DummyTableOptions struct {
4+
Filter string `json:"filter,omitempty"`
5+
}

examples/simple_plugin/go.mod

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
module github.com/cloudquery/plugin-sdk/examples/simple_plugin
22

3-
go 1.23.0
3+
go 1.23.4
44

55
toolchain go1.24.1
66

77
require (
88
github.com/apache/arrow-go/v18 v18.2.0
9-
github.com/cloudquery/plugin-sdk/v4 v4.78.0
10-
github.com/rs/zerolog v1.33.0
9+
github.com/cloudquery/plugin-sdk/v4 v4.80.1
10+
github.com/rs/zerolog v1.34.0
1111
)
1212

1313
require (
@@ -32,8 +32,9 @@ require (
3232
github.com/bahlo/generic-list-go v0.2.0 // indirect
3333
github.com/buger/jsonparser v1.1.1 // indirect
3434
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
35-
github.com/cloudquery/cloudquery-api-go v1.13.8 // indirect
36-
github.com/cloudquery/plugin-pb-go v1.26.9 // indirect
35+
github.com/cloudquery/cloudquery-api-go v1.13.9 // indirect
36+
github.com/cloudquery/codegen v0.3.28 // indirect
37+
github.com/cloudquery/plugin-pb-go v1.26.11 // indirect
3738
github.com/cloudquery/plugin-sdk/v2 v2.7.0 // indirect
3839
github.com/davecgh/go-spew v1.1.1 // indirect
3940
github.com/ghodss/yaml v1.0.0 // indirect
@@ -42,7 +43,7 @@ require (
4243
github.com/goccy/go-json v0.10.5 // indirect
4344
github.com/google/flatbuffers v25.2.10+incompatible // indirect
4445
github.com/google/uuid v1.6.0 // indirect
45-
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.2.0 // indirect
46+
github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.3.1 // indirect
4647
github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.1 // indirect
4748
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
4849
github.com/hashicorp/go-retryablehttp v0.7.7 // indirect
@@ -56,7 +57,7 @@ require (
5657
github.com/oapi-codegen/runtime v1.1.1 // indirect
5758
github.com/pierrec/lz4/v4 v4.1.22 // indirect
5859
github.com/pmezard/go-difflib v1.0.0 // indirect
59-
github.com/samber/lo v1.47.0 // indirect
60+
github.com/samber/lo v1.49.1 // indirect
6061
github.com/santhosh-tekuri/jsonschema/v6 v6.0.1 // indirect
6162
github.com/spf13/cobra v1.9.0 // indirect
6263
github.com/spf13/pflag v1.0.6 // indirect
@@ -77,17 +78,17 @@ require (
7778
go.opentelemetry.io/otel/sdk/metric v1.34.0 // indirect
7879
go.opentelemetry.io/otel/trace v1.34.0 // indirect
7980
go.opentelemetry.io/proto/otlp v1.5.0 // indirect
80-
golang.org/x/exp v0.0.0-20250305212735-054e65f0b394 // indirect
81+
golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect
8182
golang.org/x/mod v0.24.0 // indirect
82-
golang.org/x/net v0.38.0 // indirect
83-
golang.org/x/sync v0.12.0 // indirect
84-
golang.org/x/sys v0.31.0 // indirect
85-
golang.org/x/text v0.23.0 // indirect
86-
golang.org/x/tools v0.31.0 // indirect
83+
golang.org/x/net v0.39.0 // indirect
84+
golang.org/x/sync v0.13.0 // indirect
85+
golang.org/x/sys v0.32.0 // indirect
86+
golang.org/x/text v0.24.0 // indirect
87+
golang.org/x/tools v0.32.0 // indirect
8788
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da // indirect
88-
google.golang.org/genproto/googleapis/api v0.0.0-20250115164207-1a7da9e5054f // indirect
89-
google.golang.org/genproto/googleapis/rpc v0.0.0-20250115164207-1a7da9e5054f // indirect
90-
google.golang.org/grpc v1.71.1 // indirect
89+
google.golang.org/genproto/googleapis/api v0.0.0-20250218202821-56aae31c358a // indirect
90+
google.golang.org/genproto/googleapis/rpc v0.0.0-20250218202821-56aae31c358a // indirect
91+
google.golang.org/grpc v1.72.0 // indirect
9192
google.golang.org/protobuf v1.36.6 // indirect
9293
gopkg.in/yaml.v2 v2.4.0 // indirect
9394
gopkg.in/yaml.v3 v3.0.1 // indirect

0 commit comments

Comments
 (0)