Documentation
¶
Overview ¶
Package state interacts with core database schema and stores cloudquery metadata such as fetch summaries
Index ¶
- type CheckResult
- type Client
- func (c *Client) Close()
- func (c *Client) CreateCheckResult(ctx context.Context, cr *CheckResult) error
- func (c *Client) CreatePolicyExecution(ctx context.Context, pe *PolicyExecution) (*PolicyExecution, error)
- func (c *Client) GetFetchSummaryForProvider(ctx context.Context, provider string) (*FetchSummary, error)
- func (c *Client) GetProvider(ctx context.Context, p registry.Provider) (*Provider, error)
- func (c *Client) ProviderSync(ctx context.Context) (*Tx, error)
- func (c *Client) PrunePolicyExecutions(ctx context.Context, pruneBefore time.Time) error
- func (c *Client) SaveFetchSummary(ctx context.Context, fs *FetchSummary) error
- type FetchSummary
- type PolicyExecution
- type Provider
- type ResourceFetchSummaries
- type ResourceFetchSummary
- type Tx
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CheckResult ¶ added in v0.24.1
type CheckResult struct {
ExecutionId uuid.UUID `db:"execution_id"`
ExecutionTimestamp time.Time `db:"execution_timestamp"`
Name string `db:"name"`
Selector string `db:"selector"`
Description string `db:"description"`
Status string `db:"status"`
RawResults string `db:"raw_results"`
Error string `db:"error"`
}
CheckResult represents the output of a single check run
type Client ¶
type Client struct {
Logger hclog.Logger
// contains filtered or unexported fields
}
func NewClient ¶
NewClient creates a client from the given DSN and migrates the metadata schema. client.Close should be called to disconnect afterwards.
func (*Client) Close ¶ added in v0.24.0
func (c *Client) Close()
Close closes the underlying database connection.
func (*Client) CreateCheckResult ¶ added in v0.24.1
func (c *Client) CreateCheckResult(ctx context.Context, cr *CheckResult) error
CreateCheckResult inserts a check result in the database
func (*Client) CreatePolicyExecution ¶ added in v0.24.1
func (c *Client) CreatePolicyExecution(ctx context.Context, pe *PolicyExecution) (*PolicyExecution, error)
CreatePolicyExecution inserts a policy execution in the database
func (*Client) GetFetchSummaryForProvider ¶
func (c *Client) GetFetchSummaryForProvider(ctx context.Context, provider string) (*FetchSummary, error)
GetFetchSummaryForProvider gets latest fetch summary for specific provider
func (*Client) GetProvider ¶ added in v0.24.0
GetProvider gets state about given provider, or returns nil, nil.
func (*Client) ProviderSync ¶ added in v0.24.0
func (*Client) PrunePolicyExecutions ¶ added in v0.24.1
PrunePolicyExecutions deletes old policy executions in the database
func (*Client) SaveFetchSummary ¶
func (c *Client) SaveFetchSummary(ctx context.Context, fs *FetchSummary) error
SaveFetchSummary saves fetch summary into fetches database
type FetchSummary ¶
type FetchSummary struct {
CqId uuid.UUID `db:"id"`
// Unique Id of fetch session
FetchId uuid.UUID `db:"fetch_id"`
CreatedAt time.Time `db:"created_at"`
Start time.Time `db:"start"`
Finish time.Time `db:"finish"`
IsSuccess bool `db:"is_success"`
TotalResourceCount uint64 `db:"total_resource_count"`
TotalErrorsCount uint64 `db:"total_errors_count"`
ProviderName string `db:"provider_name"`
ProviderAlias string `db:"provider_alias"`
ProviderVersion string `db:"provider_version"`
CoreVersion string `db:"core_version"`
Resources ResourceFetchSummaries `db:"results"`
}
FetchSummary includes a summarized report of fetch, such as fetch id, fetch start and finish, resources fetch results
type PolicyExecution ¶ added in v0.24.1
type PolicyExecution struct {
Id uuid.UUID `db:"id"`
Timestamp time.Time `db:"timestamp"`
Scheme string `db:"scheme"`
Location string `db:"location"`
PolicyName string `db:"policy_name"`
Selector string `db:"selector"`
Sha256Hash string `db:"sha256_hash"`
Version string `db:"version"`
ChecksTotal int `db:"checks_total"`
ChecksFailed int `db:"checks_failed"`
ChecksPassed int `db:"checks_passed"`
}
PolicyExecution represents a single policy execution and their summary
type Provider ¶ added in v0.24.0
type Provider struct {
Source string `db:"source"`
Name string `db:"name"`
Version string `db:"version"`
VMajor int `db:"v_major"`
VMinor int `db:"v_minor"`
VPatch int `db:"v_patch"`
VPre string `db:"v_pre"`
VMeta string `db:"v_meta"`
Tables tableList `db:"tables"`
Signatures stringMap `db:"signatures"`
ParsedVersion *version.Version `db:"-"`
}
Provider keeps track of installed providers
func ProviderFromRegistry ¶ added in v0.24.0
ProviderFromRegistry returns a Provider struct with info filled from a registry.Provider
type ResourceFetchSummaries ¶
type ResourceFetchSummaries []ResourceFetchSummary
type ResourceFetchSummary ¶
type ResourceFetchSummary struct {
ResourceName string `json:"resource_name"`
// map of resources that have finished fetching
FinishedResources map[string]bool `json:"finished_resources"`
// Error value if any, if returned the stream will be canceled
Error string `json:"error"`
// Execution status of resource
Status string `json:"status"`
// Total Amount of resources collected by this resource
ResourceCount uint64 `json:"resource_count"`
}
ResourceFetchSummary includes a data about fetching specific resource
type Tx ¶ added in v0.24.0
type Tx struct {
execution.TXQueryExecer
// contains filtered or unexported fields
}
func (*Tx) InstallProvider ¶ added in v0.24.0
InstallProvider saves state about given provider