provider

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RegisterProvider

func RegisterProvider[T Provider](typeName string, factory GenericProviderFactory[T])

func RegisterProviderWithError

func RegisterProviderWithError[T Provider](typeName string, factory GenericProviderFactory[T]) error

func UnregisterProvider

func UnregisterProvider(typeName string)

func WithFunctions

func WithFunctions(evalCtx *hcl.EvalContext) *hcl.EvalContext

func WithQury

func WithQury(evalCtx *hcl.EvalContext, variables *EvalContextQueryVariables) (*hcl.EvalContext, error)

Types

type EvalContextQueryVariables

type EvalContextQueryVariables struct {
	FQN    string       `cty:"fqn"`
	Status string       `cty:"status"`
	Error  string       `cty:"error"`
	Result *QueryResult `cty:"result"`
}

type GenericProviderFactory

type GenericProviderFactory[T Provider] func(*ProviderParameter) (T, error)

type Provider

type Provider interface {
	NewQuery(name string, body hcl.Body, evalCtx *hcl.EvalContext) (Query, error)
}

func NewProvider

func NewProvider(param *ProviderParameter) (Provider, error)

type ProviderFactory

type ProviderFactory func(*ProviderParameter) (Provider, error)

type ProviderParameter

type ProviderParameter struct {
	Type   string
	Name   string
	Params json.RawMessage
	// contains filtered or unexported fields
}

func (*ProviderParameter) SetParams

func (p *ProviderParameter) SetParams(params map[string]cty.Value) error

func (*ProviderParameter) String

func (p *ProviderParameter) String() string

type ProviderParameters

type ProviderParameters []*ProviderParameter

func (ProviderParameters) MarshalCTYValue

func (p ProviderParameters) MarshalCTYValue() (cty.Value, error)

type Query

type Query interface {
	Run(ctx context.Context, evalCtx *hcl.EvalContext) (*QueryResult, error)
}

type QueryResult

type QueryResult struct {
	Name    string              `cty:"name" json:"name"`
	Query   string              `cty:"query" json:"query"`
	Params  []interface{}       `cty:"params" json:"params,omitempty"`
	Columns []string            `cty:"columns" json:"columns"`
	Rows    [][]json.RawMessage `cty:"rows" json:"rows"`
}

func NewQueryResult

func NewQueryResult(name string, query string, params []interface{}, columns []string, rows [][]json.RawMessage) *QueryResult

func NewQueryResultWithJSONLines

func NewQueryResultWithJSONLines(name string, query string, params []interface{}, lines ...map[string]json.RawMessage) *QueryResult

func NewQueryResultWithSQLRows

func NewQueryResultWithSQLRows(name string, query string, params []interface{}, rows *sql.Rows) (*QueryResult, error)

func (*QueryResult) ToBorderlessTable

func (qr *QueryResult) ToBorderlessTable() string

func (*QueryResult) ToJSONLines

func (qr *QueryResult) ToJSONLines() string

func (*QueryResult) ToMarkdownTable

func (qr *QueryResult) ToMarkdownTable() string

func (*QueryResult) ToTable

func (qr *QueryResult) ToTable(optFns ...func(*tablewriter.Table)) string

func (*QueryResult) ToVertical

func (qr *QueryResult) ToVertical() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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