Documentation ¶
Index ¶
- Constants
- Variables
- func CertificatesExist() bool
- func EnsureDBInstalled() (err error)
- func EnsureDbAndStartService(invoker constants.Invoker) error
- func FindAllSteampipePostgresInstances() ([]*psutils.Process, error)
- func GetCountOfConnectedClients() (i int, e error)
- func GetLocalClient(invoker constants.Invoker) (db_common.Client, error)
- func IsInstalled() bool
- func PrepareDb(spinner *spinner.Spinner) error
- func RefreshConnectionAndSearchPaths(invoker constants.Invoker) error
- func RemoveAllCertificates() error
- func RemoveServerCertificate() error
- func ShutdownService(invoker constants.Invoker)
- func TrimLogs()
- func ValidateRootCertificate() bool
- func ValidateServerCertificate() bool
- type CreateDbOptions
- type LocalDbClient
- func (c *LocalDbClient) AcquireSession(ctx context.Context) *db_common.AcquireSessionResult
- func (c *LocalDbClient) CacheClear() error
- func (c *LocalDbClient) CacheOff() error
- func (c *LocalDbClient) CacheOn() error
- func (c *LocalDbClient) Close() error
- func (c *LocalDbClient) ConnectionMap() *steampipeconfig.ConnectionDataMap
- func (c *LocalDbClient) ContructSearchPath(requiredSearchPath []string, searchPathPrefix []string, ...) ([]string, error)
- func (c *LocalDbClient) Execute(ctx context.Context, query string, disableSpinner bool) (res *queryresult.Result, err error)
- func (c *LocalDbClient) ExecuteInSession(ctx context.Context, session *db_common.DatabaseSession, query string, ...) (res *queryresult.Result, err error)
- func (c *LocalDbClient) ExecuteSync(ctx context.Context, query string, disableSpinner bool) (*queryresult.SyncQueryResult, error)
- func (c *LocalDbClient) ExecuteSyncInSession(ctx context.Context, session *db_common.DatabaseSession, query string, ...) (*queryresult.SyncQueryResult, error)
- func (c *LocalDbClient) GetCurrentSearchPath() ([]string, error)
- func (c *LocalDbClient) LoadSchema()
- func (c *LocalDbClient) RefreshConnectionAndSearchPaths() *steampipeconfig.RefreshConnectionResult
- func (c *LocalDbClient) RefreshSessions(ctx context.Context) *db_common.AcquireSessionResult
- func (c *LocalDbClient) SchemaMetadata() *schema.Metadata
- func (c *LocalDbClient) SetEnsureSessionDataFunc(f db_common.EnsureSessionStateCallback)
- func (c *LocalDbClient) SetSessionSearchPath(currentUserPath ...string) error
- type Passwords
- type RunningDBInstanceInfo
- type StartListenType
- type StartResult
- type StopStatus
Constants ¶
const CertIssuer = "steampipe.io"
const ServiceExecutableRelativeLocation = "/db/12.1.0/postgres/bin/postgres"
Variables ¶
Functions ¶
func CertificatesExist ¶
func CertificatesExist() bool
CertificatesExist checks if the root and server certificate and key files exist
func EnsureDBInstalled ¶
func EnsureDBInstalled() (err error)
EnsureDBInstalled makes sure that the embedded pg database is installed and running
func EnsureDbAndStartService ¶
EnsureDbAndStartService ensures database is installed and starts service if necessary
func GetCountOfConnectedClients ¶
GetCountOfConnectedClients returns the number of clients currently connected to the service
func GetLocalClient ¶
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 ¶
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 ¶
ShutdownService stops the database instance if the given 'invoker' matches
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(invoker constants.Invoker) (*LocalDbClient, error)
NewLocalClient ensures that the database instance is running and returns a `Client` to interact with it
func (*LocalDbClient) AcquireSession ¶ added in v0.10.0
func (c *LocalDbClient) AcquireSession(ctx context.Context) *db_common.AcquireSessionResult
func (*LocalDbClient) CacheClear ¶
func (c *LocalDbClient) CacheClear() error
CacheClear implements Client
func (*LocalDbClient) CacheOff ¶
func (c *LocalDbClient) CacheOff() error
CacheOff implements Client
func (*LocalDbClient) Close ¶
func (c *LocalDbClient) Close() 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 (*LocalDbClient) Execute ¶
func (c *LocalDbClient) Execute(ctx context.Context, query string, disableSpinner bool) (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(), disableSpinner bool) (res *queryresult.Result, err error)
ExecuteInSession implements Client
func (*LocalDbClient) ExecuteSync ¶
func (c *LocalDbClient) ExecuteSync(ctx context.Context, query string, disableSpinner bool) (*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, disableSpinner bool) (*queryresult.SyncQueryResult, error)
ExecuteSyncInSession implements Client
func (*LocalDbClient) GetCurrentSearchPath ¶
func (c *LocalDbClient) GetCurrentSearchPath() ([]string, error)
GetCurrentSearchPath implements Client
func (*LocalDbClient) LoadSchema ¶
func (c *LocalDbClient) LoadSchema()
LoadSchema implements Client
func (*LocalDbClient) RefreshConnectionAndSearchPaths ¶
func (c *LocalDbClient) RefreshConnectionAndSearchPaths() *steampipeconfig.RefreshConnectionResult
func (*LocalDbClient) RefreshSessions ¶ added in v0.10.0
func (c *LocalDbClient) RefreshSessions(ctx context.Context) *db_common.AcquireSessionResult
func (*LocalDbClient) SchemaMetadata ¶
func (c *LocalDbClient) SchemaMetadata() *schema.Metadata
SchemaMetadata implements Client
func (*LocalDbClient) SetEnsureSessionDataFunc ¶
func (c *LocalDbClient) SetEnsureSessionDataFunc(f db_common.EnsureSessionStateCallback)
SetEnsureSessionDataFunc implements Client
func (*LocalDbClient) SetSessionSearchPath ¶
func (c *LocalDbClient) SetSessionSearchPath(currentUserPath ...string) error
SetSessionSearchPath implements Client
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 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 int
StartResult is a pseudoEnum for outcomes of StartNewInstance
const ( // start from 10 to prevent confusion with int zero-value ServiceStarted StartResult = iota + 1 ServiceAlreadyRunning ServiceFailedToStart )
func StartServices ¶ added in v0.10.0
func StartServices(port int, listen StartListenType, invoker constants.Invoker) (startResult StartResult, err error)
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(force bool, invoker constants.Invoker, spinner *spinner.Spinner) (status StopStatus, e error)
StopServices searches for and stops the running instance. Does nothing if an instance was not found