db_local

package
v0.13.0-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: AGPL-3.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const CertIssuer = "steampipe.io"
View Source
const ServiceExecutableRelativeLocation = "/db/12.1.0/postgres/bin/postgres"

Variables

View Source
var (
	CertExpiryTolerance      = 180 * (24 * time.Hour)     // 180 days
	RootCertValidityPeriod   = 5 * 365 * (24 * time.Hour) // 5 years
	ServerCertValidityPeriod = 365 * (24 * time.Hour)     // 1 year
)

Functions

func CertificatesExist

func CertificatesExist() bool

CertificatesExist checks if the root and server certificate and key files exist

func EnsureDBInstalled

func EnsureDBInstalled(ctx context.Context) (err error)

EnsureDBInstalled makes sure that the embedded pg database is installed and running

func FindAllSteampipePostgresInstances

func FindAllSteampipePostgresInstances(ctx context.Context) ([]*psutils.Process, error)

func GetCountOfThirdPartyClients added in v0.11.0

func GetCountOfThirdPartyClients(ctx context.Context) (i int, e error)

GetCountOfThirdPartyClients returns the number of connections to the service from other thrid party applications

func GetLocalClient

func GetLocalClient(ctx context.Context, invoker constants.Invoker) (db_common.Client, error)

GetLocalClient starts service if needed and creates a new LocalDbClient

func IsInstalled

func IsInstalled() bool

IsInstalled checks and reports whether the embedded database is installed and setup

func RefreshConnectionAndSearchPaths

func RefreshConnectionAndSearchPaths(ctx context.Context, invoker constants.Invoker) error

RefreshConnectionAndSearchPaths creates a local client and refreshed connections and search paths

func RemoveAllCertificates

func RemoveAllCertificates() error

RemoveAllCertificates removes root and server certificates so that they can be regenerated

func RemoveServerCertificate

func RemoveServerCertificate() error

RemoveServerCertificate removes the server certificate certificates so it will be regenerated

func ShutdownService

func ShutdownService(ctx context.Context, invoker constants.Invoker)

ShutdownService stops the database instance if the given 'invoker' matches

func TrimLogs

func TrimLogs()

func ValidateRootCertificate

func ValidateRootCertificate() bool

ValidateRootCertificate checks the root certificate exists, is not expired and has correct Subject

func ValidateServerCertificate

func ValidateServerCertificate() bool

ValidateServerCertificate checks the server certificate exists, is not expired and has correct issuer

Types

type CreateDbOptions

type CreateDbOptions struct {
	DatabaseName, Username string
}

type LocalDbClient

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

LocalDbClient wraps over DbClient

func NewLocalClient

func NewLocalClient(ctx context.Context, invoker constants.Invoker) (*LocalDbClient, error)

NewLocalClient verifies that the local database instance is running and returns a Client to interact with it

func (*LocalDbClient) AcquireSession added in v0.10.0

func (*LocalDbClient) CacheClear

func (c *LocalDbClient) CacheClear(ctx context.Context) error

CacheClear implements Client

func (*LocalDbClient) CacheOff

func (c *LocalDbClient) CacheOff(ctx context.Context) error

CacheOff implements Client

func (*LocalDbClient) CacheOn

func (c *LocalDbClient) CacheOn(ctx context.Context) error

CacheOn implements Client

func (*LocalDbClient) Close

func (c *LocalDbClient) Close(ctx context.Context) error

Close implements Client close the connection to the database and shuts down the backend

func (*LocalDbClient) ConnectionMap

func (c *LocalDbClient) ConnectionMap() *steampipeconfig.ConnectionDataMap

func (*LocalDbClient) ContructSearchPath added in v0.10.0

func (c *LocalDbClient) ContructSearchPath(ctx context.Context, requiredSearchPath []string, searchPathPrefix []string, currentSearchPath []string) ([]string, error)

func (*LocalDbClient) Execute

func (c *LocalDbClient) Execute(ctx context.Context, query string) (res *queryresult.Result, err error)

Execute implements Client

func (*LocalDbClient) ExecuteInSession added in v0.10.0

func (c *LocalDbClient) ExecuteInSession(ctx context.Context, session *db_common.DatabaseSession, query string, onComplete func()) (res *queryresult.Result, err error)

ExecuteInSession implements Client

func (*LocalDbClient) ExecuteSync

func (c *LocalDbClient) ExecuteSync(ctx context.Context, query string) (*queryresult.SyncQueryResult, error)

ExecuteSync implements Client

func (*LocalDbClient) ExecuteSyncInSession added in v0.10.0

func (c *LocalDbClient) ExecuteSyncInSession(ctx context.Context, session *db_common.DatabaseSession, query string) (*queryresult.SyncQueryResult, error)

ExecuteSyncInSession implements Client

func (*LocalDbClient) ForeignSchemas added in v0.11.0

func (c *LocalDbClient) ForeignSchemas() []string

ForeignSchemas implements Client

func (*LocalDbClient) GetCurrentSearchPath

func (c *LocalDbClient) GetCurrentSearchPath(ctx context.Context) ([]string, error)

GetCurrentSearchPath implements Client

func (*LocalDbClient) GetSchemaFromDB added in v0.11.0

func (c *LocalDbClient) GetSchemaFromDB(ctx context.Context, schemas []string) (*schema.Metadata, error)

func (*LocalDbClient) LoadForeignSchemaNames added in v0.11.0

func (c *LocalDbClient) LoadForeignSchemaNames(ctx context.Context) error

func (*LocalDbClient) RefreshConnectionAndSearchPaths

func (c *LocalDbClient) RefreshConnectionAndSearchPaths(ctx context.Context) *steampipeconfig.RefreshConnectionResult

func (*LocalDbClient) RefreshSessions added in v0.10.0

func (c *LocalDbClient) RefreshSessions(ctx context.Context) *db_common.AcquireSessionResult

func (*LocalDbClient) SetEnsureSessionDataFunc

func (c *LocalDbClient) SetEnsureSessionDataFunc(f db_common.EnsureSessionStateCallback)

SetEnsureSessionDataFunc implements Client

func (*LocalDbClient) SetSessionSearchPath

func (c *LocalDbClient) SetSessionSearchPath(ctx context.Context, currentUserPath ...string) error

SetSessionSearchPath implements Client

type Passwords

type Passwords struct {
	Root      string
	Steampipe string
}

Passwords :: structure for working with DB passwords

type RunningDBInstanceInfo

type RunningDBInstanceInfo struct {
	Pid        int
	Port       int
	Listen     []string
	ListenType StartListenType
	Invoker    constants.Invoker
	Password   string
	User       string
	Database   string
}

RunningDBInstanceInfo contains data about the running process and it's credentials

func GetState added in v0.10.0

func GetState() (*RunningDBInstanceInfo, error)

GetState checks that the database instance is running and returns its details

func (*RunningDBInstanceInfo) Save

func (r *RunningDBInstanceInfo) Save() error

func (*RunningDBInstanceInfo) String

func (r *RunningDBInstanceInfo) String() string

type StartDbStatus added in v0.11.0

type StartDbStatus int

StartDbStatus is a pseudoEnum for outcomes of starting the db

const (
	// start from 10 to prevent confusion with int zero-value
	ServiceStarted StartDbStatus = iota + 1
	ServiceAlreadyRunning
	ServiceFailedToStart
)

type StartListenType

type StartListenType string

StartListenType is a pseudoEnum of network binding for postgres

const (
	// ListenTypeNetwork - bind to all known interfaces
	ListenTypeNetwork StartListenType = "network"
	// ListenTypeLocal - bind to localhost only
	ListenTypeLocal = "local"
)

func (StartListenType) IsValid

func (slt StartListenType) IsValid() error

IsValid is a validator for StartListenType known values

type StartResult

type StartResult struct {
	Error              error
	Status             StartDbStatus
	DbState            *RunningDBInstanceInfo
	PluginManagerState *pluginmanager.PluginManagerState
}

StartResult is a pseudoEnum for outcomes of StartNewInstance

func StartServices added in v0.10.0

func StartServices(ctx context.Context, port int, listen StartListenType, invoker constants.Invoker) (startResult *StartResult)

func (*StartResult) SetError added in v0.11.0

func (r *StartResult) SetError(err error) *StartResult

type StopStatus

type StopStatus int

StopStatus is a pseudoEnum for service stop result

const (
	// start from 1 to prevent confusion with int zero-value
	ServiceStopped StopStatus = iota + 1
	ServiceNotRunning
	ServiceStopFailed
	ServiceStopTimedOut
)

func StopServices added in v0.10.0

func StopServices(ctx context.Context, force bool, invoker constants.Invoker) (status StopStatus, e error)

StopServices searches for and stops the running instance. Does nothing if an instance was not found

Jump to

Keyboard shortcuts

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