{"modulePath":"github.com/OpsHelmInc/cloudquery/v2","version":"v2.0.0-20250326192610-2631c5f07fe8","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package plugin\n\n## Constants\n\n```go\nconst (\n\tGoOSLinux   = \"linux\"\n\tGoOSWindows = \"windows\"\n\tGoOSDarwin  = \"darwin\"\n\n\tGoArchAmd64 = \"amd64\"\n\tGoArchArm64 = \"arm64\"\n)\n```\n\n## Variables\n\n```go\nvar DefaultBuildTargets = []BuildTarget{\n\t{OS: GoOSLinux, Arch: GoArchAmd64},\n\t{OS: GoOSLinux, Arch: GoArchArm64},\n\t{OS: GoOSWindows, Arch: GoArchAmd64},\n\t{OS: GoOSDarwin, Arch: GoArchAmd64},\n\t{OS: GoOSDarwin, Arch: GoArchArm64},\n}\n```\n\n```go\nvar ErrNotImplemented = fmt.Errorf(\"not implemented\")\n```\n\n## Functions\n\n```go\nfunc JSONSchemaValidator(jsonSchema string) (*jsonschema.Schema, error)\n```\n\n```go\nfunc MatchesTable(name string, includeTablesPattern []string, skipTablesPattern []string) bool\n```\n\n```go\nfunc RecordsDiff(sc *arrow.Schema, have, want []arrow.Record) string\n```\n\n```go\nfunc TableDiff(have, want arrow.Table) string\n```\n\n```go\nfunc TestWriterSuiteRunner(t *testing.T, p *Plugin, tests WriterTestSuiteTests, opts ...func(o *WriterTestSuite))\n```\n\n```go\nfunc TotalRows(records []arrow.Record) int64\n```\n\n```go\nfunc UnimplementedTestConnectionFn(context.Context, zerolog.Logger, []byte) error\n```\n\n```go\nfunc ValidateNoEmptyColumns(t *testing.T, tables schema.Tables, messages message.SyncMessages)\n```\n\n```go\nfunc WithHomogeneousTypes() func(o *WriterTestSuite)\n```\n\n```go\nfunc WithRandomSeed(seed int64) func(o *WriterTestSuite)\n```\n\n```go\nfunc WithTestDataOptions(opts schema.TestSourceOptions) func(o *WriterTestSuite)\n```\n\n```go\nfunc WithTestIgnoreNullsInLists() func(o *WriterTestSuite)\n```\n\n```go\nfunc WithTestSourceAllowNull(allowNull func(arrow.DataType) bool) func(o *WriterTestSuite)\n```\n\n## Types\n\n```go\ntype AllowNullFunc func(arrow.DataType) bool\n```\n\n```go\ntype BackendOptions struct {\n\tTableName  string\n\tConnection string\n}\n```\n\n```go\ntype BuildTarget struct {\n\tOS   string   `json:\"os\"`\n\tArch string   `json:\"arch\"`\n\tCGO  bool     `json:\"cgo\"`\n\tEnv  []string `json:\"env\"`\n}\n```\n\n```go\nfunc (t BuildTarget) EnvVariables() []string\n```\n\n```go\ntype Client interface {\n\tSourceClient\n\tDestinationClient\n}\n```\n\n```go\ntype ConnectionTester func(ctx context.Context, logger zerolog.Logger, spec []byte) error\n```\n\n```go\ntype DestinationClient interface {\n\tClose(ctx context.Context) error\n\tRead(ctx context.Context, table *schema.Table, res chan\u003c- arrow.Record) error\n\tWrite(ctx context.Context, res \u003c-chan message.WriteMessage) error\n}\n```\n\n```go\ntype Kind string\n```\n\n```go\nconst (\n\tKindSource      Kind = \"source\"\n\tKindDestination Kind = \"destination\"\n)\n```\n\n```go\nfunc (k Kind) Validate() error\n```\n\n```go\ntype Meta struct {\n\tTeam            cqapi.PluginTeam\n\tKind            cqapi.PluginKind\n\tName            cqapi.PluginName\n\tSkipUsageClient bool\n}\n```\n\n```go\ntype MigrateMode int\n```\n\n```go\nconst (\n\tMigrateModeSafe MigrateMode = iota\n\tMigrateModeForce\n)\n```\n\n```go\nfunc (m MigrateMode) String() string\n```\n\n```go\ntype Migrations struct {\n\tRemoveUniqueConstraint bool\n\tMovePKToCQOnly         bool\n}\n```\nMigrations defines which migrations should be skipped completely\n\n```go\ntype NewClientFunc func(context.Context, zerolog.Logger, []byte, NewClientOptions, *aws.Config) (Client, error)\n```\n\n```go\ntype NewClientOptions struct {\n\tNoConnection bool\n\tInvocationID string\n\tPluginMeta   Meta\n}\n```\n\n```go\ntype NewPluginFunc func() *Plugin\n```\n\n```go\ntype NewSourceClientFunc func(context.Context, zerolog.Logger, any) (SourceClient, error)\n```\n\n```go\ntype OnBeforeSender interface {\n\tOnBeforeSend(context.Context, message.SyncMessage) (message.SyncMessage, error)\n}\n```\n\n```go\ntype OnSyncFinisher interface {\n\tOnSyncFinish(context.Context) error\n}\n```\nOnSyncFinisher is an interface that can be implemented by a plugin client to be notified when a sync finishes.\n\n```go\ntype Option func(*Plugin)\n```\n\n```go\nfunc WithBuildTargets(targets []BuildTarget) Option\n```\n\n```go\nfunc WithConnectionTester(tester ConnectionTester) Option\n```\nWithConnectionTester can be specified by a plugin to enable explicit connection testing, given a spec.\n\n```go\nfunc WithCustomConfig(cfg *aws.Config) Option\n```\n\n```go\nfunc WithJSONSchema(schema string) Option\n```\n\n```go\nfunc WithKind(kind string) Option\n```\n\n```go\nfunc WithTeam(team string) Option\n```\n\n```go\ntype PackageType string\n```\n\n```go\nconst (\n\tPackageTypeNative PackageType = \"native\"\n)\n```\n\n```go\ntype Plugin struct {\n\t// contains filtered or unexported fields\n}\n```\nPlugin is the base structure required to pass to sdk.serve We take a declarative approach to API here similar to Cobra\n\n```go\nfunc NewPlugin(name string, version string, newClient NewClientFunc, options ...Option) *Plugin\n```\nNewPlugin returns a new CloudQuery Plugin with the given name, version and implementation. Depending on the options, it can be a write-only plugin, read-only plugin, or both.\n\n```go\nfunc NewSourcePlugin(name string, version string, newClient NewSourceClientFunc, options ...Option) *Plugin\n```\nNewSourcePlugin returns a new CloudQuery Plugin with the given name, version and implementation. Source plugins only support read operations. For Read \u0026 Write plugin use NewPlugin.\n\n```go\nfunc (p *Plugin) Close(ctx context.Context) error\n```\n\n```go\nfunc (p *Plugin) Init(ctx context.Context, spec []byte, options NewClientOptions) error\n```\nInit initializes the plugin with the given spec.\n\n```go\nfunc (p *Plugin) InvocationID() string\n```\nInvocationID returns the invocation ID for the current execution\n\n```go\nfunc (p *Plugin) JSONSchema() string\n```\n\n```go\nfunc (p *Plugin) Kind() Kind\n```\nKind returns the kind of this plugin\n\n```go\nfunc (p *Plugin) Meta() Meta\n```\n\n```go\nfunc (p *Plugin) Name() string\n```\nName returns the name of this plugin\n\n```go\nfunc (p *Plugin) OnBeforeSend(ctx context.Context, msg message.SyncMessage) (message.SyncMessage, error)\n```\nOnBeforeSend gets called before every message is sent to the destination. A plugin client that implements the OnBeforeSender interface will have this method called.\n\n```go\nfunc (p *Plugin) OnSyncFinish(ctx context.Context) error\n```\nOnSyncFinish gets called after a sync finishes.\n\n```go\nfunc (p *Plugin) Read(ctx context.Context, table *schema.Table, res chan\u003c- arrow.Record) error\n```\nRead is read data from the requested table to the given channel, returned in the same format as the table\n\n```go\nfunc (p *Plugin) SetLogger(logger zerolog.Logger)\n```\n\n```go\nfunc (p *Plugin) SetSkipTableValidation(v bool)\n```\nSetSkipTableValidation sets whether table validation should be skipped\n\n```go\nfunc (p *Plugin) SetSkipUsageClient(v bool)\n```\nSetSkipUsageClient sets whether the usage client should be skipped\n\n```go\nfunc (p *Plugin) Sync(ctx context.Context, options SyncOptions, res chan\u003c- message.SyncMessage, resourceCh chan\u003c- *schema.Resource) error\n```\nSync is syncing data from the requested tables in spec to the given channel\n\n```go\nfunc (p *Plugin) SyncAll(ctx context.Context, options SyncOptions) (message.SyncMessages, error)\n```\n\n```go\nfunc (p *Plugin) Tables(ctx context.Context, options TableOptions) (schema.Tables, error)\n```\n\n```go\nfunc (p *Plugin) Targets() []BuildTarget\n```\n\n```go\nfunc (p *Plugin) Team() string\n```\nTeam returns the name of the team that authored this plugin\n\n```go\nfunc (p *Plugin) TestConnection(ctx context.Context, logger zerolog.Logger, spec []byte) error\n```\n\n```go\nfunc (p *Plugin) Version() string\n```\nVersion returns the version of this plugin\n\n```go\nfunc (p *Plugin) Write(ctx context.Context, res \u003c-chan message.WriteMessage) error\n```\n\n```go\nfunc (p *Plugin) WriteAll(ctx context.Context, resources []message.WriteMessage) error\n```\nWriteAll is currently used mostly for testing, so it's not a public api\n\n```go\ntype SafeMigrations struct {\n\tAddColumn              bool\n\tAddColumnNotNull       bool\n\tRemoveColumn           bool\n\tRemoveColumnNotNull    bool\n\tChangeColumn           bool\n\tRemoveUniqueConstraint bool\n\tMovePKToCQOnly         bool\n}\n```\nSafeMigrations defines which migrations are supported by the plugin in safe migrate mode\n\n```go\ntype SourceClient interface {\n\tClose(ctx context.Context) error\n\tTables(ctx context.Context, options TableOptions) (schema.Tables, error)\n\tSync(ctx context.Context, options SyncOptions, res chan\u003c- message.SyncMessage, resourceCh chan\u003c- *schema.Resource) error\n}\n```\n\n```go\ntype SyncOptions struct {\n\tTables              []string\n\tSkipTables          []string\n\tSkipDependentTables bool\n\tDeterministicCQID   bool\n\tBackendOptions      *BackendOptions\n}\n```\n\n```go\ntype TableOptions struct {\n\tTables              []string\n\tSkipTables          []string\n\tSkipDependentTables bool\n}\n```\n\n```go\ntype TestConnError struct {\n\tCode    string\n\tMessage error\n}\n```\n\n```go\nfunc NewTestConnError(code string, err error) *TestConnError\n```\n\n```go\nfunc (e *TestConnError) Error() string\n```\n\n```go\nfunc (e *TestConnError) Is(err error) bool\n```\n\n```go\nfunc (e *TestConnError) Unwrap() error\n```\n\n```go\ntype UnimplementedDestination struct{}\n```\n\n```go\nfunc (UnimplementedDestination) Read(context.Context, *schema.Table, chan\u003c- arrow.Record) error\n```\n\n```go\nfunc (UnimplementedDestination) Write(context.Context, \u003c-chan message.WriteMessage) error\n```\n\n```go\ntype UnimplementedSource struct{}\n```\n\n```go\nfunc (UnimplementedSource) Sync(context.Context, SyncOptions, chan\u003c- message.SyncMessage, chan\u003c- *schema.Resource) error\n```\n\n```go\nfunc (UnimplementedSource) Tables(context.Context, TableOptions) (schema.Tables, error)\n```\n\n```go\ntype WriteTests struct {\n\tDuplicatePK bool\n}\n```\nWriteTests defines which tests should be skipped in the write test suite\n\n```go\ntype WriterTestSuite struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\ntype WriterTestSuiteTests struct {\n\t// SkipUpsert skips testing with message.Insert and Upsert=true.\n\t// Usually when a destination is not supporting primary keys\n\tSkipUpsert bool\n\n\t// SkipDeleteStale skips testing message.Delete events.\n\tSkipDeleteStale bool\n\n\t// SkipDeleteRecord skips testing message.DeleteRecord events.\n\tSkipDeleteRecord bool\n\n\t// SkipAppend skips testing message.Insert and Upsert=false.\n\tSkipInsert bool\n\n\t// SkipMigrate skips testing migration\n\tSkipMigrate bool\n\n\t// SafeMigrations defines which tests should work with force migration\n\t// and which should pass with safe migration\n\tSafeMigrations SafeMigrations\n\n\tSkipSpecificMigrations Migrations\n\n\tSkipSpecificWriteTests WriteTests\n}\n```\n\n","path":"github.com/OpsHelmInc/cloudquery/v2/plugin-sdk/plugin","name":"plugin","synopsis":"","isRedistributable":true}
