-
Notifications
You must be signed in to change notification settings - Fork 26
Draft: Validation warnings #272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,8 @@ import ( | |
| "encoding/json" | ||
| "errors" | ||
| "fmt" | ||
| "google.golang.org/grpc/codes" | ||
| "google.golang.org/grpc/status" | ||
| "io" | ||
| "net" | ||
| "os" | ||
|
|
@@ -195,6 +197,26 @@ func (c *SourceClient) GetTables(ctx context.Context) ([]*schema.Table, error) { | |
| return tables, nil | ||
| } | ||
|
|
||
| func (c *SourceClient) Validate(ctx context.Context, spec specs.Source) (warnings, errors []string, err error) { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apart from the errors shadow/nit, could maybe consider returning a ValidateResult struct instead of the triple return values? But then it would be very similar to the grpc structs,
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah I'd be good with a struct; it's more extensible in the long run too. I don't think it's an issue that it's similar to |
||
| b, err := json.Marshal(spec) | ||
| if err != nil { | ||
| return nil, nil, fmt.Errorf("failed to marshal source spec: %w", err) | ||
| } | ||
| resp, err := c.pbClient.Validate(ctx, &pb.ValidateSource_Request{ | ||
| Spec: b, | ||
| }) | ||
| if err != nil { | ||
| st, ok := status.FromError(err) | ||
| if ok && st.Code() == codes.Unimplemented { | ||
| // Backwards-compatibility with older plugin versions that don't support Validate(). | ||
| // In this case, we only return one warning: that the plugin should be updated. | ||
| return []string{"the version of this plugin is outdated and should be updated"}, nil, nil | ||
| } | ||
| return nil, nil, fmt.Errorf("failed to call Validate: %w", err) | ||
| } | ||
| return resp.Warnings, resp.Errors, nil | ||
| } | ||
|
|
||
| // Sync start syncing for the source client per the given spec and returning the results | ||
| // in the given channel. res is marshaled schema.Resource. We are not unmarshalling this for performance reasons | ||
| // as usually this is sent over-the-wire anyway to a destination plugin | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Maybe temper the wording a bit.
Some advanced features might not be supported by the current version of the CLI, and might lead to breaks in future. Please update using (this link)
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks, good suggestion - I was struggling to find the right wording here :)