inspect

package
v0.0.0-...-43c2f11 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2024 License: PostgreSQL Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

This section is empty.

Types

type Config

type Config struct {
	FallbackOwner       string
	DatabasesQuery      Querier[string]
	ManagedRolesQuery   Querier[string]
	RolesBlacklistQuery Querier[string]
	SchemasQuery        Querier[postgres.Schema]
}

type Conn

type Conn interface {
	Query(context.Context, string, ...any) (pgx.Rows, error)
}

Conn allows to inject a mock.

type Creators

type Creators struct {
	Schema   string
	Creators []string
}

func RowToCreators

func RowToCreators(rows pgx.CollectableRow) (c Creators, err error)

type Instance

type Instance struct {
	AllRoles         role.Map
	Databases        postgres.DBMap
	DefaultDatabase  string
	FallbackOwner    string
	ManagedDatabases mapset.Set[string]
	ManagedRoles     role.Map
	Me               role.Role
	RolesBlacklist   lists.Blacklist
}

Fourzitou struct holding everything need to synchronize Instance.

func Stage0

func Stage0(ctx context.Context, pc Config) (instance Instance, err error)

func (*Instance) InspectCreators

func (instance *Instance) InspectCreators(ctx context.Context, dbname string, managedRoles mapset.Set[string]) error

func (*Instance) InspectGrants

func (instance *Instance) InspectGrants(ctx context.Context, dbname string, privileges privilege.TypeMap, roles mapset.Set[string]) (out []privilege.Grant, err error)

func (*Instance) InspectManagedDatabases

func (instance *Instance) InspectManagedDatabases(ctx context.Context, pgconn *pgx.Conn, q Querier[string]) error

func (*Instance) InspectRoles

func (instance *Instance) InspectRoles(ctx context.Context, pgconn *pgx.Conn, managedRolesQ Querier[string]) error

func (*Instance) InspectSchemas

func (instance *Instance) InspectSchemas(ctx context.Context, dbname string, managedQuery Querier[postgres.Schema]) error

func (*Instance) InspectSession

func (instance *Instance) InspectSession(ctx context.Context, fallbackOwner string) error

func (*Instance) InspectStage1

func (instance *Instance) InspectStage1(ctx context.Context, pc Config) (err error)

func (*Instance) InspectStage2

func (instance *Instance) InspectStage2(ctx context.Context, dbname string, query Querier[postgres.Schema]) error

func (*Instance) InspectStage3

func (instance *Instance) InspectStage3(ctx context.Context, dbname string, roles mapset.Set[string]) error

type Querier

type Querier[T any] interface {
	Query(context.Context, Conn)
	Next() bool
	Err() error
	Row() T
}

Querier abstracts the execution of a SQL query or the copy of static rows from YAML.

type SQLQuery

type SQLQuery[T any] struct {
	SQL   string
	RowTo pgx.RowToFunc[T]
	// contains filtered or unexported fields
}

SQLQuery holds a configurable SQL query en handle fetching rows from Postgres. *SQLQuery implements Querier.

func (*SQLQuery[_]) Err

func (q *SQLQuery[_]) Err() error

func (*SQLQuery[_]) Next

func (q *SQLQuery[_]) Next() bool

func (*SQLQuery[_]) Query

func (q *SQLQuery[_]) Query(ctx context.Context, pgconn Conn)

func (*SQLQuery[T]) Row

func (q *SQLQuery[T]) Row() T

type YAMLQuery

type YAMLQuery[T any] struct {
	Rows []T
	// contains filtered or unexported fields
}

YAMLQuery holds a static rowset from config file

func (*YAMLQuery[_]) Err

func (q *YAMLQuery[_]) Err() error

func (*YAMLQuery[_]) Next

func (q *YAMLQuery[_]) Next() bool

func (*YAMLQuery[_]) Query

func (q *YAMLQuery[_]) Query(_ context.Context, _ Conn)

func (*YAMLQuery[T]) Row

func (q *YAMLQuery[T]) Row() T

Jump to

Keyboard shortcuts

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