steampipeconfig

package
v0.14.5-alpha.0 Latest Latest
Warning

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

Go to latest
Published: May 17, 2022 License: AGPL-3.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConnectionDataStructVersion int64 = 20211125

ConnectionDataStructVersion is used to force refreshing connections If we need to force a connection refresh (for example if any of the underlying schema generation code changes), updating this version will force all connections to refresh, as the deserialized data will have an old version

Functions

func BuildValidationWarningString

func BuildValidationWarningString(failures []*ValidationFailure) string

func GetModFileExtensions added in v0.4.0

func GetModFileExtensions() []string

GetModFileExtensions :: return list of all file extensions we care about this will be the mod data extension, plus any registered extensions registered in fileToResourceMap

func GetVariableValues added in v0.14.5

func GetVariableValues(ctx context.Context, runCtx *parse.RunContext, variableMap *modconfig.ModVariableMap, validate bool) (*modconfig.ModVariableMap, error)

func LoadMod added in v0.4.0

func LoadMod(ctx context.Context, modPath string, runCtx *parse.RunContext, variableMap *modconfig.ModVariableMap) (mod *modconfig.Mod, err error)

LoadMod parses all hcl files in modPath and returns a single mod if CreatePseudoResources flag is set, construct hcl resources for files with specific extensions NOTE: it is an error if there is more than 1 mod defined, however zero mods is acceptable - a default mod will be created assuming there are any resource files

func LoadModDefinition

func LoadModDefinition(modPath string, runCtx *parse.RunContext) (*modconfig.Mod, error)

func LoadModDependencies added in v0.4.0

func LoadModDependencies(mod *modconfig.Mod, runCtx *parse.RunContext) error

func LoadModResourceNames added in v0.8.0

func LoadModResourceNames(modPath string, runCtx *parse.RunContext) (resources *modconfig.WorkspaceResources, err error)

LoadModResourceNames parses all hcl files in modPath and returns the names of all resources

func LoadModResources

func LoadModResources(modPath string, runCtx *parse.RunContext, mod *modconfig.Mod) (*modconfig.Mod, error)

func LoadVariableDefinitions added in v0.14.5

func LoadVariableDefinitions(variablePath string, runCtx *parse.RunContext) (*modconfig.ModVariableMap, error)

func NewConnectionUpdates added in v0.9.0

func NewConnectionUpdates(schemaNames []string) (*ConnectionUpdates, *RefreshConnectionResult)

NewConnectionUpdates returns updates to be made to the database to sync with connection config

Types

type ActorMetadata added in v0.13.0

type ActorMetadata struct {
	Id     string `json:"id,omitempty"`
	Handle string `json:"handle,omitempty"`
}

type CloudMetadata added in v0.13.0

type CloudMetadata struct {
	Actor            *ActorMetadata     `json:"actor,omitempty"`
	Identity         *IdentityMetadata  `json:"identity,omitempty"`
	Workspace        *WorkspaceMetadata `json:"workspace,omitempty"`
	ConnectionString string             `json:"-"`
}

func NewCloudMetadata added in v0.13.0

func NewCloudMetadata() *CloudMetadata

type ConnectionData

type ConnectionData struct {
	StructVersion int64 `json:"struct_version,omitempty"`
	// the fully qualified name of the plugin
	Plugin string `json:"plugin,omitempty"`
	// the underlying connection object
	Connection *modconfig.Connection `json:"connection,omitempty"`
	// schema mode - static or dynamic
	SchemaMode string `json:"schema_mode,omitempty"`
	// the hash of the connection schema
	SchemaHash string `json:"schema_hash,omitempty"`
	// the creation time of the plugin file (only used for local plugins)
	ModTime time.Time `json:"mod_time"`

	// legacy properties included for backwards compatibility with v0.13
	LegacyPlugin     string                `json:"Plugin,omitempty"`
	LegacyConnection *modconfig.Connection `json:"Connection,omitempty"`
	LegacySchemaMode string                `json:"SchemaMode,omitempty"`
	LegacySchemaHash string                `json:"SchemaHash,omitempty"`
	LegacyModTime    time.Time             `json:"ModTime,omitempty"`
}

ConnectionData 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 NewConnectionData added in v0.9.0

func NewConnectionData(remoteSchema string, connection *modconfig.Connection, creationTime time.Time) *ConnectionData

func (*ConnectionData) Equals added in v0.4.0

func (p *ConnectionData) Equals(other *ConnectionData) bool

func (*ConnectionData) IsValid added in v0.14.0

func (s *ConnectionData) IsValid() bool

IsValid checks whether the struct was correctly deserialized, by checking if the StructVersion is populated

func (*ConnectionData) MaintainLegacy added in v0.14.0

func (s *ConnectionData) MaintainLegacy()

MaintainLegacy keeps the values of the legacy properties intact while refreshing connections

func (*ConnectionData) MigrateLegacy added in v0.14.0

func (s *ConnectionData) MigrateLegacy()

MigrateLegacy migrates the legacy properties into new properties

type ConnectionDataMap added in v0.9.0

type ConnectionDataMap map[string]*ConnectionData

func GetConnectionState

func GetConnectionState(schemaNames []string) (ConnectionDataMap, error)

GetConnectionState loads the connection state file, and remove any connections which do not exist in the db

func NewConnectionDataMap added in v0.9.0

func NewConnectionDataMap(connectionMap map[string]*modconfig.Connection) (ConnectionDataMap, []string, error)

NewConnectionDataMap populates a map of connection data for all connections in connectionMap

func (ConnectionDataMap) Connections added in v0.10.0

func (m ConnectionDataMap) Connections() []*modconfig.Connection

func (ConnectionDataMap) Equals added in v0.9.0

func (m ConnectionDataMap) Equals(other ConnectionDataMap) bool

func (*ConnectionDataMap) IsValid added in v0.14.0

func (s *ConnectionDataMap) IsValid() bool

IsValid checks whether the struct was correctly deserialized, by checking if the ConnectionData StructVersion is populated

func (*ConnectionDataMap) MigrateFrom added in v0.14.0

func (s *ConnectionDataMap) MigrateFrom() migrate.Migrateable

func (*ConnectionDataMap) Save added in v0.14.0

func (f *ConnectionDataMap) Save() error

type ConnectionPlugin

type ConnectionPlugin struct {
	ConnectionName      string
	ConnectionConfig    string
	ConnectionOptions   *options.Connection
	PluginName          string
	PluginClient        *sdkgrpc.PluginClient
	Schema              *sdkproto.Schema
	SupportedOperations *sdkproto.GetSupportedOperationsResponse
}

ConnectionPlugin is a structure representing an instance of a plugin NOTE: this corresponds to a single steampipe connection, i.e. we have 1 plugin instance per steampipe connection

type ConnectionSchemaMap added in v0.11.0

type ConnectionSchemaMap map[string][]string

ConnectionSchemaMap is a map of connection to all connections with the same schema

func NewConnectionSchemaMap added in v0.11.0

func NewConnectionSchemaMap() (ConnectionSchemaMap, error)

NewConnectionSchemaMap creates a ConnectionSchemaMap for all configured connections it uses the current connection state to determine if a connection has a dynamic schema (NOTE: this will no work for newly added plugins which will not have a state yet - which is why CreateConnectionPlugins loads the schemas for each new plugin and calls NewConnectionSchemaMapForConnections directly, passing the schema modes)

func NewConnectionSchemaMapForConnections added in v0.11.0

func NewConnectionSchemaMapForConnections(connections []*modconfig.Connection, schemaModeMap map[string]string) ConnectionSchemaMap

func (ConnectionSchemaMap) UniqueSchemas added in v0.11.0

func (c ConnectionSchemaMap) UniqueSchemas() []string

UniqueSchemas returns the unique schemas for all loaded connections

type ConnectionUpdates

type ConnectionUpdates struct {
	Update         ConnectionDataMap
	Delete         ConnectionDataMap
	MissingPlugins []string
	// the connections which will exist after the update
	RequiredConnectionState ConnectionDataMap
	// connection plugins required to perform the updates
	ConnectionPlugins map[string]*ConnectionPlugin
	// contains filtered or unexported fields
}

func (*ConnectionUpdates) HasUpdates added in v0.13.1

func (u *ConnectionUpdates) HasUpdates() bool

type CreateConnectionPluginOptions added in v0.13.0

type CreateConnectionPluginOptions struct {
	SetConnectionConfig bool
}

type IdentityMetadata added in v0.13.0

type IdentityMetadata struct {
	Id     string `json:"id,omitempty"`
	Handle string `json:"handle,omitempty"`
	Type   string `json:"type,omitempty"`
}

type RefreshConnectionResult added in v0.9.0

type RefreshConnectionResult struct {
	UpdatedConnections bool
	Warnings           []string
	Error              error
}

RefreshConnectionResult is a structure used to contain the result of either a RefreshConnections or a NewLocalClient operation

func CreateConnectionPlugins added in v0.10.0

func CreateConnectionPlugins(connections []*modconfig.Connection, opts *CreateConnectionPluginOptions) (connectionPluginMap map[string]*ConnectionPlugin, res *RefreshConnectionResult)

CreateConnectionPlugins instantiates plugins for specified connections, fetches schemas and sends connection config

func (*RefreshConnectionResult) AddWarning added in v0.10.0

func (r *RefreshConnectionResult) AddWarning(warning string)

func (*RefreshConnectionResult) Merge added in v0.9.0

func (*RefreshConnectionResult) ShowWarnings added in v0.9.0

func (r *RefreshConnectionResult) ShowWarnings()

type SteampipeConfig

type SteampipeConfig struct {
	// map of connection name to partially parsed connection config
	Connections map[string]*modconfig.Connection

	// Steampipe options
	DefaultConnectionOptions *options.Connection
	DatabaseOptions          *options.Database
	TerminalOptions          *options.Terminal
	GeneralOptions           *options.General
	// contains filtered or unexported fields
}

SteampipeConfig is a struct to hold Connection map and Steampipe options

var GlobalConfig *SteampipeConfig

func LoadConnectionConfig added in v0.9.0

func LoadConnectionConfig() (*SteampipeConfig, error)

LoadConnectionConfig loads the connection config but not the workspace options this is called by the fdw

func LoadSteampipeConfig added in v0.4.0

func LoadSteampipeConfig(workspacePath string, commandName string) (*SteampipeConfig, error)

LoadSteampipeConfig loads the HCL connection config and workspace options

func NewSteampipeConfig added in v0.9.0

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 added in v0.11.0

func (c *SteampipeConfig) ConnectionList() []*modconfig.Connection

func (*SteampipeConfig) ConnectionNames added in v0.11.0

func (c *SteampipeConfig) ConnectionNames() []string

ConnectionNames returns a flat list of connection names

func (*SteampipeConfig) ConnectionsForPlugin added in v0.10.0

func (c *SteampipeConfig) ConnectionsForPlugin(pluginLongName string, pluginVersion *version.Version) []*modconfig.Connection

func (*SteampipeConfig) GetConnectionOptions

func (c *SteampipeConfig) GetConnectionOptions(connectionName string) *options.Connection

func (*SteampipeConfig) SetOptions

func (c *SteampipeConfig) SetOptions(opts options.Options)

func (*SteampipeConfig) String added in v0.4.0

func (c *SteampipeConfig) String() string

func (*SteampipeConfig) Validate added in v0.7.0

func (c *SteampipeConfig) Validate() error

type ValidationFailure

type ValidationFailure struct {
	Plugin             string
	ConnectionName     string
	Message            string
	ShouldDropIfExists bool
}

func (ValidationFailure) String

func (v ValidationFailure) String() string

type WorkspaceMetadata added in v0.13.0

type WorkspaceMetadata struct {
	Id     string `json:"id,omitempty"`
	Handle string `json:"handle,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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