plugins

package
v0.0.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 11, 2022 License: MPL-2.0 Imports: 18 Imported by: 7

Documentation

Index

Constants

View Source
const ExampleSourceConfig = `` /* 294-byte string literal not displayed */

Variables

This section is empty.

Functions

func TestResource

func TestResource(t *testing.T, tc ResourceTestCase)

Types

type DestinationPlugin

type DestinationPlugin interface {
	Configure(ctx context.Context, spec specs.DestinationSpec) error
	CreateTables(ctx context.Context, table []*schema.Table) error
	Save(ctx context.Context, resources []*schema.Resource) error
	GetExampleConfig(ctx context.Context) string
}

type DestinationPluginOptions

type DestinationPluginOptions struct {
	Logger zerolog.Logger
}

type ResourceTestCase

type ResourceTestCase struct {
	Plugin *SourcePlugin
	Config string
	// we want it to be parallel by default
	NotParallel bool
	// ParallelFetchingLimit limits parallel resources fetch at a time
	ParallelFetchingLimit uint64
	// SkipIgnoreInTest flag which detects if schema.Table or schema.Column should be ignored
	SkipIgnoreInTest bool
	// Verifiers are map from resource name to its verifiers.
	// If no verifiers specified for resource (resource name is not in key set of map),
	// non emptiness check of all columns in table and its relations will be performed.
	Verifiers map[string][]Verifier
}

type Row

type Row map[string]interface{}

type SourcePlugin

type SourcePlugin struct {
	// Name of plugin i.e aws,gcp, azure etc'
	Name string
	// Version of the plugin
	Version string
	// Called upon configure call to validate and init configuration
	Configure func(context.Context, *SourcePlugin, specs.SourceSpec) (schema.ClientMeta, error)
	// Tables is all tables supported by this source plugin
	Tables []*schema.Table
	// JsonSchema for specific source plugin spec
	JsonSchema string
	// ExampleConfig is the example configuration for this plugin
	ExampleConfig string
	// Logger to call, this logger is passed to the serve.Serve Client, if not define Serve will create one instead.
	Logger zerolog.Logger
	// contains filtered or unexported fields
}

SourcePlugin is the base structure required to pass to sdk.serve We take a similar/declerative approach to API here similar to Cobra

func (*SourcePlugin) Fetch

func (p *SourcePlugin) Fetch(ctx context.Context, res chan<- *schema.Resource) error

Fetch fetches data according to source configuration and

func (*SourcePlugin) Init

type Verifier

type Verifier func(t *testing.T, table *schema.Table, conn pgxscan.Querier, shouldSkipIgnoreInTest bool)

Verifier verifies tables specified by table schema (main table and its relations).

func VerifyAtLeastOneRow

func VerifyAtLeastOneRow() Verifier

VerifyAtLeastOneRow verifies that main table from schema has at least one row

func VerifyAtMostOneOf

func VerifyAtMostOneOf(tableName string, oneof ...string) Verifier

VerifyAtMostOneOf verifies that for each row in table at most one column from oneof is not empty

func VerifyNoEmptyColumnsExcept

func VerifyNoEmptyColumnsExcept(tableName string, except ...string) Verifier

VerifyNoEmptyColumnsExcept verifies that for each row in table its columns are not empty except passed

func VerifyRowPredicateInTable

func VerifyRowPredicateInTable(tableName string, rowVerifier func(*testing.T, Row)) Verifier

VerifyRowPredicateInTable is a base verifier accepting single row verifier for specific table from schema

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL