Skip to content

Commit 4163e8d

Browse files
authored
chore(docs): Add more godoc to important APIs (#118)
As part of the v2 release we want to improve documentation for developers and for our plugin-sdk. Right now we have a bit of mix-match of tutorials and docs https://www.cloudquery.io/docs/developers/sdk/provider/configuration What we want to achieve: - SDK documentation in godoc together with docs - https://pkg.go.dev/github.com/cloudquery/plugin-sdk - Tutorials - https://www.cloudquery.io/docs/developers/sdk/overview There is still much more documentation to be added with some more examples but this should be a good start. <!-- Explain what problem this PR addresses --> ---
1 parent c4b33fe commit 4163e8d

File tree

11 files changed

+51
-22
lines changed

11 files changed

+51
-22
lines changed

README.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
CloudQuery Plugin SDK ![License](https://img.shields.io/github/license/cloudquery/cloudquery?style=flat-square)
2-
=======================
1+
# CloudQuery Plugin SDK
32

4-
This SDK enables building CloudQuery plugins which allows CloudQuery's users to extract/load/transform existing and popular service providers as well as custom in-house solutions into a SQL Database.
3+
CloudQuery SDK enables building CloudQuery source and destination plugins.
54

6-
CloudQuery itself is a tool that transforms your cloud infrastructure into queryable SQL for easy monitoring, governance and security. You can find more about CloudQuery on its website and its GitHub repository.
5+
Source plugins allows developers to extract information from third party APIs and enjoying built-in transformations, concurrency, logging, testing and database agnostic support via destination plugins.
76

7+
Destinations plugins allows writing the data from any of the source plugins to an additional database, message queue, storage or any other destination without recompiling any of the source plugins.
88

99
## Getting Started & Documentation
1010

11-
* Homepage: https://cloudquery.io
12-
* Releases: https://github.com/cloudquery/cloudquery/releases
13-
* Documentation: https://docs.cloudquery.io
14-
* Database Configuration: https://docs.cloudquery.io/database-configuration
11+
- Homepage: https://cloudquery.io
12+
- Releases: https://github.com/cloudquery/cloudquery/releases
13+
- Documentation: https://docs.cloudquery.io
1514

1615
## Supported plugins
1716

clients/doc.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// package clients is a wrapper around grpc clients so clients can work
2+
// with non protobuf structs and handle unmarshaling
3+
package clients

clients/source.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// package clients is a wrapper around grpc clients so clients can work
2-
// with non protobuf structs and handle unmarshaling
31
package clients
42

53
import (
@@ -14,6 +12,7 @@ import (
1412
"google.golang.org/grpc"
1513
)
1614

15+
// SourceClient
1716
type SourceClient struct {
1817
pbClient pb.SourceClient
1918
}

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+
// Package codgen helps autogenerate tables for CloudQuery source plugins from Go structs (of relevant SDKs)
22
package codegen

codegen/golang.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ func (t *TableDefinition) addColumnFromField(field reflect.StructField, parentFi
156156
t.Columns = append(t.Columns, column)
157157
}
158158

159+
// NewTableFromStruct creates a new TableDefinition from a struct by inspecting its fields
159160
func NewTableFromStruct(name string, obj interface{}, opts ...TableOptions) (*TableDefinition, error) {
160161
t := &TableDefinition{
161162
Name: name,

plugins/docs.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package plugins defines APIs for source and destination plugins
2+
package plugins

plugins/source.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ func addInternalColumns(tables []*schema.Table) {
5959
}
6060
}
6161

62+
// NewSourcePlugin returns a new plugin with a given name, version, tables, newExecutionClient
63+
// and additional options.
6264
func NewSourcePlugin(name string, version string, tables []*schema.Table, newExecutionClient SourceNewExecutionClientFunc, opts ...SourceOption) *SourcePlugin {
6365
p := SourcePlugin{
6466
name: name,
@@ -91,27 +93,32 @@ func (p *SourcePlugin) validate() error {
9193
return nil
9294
}
9395

96+
// Tables returns all supported tables by this source plugin
9497
func (p *SourcePlugin) Tables() schema.Tables {
9598
return p.tables
9699
}
97100

101+
// ExampleConfig returns an example configuration for this source plugin
98102
func (p *SourcePlugin) ExampleConfig() string {
99103
return p.exampleConfig
100104
}
101105

106+
// Name return the name of this plugin
102107
func (p *SourcePlugin) Name() string {
103108
return p.name
104109
}
105110

111+
// Version returns the version of this plugin
106112
func (p *SourcePlugin) Version() string {
107113
return p.version
108114
}
109115

116+
// SetLogger sets the logger for this plugin which will be used in Sync and all other function calls.
110117
func (p *SourcePlugin) SetLogger(log zerolog.Logger) {
111118
p.logger = log
112119
}
113120

114-
// Sync data from source to the given channel
121+
// Sync is syncing data from the requested tables in spec to the given channel
115122
func (p *SourcePlugin) Sync(ctx context.Context, spec specs.Source, res chan<- *schema.Resource) error {
116123
c, err := p.newExecutionClient(ctx, p.logger, spec)
117124
if err != nil {

schema/doc.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
// Package schema defines types supported by tables in source plugins
2+
package schema

serve/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// Package serve defines APIs to serve (invoke) source and destination plugins
12
package serve
23

34
import (

specs/doc.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// Package specs specs for source and destination plugins including
2+
// parsers and readers.
3+
package specs

0 commit comments

Comments
 (0)