-
Notifications
You must be signed in to change notification settings - Fork 26
chore(docs): Add more godoc to important APIs #118
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
8282264
30f0353
9a79683
31e9bc1
8aca4c3
12eacd3
515e2a3
1d0a9e4
873a584
ac3a859
9aa796d
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 |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // package clients is a wrapper around grpc clients so clients can work | ||
| // with non protobuf structs and handle unmarshaling | ||
| package clients |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,2 +1,2 @@ | ||
| // codgen helps autogenerate cloudquery plugins configured by definition | ||
| // Package codgen helps autogenerate tables for CloudQuery source plugins from Go structs (of relevant SDKs) | ||
| package codegen |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // Package plugins defines APIs for source and destination plugins | ||
| package plugins |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -59,6 +59,8 @@ func addInternalColumns(tables []*schema.Table) { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| // NewSourcePlugin returns a new plugin with a given name, version, tables, newExecutionClient | ||||||
| // and additional options. | ||||||
| func NewSourcePlugin(name string, version string, tables []*schema.Table, newExecutionClient SourceNewExecutionClientFunc, opts ...SourceOption) *SourcePlugin { | ||||||
| p := SourcePlugin{ | ||||||
| name: name, | ||||||
|
|
@@ -91,27 +93,32 @@ func (p *SourcePlugin) validate() error { | |||||
| return nil | ||||||
| } | ||||||
|
|
||||||
| // Tables returns all supported tables by this source plugin | ||||||
| func (p *SourcePlugin) Tables() schema.Tables { | ||||||
| return p.tables | ||||||
| } | ||||||
|
|
||||||
| // ExampleConfig returns an example configuration for this source plugin | ||||||
| func (p *SourcePlugin) ExampleConfig() string { | ||||||
| return p.exampleConfig | ||||||
| } | ||||||
|
|
||||||
| // Name return the name of this plugin | ||||||
|
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.
Suggested change
|
||||||
| func (p *SourcePlugin) Name() string { | ||||||
| return p.name | ||||||
| } | ||||||
|
|
||||||
| // Version returns the version of this plugin | ||||||
|
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.
Suggested change
|
||||||
| func (p *SourcePlugin) Version() string { | ||||||
| return p.version | ||||||
| } | ||||||
|
|
||||||
| // SetLogger sets the logger for this plugin which will be used in Sync and all other function calls. | ||||||
| func (p *SourcePlugin) SetLogger(log zerolog.Logger) { | ||||||
| p.logger = log | ||||||
| } | ||||||
|
|
||||||
| // Sync data from source to the given channel | ||||||
| // Sync is syncing data from the requested tables in spec to the given channel | ||||||
|
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.
Suggested change
|
||||||
| func (p *SourcePlugin) Sync(ctx context.Context, spec specs.Source, res chan<- *schema.Resource) error { | ||||||
| c, err := p.newExecutionClient(ctx, p.logger, spec) | ||||||
| if err != nil { | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| // Package schema defines types supported by tables in source plugins | ||
| package schema |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,4 @@ | ||
| // Package serve defines APIs to serve (invoke) source and destination plugins | ||
| package serve | ||
|
|
||
| import ( | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| // Package specs specs for source and destination plugins including | ||
|
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. I'm not sure I understand what message this comment is trying to convey |
||
| // parsers and readers. | ||
| package specs | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,19 +7,30 @@ import ( | |||||
| "github.com/xeipuuv/gojsonschema" | ||||||
| ) | ||||||
|
|
||||||
| // Source is the shared configuration for all source plugins | ||||||
| // Source is the spec for a source plugin | ||||||
|
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.
Suggested change
|
||||||
| type Source struct { | ||||||
| Name string `json:"name,omitempty"` | ||||||
| // Name of the source plugin to use | ||||||
|
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.
Suggested change
|
||||||
| Name string `json:"name,omitempty"` | ||||||
| // Version of the source plugin to use | ||||||
|
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.
Suggested change
|
||||||
| Version string `json:"version,omitempty"` | ||||||
| // Path is the path in the registry | ||||||
| // Path is the canonical path to the source plugin in a given registry | ||||||
| // For example: | ||||||
| // in github the path will be: org/repo | ||||||
|
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.
Suggested change
|
||||||
| // For the local registry the path will be the path to the binary: ./path/to/binary | ||||||
| // For the gRPC registry the path will be the address of the gRPC server: host:port | ||||||
| Path string `json:"path,omitempty"` | ||||||
| // Registry can be github,local,grpc. Might support things like https in the future. | ||||||
| Registry Registry `json:"registry,omitempty"` | ||||||
| MaxGoRoutines uint64 `json:"max_goroutines,omitempty"` | ||||||
| Tables []string `json:"tables,omitempty"` | ||||||
| SkipTables []string `json:"skip_tables,omitempty"` | ||||||
| Destinations []string `json:"destinations,omitempty"` | ||||||
| Spec interface{} `json:"spec,omitempty"` | ||||||
| // Registry can be github,local,grpc. | ||||||
| Registry Registry `json:"registry,omitempty"` | ||||||
| MaxGoRoutines uint64 `json:"max_goroutines,omitempty"` | ||||||
| // Tables to sync from the source plugin | ||||||
| Tables []string `json:"tables,omitempty"` | ||||||
| // SkipTables defines tables to skip when syncing data. Useful if a glob pattern is used in Tables | ||||||
| SkipTables []string `json:"skip_tables,omitempty"` | ||||||
| // Destinations are the names of destination plugins to send sync data to | ||||||
| Destinations []string `json:"destinations,omitempty"` | ||||||
| // Spec defines plugin specific configuration | ||||||
| // This is different in every source plugin. | ||||||
| Spec interface{} `json:"spec,omitempty"` | ||||||
| } | ||||||
|
|
||||||
| func (s *Source) SetDefaults() { | ||||||
|
|
@@ -37,6 +48,7 @@ func (s *Source) SetDefaults() { | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| // UnmarshalSpec unmarshals the internal spec into the given interface | ||||||
| func (s *Source) UnmarshalSpec(out interface{}) error { | ||||||
| b, err := json.Marshal(s.Spec) | ||||||
| if err != nil { | ||||||
|
|
||||||
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.