Skip to content

Commit 06275b6

Browse files
authored
feat: Revert "feat: Generate full example configs from within SDK" (#70)
Revert "feat: Generate full example configs from within SDK (#61)" This reverts commit e4f49e9.
1 parent 0e68c6f commit 06275b6

26 files changed

+472
-1099
lines changed

clients/destination.go

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,7 @@ import (
1515
type DestinationClient struct {
1616
pbClient pb.DestinationClient
1717
// this can be used if we have a plugin which is compiled in, so we don't need to do any grpc requests
18-
localClient *plugins.DestinationPlugin
19-
}
20-
21-
// DestinationExampleConfigOptions can be used to override default example values.
22-
type DestinationExampleConfigOptions struct {
23-
Path string
24-
Registry specs.Registry
18+
localClient plugins.DestinationPlugin
2519
}
2620

2721
func NewDestinationClient(cc grpc.ClientConnInterface) *DestinationClient {
@@ -30,7 +24,7 @@ func NewDestinationClient(cc grpc.ClientConnInterface) *DestinationClient {
3024
}
3125
}
3226

33-
func NewLocalDestinationClient(p *plugins.DestinationPlugin) *DestinationClient {
27+
func NewLocalDestinationClient(p plugins.DestinationPlugin) *DestinationClient {
3428
return &DestinationClient{
3529
localClient: p,
3630
}
@@ -58,6 +52,17 @@ func (c *DestinationClient) Version(ctx context.Context) (string, error) {
5852
return res.Version, nil
5953
}
6054

55+
func (c *DestinationClient) GetExampleConfig(ctx context.Context) (string, error) {
56+
if c.localClient != nil {
57+
return c.localClient.ExampleConfig(), nil
58+
}
59+
res, err := c.pbClient.GetExampleConfig(ctx, &pb.GetExampleConfig_Request{})
60+
if err != nil {
61+
return "", err
62+
}
63+
return res.Config, nil
64+
}
65+
6166
func (c *DestinationClient) Initialize(ctx context.Context, spec specs.Destination) error {
6267
if c.localClient != nil {
6368
return c.localClient.Initialize(ctx, spec)
@@ -75,23 +80,6 @@ func (c *DestinationClient) Initialize(ctx context.Context, spec specs.Destinati
7580
return nil
7681
}
7782

78-
func (c *DestinationClient) GetExampleConfig(ctx context.Context, opts DestinationExampleConfigOptions) (string, error) {
79-
if c.localClient != nil {
80-
return c.localClient.ExampleConfig(plugins.DestinationExampleConfigOptions{
81-
Registry: opts.Registry,
82-
Path: opts.Path,
83-
})
84-
}
85-
res, err := c.pbClient.GetExampleConfig(ctx, &pb.GetDestinationExampleConfig_Request{
86-
Registry: opts.Registry.String(),
87-
Path: opts.Path,
88-
})
89-
if err != nil {
90-
return "", err
91-
}
92-
return res.Config, nil
93-
}
94-
9583
func (c *DestinationClient) Migrate(ctx context.Context, tables []*schema.Table) error {
9684
if c.localClient != nil {
9785
return c.localClient.Migrate(ctx, tables)

clients/source.go

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,6 @@ type FetchResultMessage struct {
2222
Resource []byte
2323
}
2424

25-
// SourceExampleConfigOptions can be used to override default example values.
26-
type SourceExampleConfigOptions struct {
27-
Path string
28-
Registry specs.Registry
29-
}
30-
3125
func NewSourceClient(cc grpc.ClientConnInterface) *SourceClient {
3226
return &SourceClient{
3327
pbClient: pb.NewSourceClient(cc),
@@ -50,11 +44,8 @@ func (c *SourceClient) Version(ctx context.Context) (string, error) {
5044
return res.Version, nil
5145
}
5246

53-
func (c *SourceClient) ExampleConfig(ctx context.Context, opts SourceExampleConfigOptions) (string, error) {
54-
res, err := c.pbClient.GetExampleConfig(ctx, &pb.GetSourceExampleConfig_Request{
55-
Registry: opts.Registry.String(),
56-
Path: opts.Path,
57-
})
47+
func (c *SourceClient) ExampleConfig(ctx context.Context) (string, error) {
48+
res, err := c.pbClient.GetExampleConfig(ctx, &pb.GetExampleConfig_Request{})
5849
if err != nil {
5950
return "", fmt.Errorf("failed to get example config: %w", err)
6051
}

codegen/doc.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
// codgen helps autogenerate cloudquery plugins configured by definition
1+
//codgen helps autogenerate cloudquery plugins configured by definition
22
package codegen

docs/source_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package docs
22

33
import (
44
"context"
5+
"io/ioutil"
56
"os"
67
"path"
78
"testing"
@@ -99,7 +100,7 @@ func TestGenerateSourcePluginDocs(t *testing.T) {
99100

100101
for _, exp := range expectFiles {
101102
output := path.Join(tmpdir, exp.Name)
102-
got, err := os.ReadFile(output)
103+
got, err := ioutil.ReadFile(output)
103104
if err != nil {
104105
t.Fatalf("error reading %q: %v ", exp.Name, err)
105106
}

0 commit comments

Comments
 (0)