@@ -15,7 +15,13 @@ import (
1515type 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
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
1925}
2026
2127func NewDestinationClient (cc grpc.ClientConnInterface ) * DestinationClient {
@@ -24,7 +30,7 @@ func NewDestinationClient(cc grpc.ClientConnInterface) *DestinationClient {
2430 }
2531}
2632
27- func NewLocalDestinationClient (p plugins.DestinationPlugin ) * DestinationClient {
33+ func NewLocalDestinationClient (p * plugins.DestinationPlugin ) * DestinationClient {
2834 return & DestinationClient {
2935 localClient : p ,
3036 }
@@ -52,17 +58,6 @@ func (c *DestinationClient) Version(ctx context.Context) (string, error) {
5258 return res .Version , nil
5359}
5460
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-
6661func (c * DestinationClient ) Initialize (ctx context.Context , spec specs.Destination ) error {
6762 if c .localClient != nil {
6863 return c .localClient .Initialize (ctx , spec )
@@ -80,6 +75,23 @@ func (c *DestinationClient) Initialize(ctx context.Context, spec specs.Destinati
8075 return nil
8176}
8277
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+
8395func (c * DestinationClient ) Migrate (ctx context.Context , tables []* schema.Table ) error {
8496 if c .localClient != nil {
8597 return c .localClient .Migrate (ctx , tables )
0 commit comments