util

package
v0.0.0-...-465781a Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2020 License: MIT Imports: 18 Imported by: 0

Documentation

Overview

Package util contains various utility methods and constants

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateExtension

func CreateExtension(ctx context.Context, dbConnection *sql.DB, ext model.Extension) error

CreateExtension creates a postgres extension in the database

func CreateServer

func CreateServer(ctx context.Context, dbConnection *sql.DB, server model.ForeignServer) error

func CreateUserMap

func CreateUserMap(ctx context.Context, dbConnection *sql.DB, usermap model.UserMap) error

func DiffExtensions

func DiffExtensions(dStateExts []model.Extension, dbExts []model.Extension) (extRemove []model.Extension, extAdd []model.Extension)

DiffExtensions takes two lists of extensions and produces a list of extensions that migrate the second list (dbExts) to equal the first (dStateExts). The first list (dStateExts) is the desired state; the second list (dbExts) is the current state. A list of extensions to remove and extensions to add are returned.

func DiffForeignServers

func DiffForeignServers(dStateServers []model.ForeignServer, dbServers []model.ForeignServer) (fsRemove []model.ForeignServer, fsAdd []model.ForeignServer, fsModify []model.ForeignServer)

DiffForeignServers produces a list of `ForeignServers` to remove, add, and modify to bring `dbServers` in line with `dStateServers`

func DiffSchemas

func DiffSchemas(dStateSchemas []model.Schema, dbSchemas []model.Schema) (schRemove []model.Schema, schAdd []model.Schema, schModify []model.Schema)

DiffSchemas takes two lists of schemas and produces a list of schemas that migrate the second list (dbSchemas) to equal the first (dStateSchemas). The first list (dStateSchemas) is the desired state; the second list (dbSchemas) is the current state. A list of schemas to remove, schemas to add, and schemas to modify are returned.

func DiffUserMaps

func DiffUserMaps(dStateUserMaps []model.UserMap, dbUserMaps []model.UserMap) (umRemove []model.UserMap, umAdd []model.UserMap, umModify []model.UserMap)

func DropExtension

func DropExtension(ctx context.Context, dbConnection *sql.DB, ext model.Extension) error

DropExtension drops a postgres extension from the database

func DropSchema

func DropSchema(ctx context.Context, dbConnection *sql.DB, schema model.Schema, cascadeDrop bool) error

DropSchema drops a database schema with optional CASCADE

func DropServer

func DropServer(ctx context.Context, dbConnection *sql.DB, servername string, cascade bool) error

func DropUser

func DropUser(ctx context.Context, dbConnection *sql.DB, username string) error

func DropUserMap

func DropUserMap(ctx context.Context, dbConnection *sql.DB, usermap model.UserMap, dropLocalUser bool) error

func EnsureUser

func EnsureUser(ctx context.Context, dbConnection *sql.DB, userName string, userPassword string) error

func FindForeignServer

func FindForeignServer(foreignServers []model.ForeignServer, serverName string) *model.ForeignServer

func FindUserMap

func FindUserMap(usermaps []model.UserMap, localuser string) *model.UserMap

func GetExtensions

func GetExtensions(ctx context.Context, dbConnection *sql.DB) ([]model.Extension, error)

GetExtensions returns a list of installed extensions

func GetSchemasForServer

func GetSchemasForServer(ctx context.Context, dbConnection *sql.DB, serverName string) ([]model.Schema, error)

GetSchemasForServer returns a list of foreign schemas

func GetSecret

func GetSecret(ctx context.Context, secret model.Secret) (string, error)

func GetServers

func GetServers(ctx context.Context, dbConnection *sql.DB) ([]model.ForeignServer, error)

func GetUserMapsForServer

func GetUserMapsForServer(ctx context.Context, dbConnection *sql.DB, foreignServer string) ([]model.UserMap, error)

func ImportSchema

func ImportSchema(ctx context.Context, dbConnection *sql.DB, serverName string, schema model.Schema) error

ImportSchema attempts to import a remote schema from a foreign server into a local schema, optionally importing ENUM types used in the remote schema as well.

func ResolveConnectionString

func ResolveConnectionString(connStr string, secret *model.Secret) string

ResolveConnectionString returns a connection string populated with a credential obtained using the supplied secret configuration

func SecretIsDefined

func SecretIsDefined(secret model.Secret) bool

func StartsWithNumber

func StartsWithNumber(str string) bool

StartsWithNumber determines if a string starts with a number

func StringCoalesce

func StringCoalesce(args ...string) string

StringCoalesce returns the first string in the supplied arguments that is non-empty when trimmed. If there is no such string, the empty string is returned.

func UpdateServer

func UpdateServer(ctx context.Context, dbConnection *sql.DB, server model.ForeignServer) error

func UpdateServerName

func UpdateServerName(ctx context.Context, dbConnection *sql.DB, server model.ForeignServer, newServerName string) error

func UpdateUserMap

func UpdateUserMap(ctx context.Context, dbConnection *sql.DB, usermap model.UserMap) error

Types

This section is empty.

Jump to

Keyboard shortcuts

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