postgres

package
v0.0.0-...-a6fcbec Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConfigSchema = map[string]*schema.Attribute{
	"connection_string": {Type: schema.TypeString},
	"schema":            {Type: schema.TypeString},
	"tables_to_expose":  {Type: schema.TypeList, Elem: &schema.Attribute{Type: schema.TypeString}},
}

Functions

func ConfigInstance

func ConfigInstance() interface{}

func FindCommentOnAttrs

func FindCommentOnAttrs(attrs []schema.Attr) string

FindCommentOnAttrs tries to locate an Attr among the passed array that corresponds to a comment, and returns it if found. Otherwise, returns an empty string. This function can be used to identify the comment that is attached to a schema, table or column.

func GetAtlasSchemaForDBSchema

func GetAtlasSchemaForDBSchema(ctx context.Context, connectionString, schema string) (*schema.Schema, error)

GetAtlasSchemaForDBSchema gets the Atlas schema (as in, the metadata) for a Postgres schema (as in, the hierarchy below a database and above a table, such as `public`). Must receive a connection string in the format expected by pgx (https://pkg.golang.ir/github.com/jackc/pgx/v5#hdr-Establishing_a_Connection)

func ListRawResults

func ListRawResults(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error)

func ListTableRecords

func ListTableRecords(ctx context.Context, d *plugin.QueryData, _ *plugin.HydrateData) (interface{}, error)

func MakeRawSQLQuery

func MakeRawSQLQuery(ctx context.Context, connectionString, schema string, table string, query string) ([]map[string]any, error)

MakeRawSQLQuery sends a raw SQL query to a remote DB, and returns any results

func MakeSQLQuery

func MakeSQLQuery(ctx context.Context, connectionString, schema string, table string, quals plugin.KeyColumnQualMap) ([]map[string]any, error)

MakeSQLQuery composes a SQL query from a set of quals, sends it to a remote DB, and returns any results

func Plugin

func Plugin(ctx context.Context) *plugin.Plugin

func PluginTables

func PluginTables(ctx context.Context, d *plugin.TableMapData) (map[string]*plugin.Table, error)

func PostgresColTypeToSteampipeColType

func PostgresColTypeToSteampipeColType(ctx context.Context, col *schema.Column) proto.ColumnType

PostgresColTypeToSteampipeColType converts an Atlas column type to a Steampipe column. Atlas column types correspond almost one-to-one to actual SQL types, either standard SQL or Postgres extensions. For example, DECIMAL, FLOAT and CURRENCY become DOUBLEs on Steampipe

Types

type PostgresConfig

type PostgresConfig struct {
	ConnectionString *string  `cty:"connection_string"`
	Schema           *string  `cty:"schema"`
	TablesToExpose   []string `cty:"tables_to_expose"`
}

func GetConfig

func GetConfig(connection *plugin.Connection) PostgresConfig

GetConfig :: retrieve and cast connection config from query data

func (PostgresConfig) GetConnectionString

func (c PostgresConfig) GetConnectionString() (string, error)

func (PostgresConfig) GetSchema

func (c PostgresConfig) GetSchema() string

GetSchema returns the schema that was configured in the .spc file, if available, and "public" otherwise

func (PostgresConfig) GetTablesToExpose

func (c PostgresConfig) GetTablesToExpose() []string

GetTablesToExpose returns the slice of table blobs that was configured in the .spc file, if set, and ["*"] otherwise (which will expose every table)

func (PostgresConfig) String

func (c PostgresConfig) String() string

Jump to

Keyboard shortcuts

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