provider

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Dec 18, 2021 License: MPL-2.0 Imports: 33 Imported by: 39

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultErrorClassifier added in v0.5.0

func DefaultErrorClassifier(_ schema.ClientMeta, resourceName string, err error) []diag.Diagnostic

DefaultErrorClassifier defines default error classifier for providers that don't provide custom error classification for errors returned from fetch execution

Types

type Config

type Config interface {
	// Example returns a configuration example (with comments) so user clients can generate an example config
	Example() string
}

Config Every provider implements a resources field we only want to extract that in fetch execution

type Migrator

type Migrator struct {
	// contains filtered or unexported fields
}

func NewMigrator

func NewMigrator(log hclog.Logger, migrationFiles map[string][]byte, dsn string, providerName string) (*Migrator, error)

func (*Migrator) Close added in v0.4.5

func (m *Migrator) Close() error

func (*Migrator) DowngradeProvider added in v0.3.3

func (m *Migrator) DowngradeProvider(version string) error

func (*Migrator) DropProvider added in v0.3.3

func (m *Migrator) DropProvider(ctx context.Context, schema map[string]*schema.Table) error

func (*Migrator) FindLatestMigration added in v0.3.3

func (m *Migrator) FindLatestMigration(requestedVersion string) (uint, error)

FindLatestMigration finds closet migration to the requested version

For example we have the following migrations:
1_001, 2_005, 3_009

if we ask for 007 we get 005 if we ask for 004 we get 001 if we ask for 005 we get 005

func (*Migrator) SetVersion added in v0.3.3

func (m *Migrator) SetVersion(requestedVersion string) error

func (*Migrator) UpgradeProvider added in v0.3.3

func (m *Migrator) UpgradeProvider(version string) error

func (*Migrator) Version added in v0.3.3

func (m *Migrator) Version() (string, bool, error)

type Provider

type Provider struct {
	// Name of plugin i.e aws,gcp, azure etc'
	Name string
	// Version of the provider
	Version string
	// Configure the provider and return context
	Configure func(hclog.Logger, interface{}) (schema.ClientMeta, error)
	// ResourceMap is all resources supported by this plugin
	ResourceMap map[string]*schema.Table
	// Configuration decoded from configure request
	Config func() Config
	// Logger to call, this logger is passed to the serve.Serve Client, if not define Serve will create one instead.
	Logger hclog.Logger
	// Migrations embedded and passed by the provider to upgrade between versions
	Migrations embed.FS
	// ErrorClassifier allows the provider to classify errors it produces during table execution, and return them as diagnostics to the user.
	// Classifier function may return empty slice if it cannot meaningfully convert the error into diagnostics. In this case
	// the error will be converted by the SDK into diagnostic at ERROR level and RESOLVING type.
	ErrorClassifier func(meta schema.ClientMeta, resource string, err error) []diag.Diagnostic
	// contains filtered or unexported fields
}

Provider is the base structure required to pass and serve an sdk provider.Provider

func (*Provider) ConfigureProvider added in v0.2.0

func (*Provider) FetchResources added in v0.2.0

func (p *Provider) FetchResources(ctx context.Context, request *cqproto.FetchResourcesRequest, sender cqproto.FetchResourcesSender) error

func (*Provider) GetProviderConfig added in v0.2.0

func (*Provider) GetProviderSchema added in v0.2.0

type TableCreator added in v0.3.3

type TableCreator struct {
	// contains filtered or unexported fields
}

TableCreator handles creation of schema.Table in database if they don't exist, and migration of tables if provider was upgraded.

func NewTableCreator added in v0.3.3

func NewTableCreator(log hclog.Logger) *TableCreator

func (TableCreator) CreateTable added in v0.3.3

func (m TableCreator) CreateTable(ctx context.Context, conn *pgxpool.Conn, t *schema.Table, parent *schema.Table) error

Directories

Path Synopsis
Package docs helps create provider documentation
Package docs helps create provider documentation
mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

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