Documentation
¶
Index ¶
- Constants
- Variables
- func BuildValidationWarningString(failures []*ValidationFailure) string
- func DeleteConnectionStateFile()
- func GetLoadingConnectionStatusMessage(connectionStateMap ConnectionStateMap, requiredSchemas ...string) string
- func NewConnectionUpdates(ctx context.Context, pool *pgxpool.Pool, ...) (*ConnectionUpdates, *RefreshConnectionResult)
- func SaveConnectionStateFile(res *RefreshConnectionResult, connectionUpdates *ConnectionUpdates)
- func SteampipeOptionsBlockMapping(block *hcl.Block) (poptions.Options, hcl.Diagnostics)
- func ValidateConnectionName(connectionName string) error
- type ConnectionPlugin
- type ConnectionPluginData
- type ConnectionSchemaMap
- type ConnectionState
- func (d *ConnectionState) CanCloneSchema() bool
- func (d *ConnectionState) Disabled() bool
- func (d *ConnectionState) Equals(other *ConnectionState) bool
- func (d *ConnectionState) Error() string
- func (d *ConnectionState) GetType() string
- func (d *ConnectionState) Loaded() bool
- func (d *ConnectionState) SetError(err string)
- type ConnectionStateMap
- func (m ConnectionStateMap) ConnectionModTime() time.Time
- func (m ConnectionStateMap) ConnectionsInState(states ...string) bool
- func (m ConnectionStateMap) Equals(other ConnectionStateMap) bool
- func (m ConnectionStateMap) GetFirstSearchPathConnectionForPlugins(searchPath []string) []string
- func (m ConnectionStateMap) GetPluginToConnectionMap() map[string][]string
- func (m ConnectionStateMap) GetSummary() ConnectionStateSummary
- func (m ConnectionStateMap) Loaded(connections ...string) bool
- func (m ConnectionStateMap) Pending() bool
- func (m ConnectionStateMap) PopulateFilename()
- func (m ConnectionStateMap) Save() error
- func (m ConnectionStateMap) SetConnectionsToPendingOrIncomplete()
- type ConnectionStateSummary
- type ConnectionUpdates
- type ConnectionUpdatesOption
- type DependencyPathKey
- type ErrorsAndWarningsNotification
- type LoadConnectionStateConfiguration
- type LoadConnectionStateOption
- type PostgresNotification
- type PostgresNotificationType
- type RefreshConnectionResult
- type SteampipeConfig
- func (c *SteampipeConfig) ConfigMap() map[string]interface{}
- func (c *SteampipeConfig) ConnectionList() []*modconfig.SteampipeConnection
- func (c *SteampipeConfig) ConnectionNames() []string
- func (c *SteampipeConfig) ConnectionsForPlugin(pluginLongName string, pluginVersion *version.Version) []*modconfig.SteampipeConnection
- func (c *SteampipeConfig) GetNonSearchPathConnections(searchPath []string) []string
- func (c *SteampipeConfig) SetOptions(opts poptions.Options) (errorsAndWarnings error_helpers.ErrorAndWarnings)
- func (c *SteampipeConfig) String() string
- func (c *SteampipeConfig) Validate() (validationWarnings, validationErrors []string)
- type ValidationFailure
- type WaitModeValue
Constants ¶
const PostgresNotificationStructVersion = 20230306
Variables ¶
var GlobalWorkspaceProfile *workspace_profile.SteampipeWorkspaceProfile
var WithWaitForSearchPath = func(searchPath []string) func(config *LoadConnectionStateConfiguration) { return func(config *LoadConnectionStateConfiguration) { config.WaitMode = WaitForSearchPath config.SearchPath = searchPath } }
var WithWaitUntilLoading = func() func(config *LoadConnectionStateConfiguration) { return func(config *LoadConnectionStateConfiguration) { config.WaitMode = WaitForLoading } }
WithWaitUntilLoading waits until no connections are in pending state
var WithWaitUntilReady = func(connections ...string) func(config *LoadConnectionStateConfiguration) { return func(config *LoadConnectionStateConfiguration) { config.Connections = connections config.WaitMode = WaitForReady } }
WithWaitUntilReady waits until all are in ready state
Functions ¶
func BuildValidationWarningString ¶
func BuildValidationWarningString(failures []*ValidationFailure) string
func DeleteConnectionStateFile ¶
func DeleteConnectionStateFile()
func GetLoadingConnectionStatusMessage ¶
func GetLoadingConnectionStatusMessage(connectionStateMap ConnectionStateMap, requiredSchemas ...string) string
func NewConnectionUpdates ¶
func NewConnectionUpdates(ctx context.Context, pool *pgxpool.Pool, pluginManager pluginshared.PluginManager, opts ...ConnectionUpdatesOption) (*ConnectionUpdates, *RefreshConnectionResult)
NewConnectionUpdates returns updates to be made to the database to sync with connection config
func SaveConnectionStateFile ¶
func SaveConnectionStateFile(res *RefreshConnectionResult, connectionUpdates *ConnectionUpdates)
func SteampipeOptionsBlockMapping ¶
SteampipeOptionsBlockMapping is an OptionsBlockFactory used to map GLOBAL steampipe options
func ValidateConnectionName ¶
Types ¶
type ConnectionPlugin ¶
type ConnectionPlugin struct {
// map of connection data (name, config, options)
// keyed by connection name
ConnectionMap map[string]*ConnectionPluginData
PluginName string
PluginClient *sdkgrpc.PluginClient
SupportedOperations *proto.SupportedOperations
PluginShortName string
}
ConnectionPlugin is a structure representing an instance of a plugin for non-legacy plugins, each plugin instance supportds multiple connections the config, options and schema for each connection is stored in ConnectionMap
func NewConnectionPlugin ¶
func NewConnectionPlugin(pluginShortName, pluginName string, pluginClient *sdkgrpc.PluginClient, supportedOperations *proto.SupportedOperations) *ConnectionPlugin
type ConnectionPluginData ¶
type ConnectionSchemaMap ¶
ConnectionSchemaMap is a map of connection to all connections with the same schema key is exemplar connection and value is all connections with same schema
func NewConnectionSchemaMap ¶
func NewConnectionSchemaMap(ctx context.Context, connectionStateMap ConnectionStateMap, searchPath []string) ConnectionSchemaMap
NewConnectionSchemaMap creates a ConnectionSchemaMap for all configured connections this is a map keyed by exemplar connection with the value the connections which have the same schema it uses the current connection state to determine if a connection has a dynamic schema
type ConnectionState ¶
type ConnectionState struct {
// the connection name
ConnectionName string `json:"connection" db:"name"`
// connection type (expected value: "aggregator")
Type *string `json:"type,omitempty" db:"type"`
// should we create a postgres schema for the connection (expected values: "enable", "disable")
ImportSchema string `json:"import_schema" db:"import_schema"`
// the fully qualified name of the plugin
Plugin string `json:"plugin" db:"plugin"`
// the plugin instance
PluginInstance *string `json:"plugin_instance" db:"plugin_instance"`
// the connection state (pending, updating, deleting, error, ready)
State string `json:"state" db:"state"`
// error (if there is one - make a pointer to support null)
ConnectionError *string `json:"error,omitempty" db:"error"`
// schema mode - static or dynamic
SchemaMode string `json:"schema_mode" db:"schema_mode"`
// the hash of the connection schema - this is used to determine if a dynamic schema has changed
SchemaHash string `json:"schema_hash,omitempty" db:"schema_hash"`
// are the comments set
CommentsSet bool `json:"comments_set" db:"comments_set"`
// the creation time of the plugin file
PluginModTime time.Time `json:"plugin_mod_time" db:"plugin_mod_time"`
// the update time of the connection
ConnectionModTime time.Time `json:"connection_mod_time" db:"connection_mod_time"`
// the matching patterns of child connections (for aggregators)
Connections []string `json:"connections" db:"connections"`
FileName string `json:"file_name" db:"file_name"`
StartLineNumber int `json:"start_line_number" db:"start_line_number"`
EndLineNumber int `json:"end_line_number" db:"end_line_number"`
}
ConnectionState is a struct containing all details for a connection - the plugin name and checksum, the connection config and options json tags needed as this is stored in the connection state file
func NewConnectionState ¶
func NewConnectionState(connection *modconfig.SteampipeConnection, creationTime time.Time) *ConnectionState
func (*ConnectionState) CanCloneSchema ¶
func (d *ConnectionState) CanCloneSchema() bool
func (*ConnectionState) Disabled ¶
func (d *ConnectionState) Disabled() bool
func (*ConnectionState) Equals ¶
func (d *ConnectionState) Equals(other *ConnectionState) bool
func (*ConnectionState) Error ¶
func (d *ConnectionState) Error() string
func (*ConnectionState) GetType ¶
func (d *ConnectionState) GetType() string
func (*ConnectionState) Loaded ¶
func (d *ConnectionState) Loaded() bool
Loaded returns true if the connection state is 'ready' or 'error' Disabled connections are considered as 'loaded'
func (*ConnectionState) SetError ¶
func (d *ConnectionState) SetError(err string)
type ConnectionStateMap ¶
type ConnectionStateMap map[string]*ConnectionState
func GetRequiredConnectionStateMap ¶
func GetRequiredConnectionStateMap(connectionMap map[string]*modconfig.SteampipeConnection, currentConnectionState ConnectionStateMap) (ConnectionStateMap, map[string][]modconfig.SteampipeConnection, error_helpers.ErrorAndWarnings)
GetRequiredConnectionStateMap populates a map of connection data for all connections in connectionMap
func LoadConnectionState ¶
func LoadConnectionState(ctx context.Context, conn *pgx.Conn, opts ...LoadConnectionStateOption) (ConnectionStateMap, error)
LoadConnectionState populates a ConnectionStateMap from the connection_state table it verifies the table has been initialised by calling RefreshConnections after db startup
func (ConnectionStateMap) ConnectionModTime ¶
func (m ConnectionStateMap) ConnectionModTime() time.Time
ConnectionModTime returns the latest connection mod time
func (ConnectionStateMap) ConnectionsInState ¶
func (m ConnectionStateMap) ConnectionsInState(states ...string) bool
ConnectionsInState returns whether there are any connections one of the given states
func (ConnectionStateMap) Equals ¶
func (m ConnectionStateMap) Equals(other ConnectionStateMap) bool
func (ConnectionStateMap) GetFirstSearchPathConnectionForPlugins ¶
func (m ConnectionStateMap) GetFirstSearchPathConnectionForPlugins(searchPath []string) []string
func (ConnectionStateMap) GetPluginToConnectionMap ¶
func (m ConnectionStateMap) GetPluginToConnectionMap() map[string][]string
func (ConnectionStateMap) GetSummary ¶
func (m ConnectionStateMap) GetSummary() ConnectionStateSummary
func (ConnectionStateMap) Loaded ¶
func (m ConnectionStateMap) Loaded(connections ...string) bool
Loaded returns whether loading is complete, i.e. all connections are either ready or error (optionally, a list of connections may be passed, in which case just these connections are checked)
func (ConnectionStateMap) Pending ¶
func (m ConnectionStateMap) Pending() bool
Pending returns whether there are any connections in the map which are pending this indicates that the db has just started and RefreshConnections has not been called yet
func (ConnectionStateMap) PopulateFilename ¶
func (m ConnectionStateMap) PopulateFilename()
PopulateFilename sets the Filename, StartLineNumber and EndLineNumber properties this is required as these fields were added to the table after release
func (ConnectionStateMap) Save ¶
func (m ConnectionStateMap) Save() error
func (ConnectionStateMap) SetConnectionsToPendingOrIncomplete ¶
func (m ConnectionStateMap) SetConnectionsToPendingOrIncomplete()
type ConnectionStateSummary ¶
type ConnectionUpdates ¶
type ConnectionUpdates struct {
Update ConnectionStateMap
Delete map[string]struct{}
Error map[string]struct{}
Disabled map[string]struct{}
MissingComments ConnectionStateMap
// map of missing plugins, keyed by plugin ALIAS
// NOTE: we key by alias so the error message refers to the string which was used to specify the plugin
MissingPlugins map[string][]modconfig.SteampipeConnection
// the connections which will exist after the update
FinalConnectionState ConnectionStateMap
// connection plugins required to perform the updates, keyed by connection name
ConnectionPlugins map[string]*ConnectionPlugin
CurrentConnectionState ConnectionStateMap
InvalidConnections map[string]*ValidationFailure
// map of plugin to connection for which we must refetch the rate limiter definitions
PluginsWithUpdatedBinary map[string]string
// contains filtered or unexported fields
}
func (*ConnectionUpdates) DynamicUpdates ¶
func (u *ConnectionUpdates) DynamicUpdates() []string
DynamicUpdates returns the names of all dynamic plugins which are being updated
func (*ConnectionUpdates) GetConnectionsToDelete ¶
func (u *ConnectionUpdates) GetConnectionsToDelete() []string
func (*ConnectionUpdates) HasUpdates ¶
func (u *ConnectionUpdates) HasUpdates() bool
func (*ConnectionUpdates) IdentifyMissingComments ¶
func (u *ConnectionUpdates) IdentifyMissingComments()
IdentifyMissingComments identifies any connections which are not being updated/deleted but which have not got comments set NOTE: this mutates FinalConnectionState to set comment_set (if needed)
func (*ConnectionUpdates) String ¶
func (u *ConnectionUpdates) String() string
type ConnectionUpdatesOption ¶
type ConnectionUpdatesOption func(opt *connectionUpdatesConfig)
func WithForceUpdate ¶
func WithForceUpdate(connections []string) ConnectionUpdatesOption
type DependencyPathKey ¶
type DependencyPathKey string
DependencyPathKey is a string representation of a dependency path
- a set of mod dependencyPath values separated by '->'
e.g. local -> github.com/kaidaguerre/steampipe-mod-m1@v3.1.1 -> github.com/kaidaguerre/steampipe-mod-m2@v5.1.1
func (DependencyPathKey) GetParent ¶
func (k DependencyPathKey) GetParent() DependencyPathKey
func (DependencyPathKey) PathLength ¶
func (k DependencyPathKey) PathLength() int
how long is the depdency path
type ErrorsAndWarningsNotification ¶
type ErrorsAndWarningsNotification struct {
PostgresNotification
Errors []string
Warnings []string
}
func NewErrorsAndWarningsNotification ¶
func NewErrorsAndWarningsNotification(errorAndWarnings error_helpers.ErrorAndWarnings) *ErrorsAndWarningsNotification
type LoadConnectionStateConfiguration ¶
type LoadConnectionStateConfiguration struct {
WaitMode WaitModeValue
Connections []string
SearchPath []string
}
type LoadConnectionStateOption ¶
type LoadConnectionStateOption = func(config *LoadConnectionStateConfiguration)
type PostgresNotification ¶
type PostgresNotification struct {
StructVersion int
Type PostgresNotificationType
}
func NewSchemaUpdateNotification ¶
func NewSchemaUpdateNotification() *PostgresNotification
type PostgresNotificationType ¶
type PostgresNotificationType int
const ( PgNotificationSchemaUpdate PostgresNotificationType = iota + 1 PgNotificationConnectionError )
type RefreshConnectionResult ¶
type RefreshConnectionResult struct {
error_helpers.ErrorAndWarnings
UpdatedConnections bool
FailedConnections map[string]string
}
RefreshConnectionResult is a structure used to contain the result of either a RefreshConnections or a NewLocalClient operation
func CreateConnectionPlugins ¶
func CreateConnectionPlugins(pluginManager pluginshared.PluginManager, connectionNamesToCreate []string) (requestedConnectionPluginMap map[string]*ConnectionPlugin, res *RefreshConnectionResult)
CreateConnectionPlugins instantiates plugins for specified connections, and fetches schemas
func NewErrorRefreshConnectionResult ¶
func NewErrorRefreshConnectionResult(err error) *RefreshConnectionResult
func (*RefreshConnectionResult) AddFailedConnection ¶
func (r *RefreshConnectionResult) AddFailedConnection(c string, failure string)
func (*RefreshConnectionResult) Merge ¶
func (r *RefreshConnectionResult) Merge(other *RefreshConnectionResult)
func (*RefreshConnectionResult) String ¶
func (r *RefreshConnectionResult) String() string
type SteampipeConfig ¶
type SteampipeConfig struct {
// map of plugin configs, keyed by plugin image ref
// (for each image ref we store an array of configs)
Plugins map[string][]*plugin.Plugin
// map of plugin configs, keyed by plugin instance
PluginsInstances map[string]*plugin.Plugin
// map of connection name to partially parsed connection config
Connections map[string]*modconfig.SteampipeConnection
// Steampipe options
DatabaseOptions *options.Database
GeneralOptions *options.General
PluginOptions *options.Plugin
// map of installed plugin versions, keyed by plugin image ref
PluginVersions map[string]*versionfile.InstalledVersion
}
SteampipeConfig is a struct to hold Connection map and Steampipe options
var GlobalConfig *SteampipeConfig
func LoadConnectionConfig ¶
func LoadConnectionConfig(ctx context.Context) (*SteampipeConfig, perror_helpers.ErrorAndWarnings)
LoadConnectionConfig loads the connection config but not the workspace options this is called by the fdw
func LoadSteampipeConfig ¶
func LoadSteampipeConfig(ctx context.Context, modLocation string, commandName string) (*SteampipeConfig, perror_helpers.ErrorAndWarnings)
LoadSteampipeConfig loads the HCL connection config and workspace options
func NewSteampipeConfig ¶
func NewSteampipeConfig(commandName string) *SteampipeConfig
func (*SteampipeConfig) ConfigMap ¶
func (c *SteampipeConfig) ConfigMap() map[string]interface{}
ConfigMap creates a config map to pass to viper
func (*SteampipeConfig) ConnectionList ¶
func (c *SteampipeConfig) ConnectionList() []*modconfig.SteampipeConnection
func (*SteampipeConfig) ConnectionNames ¶
func (c *SteampipeConfig) ConnectionNames() []string
ConnectionNames returns a flat list of connection names
func (*SteampipeConfig) ConnectionsForPlugin ¶
func (c *SteampipeConfig) ConnectionsForPlugin(pluginLongName string, pluginVersion *version.Version) []*modconfig.SteampipeConnection
func (*SteampipeConfig) GetNonSearchPathConnections ¶
func (c *SteampipeConfig) GetNonSearchPathConnections(searchPath []string) []string
GetNonSearchPathConnections returns a list of connection names that are not in the provided search path
func (*SteampipeConfig) SetOptions ¶
func (c *SteampipeConfig) SetOptions(opts poptions.Options) (errorsAndWarnings error_helpers.ErrorAndWarnings)
func (*SteampipeConfig) String ¶
func (c *SteampipeConfig) String() string
func (*SteampipeConfig) Validate ¶
func (c *SteampipeConfig) Validate() (validationWarnings, validationErrors []string)
Validate validates all connections connections with validation errors are removed
type ValidationFailure ¶
type ValidationFailure struct {
Plugin string
ConnectionName string
Message string
ShouldDropIfExists bool
}
func (ValidationFailure) String ¶
func (v ValidationFailure) String() string
type WaitModeValue ¶
type WaitModeValue int
const ( NoWait WaitModeValue = iota WaitForLoading WaitForReady WaitForSearchPath )
Source Files
¶
- connection_plugin.go
- connection_schemas.go
- connection_state.go
- connection_state_map.go
- connection_updates.go
- connection_updates_opts.go
- connection_updates_validate.go
- dependency_path.go
- load_config.go
- load_connection_state.go
- load_connection_state_option.go
- postgres_notification.go
- refresh_connections_result.go
- steampipeconfig.go
- validate.go
- validation_failure.go