Documentation
¶
Index ¶
- Constants
- Variables
- func CheckCoreUpdate(ctx context.Context, fs afero.Afero, nowUnix, period int64) (*version.Version, error)
- func Drop(ctx context.Context, sta *state.Client, pm *plugin.Manager, ...) diag.Diagnostics
- func GetProviderConfiguration(ctx context.Context, pm *plugin.Manager, opts *GetProviderConfigOptions) (*cqproto.GetProviderConfigResponse, diag.Diagnostics)
- func ManagedProviders(pm *plugin.Manager, provs []registry.Provider) []registry.Provider
- func ParseProviderSource(requestedProvider *config.RequiredProvider) (org string, provider string, err error)
- func Test(ctx context.Context, pm *plugin.Manager, opts TestOptions) (bool, error)
- type AvailableUpdate
- type CheckUpdatesOptions
- type DiagnosticsSummary
- type DownloadOptions
- type DownloadResult
- type FetchOptions
- type FetchResponse
- type FetchStatus
- type FetchUpdate
- type FetchUpdateCallback
- type GetProviderConfigOptions
- type GetProviderSchemaOptions
- type ProviderFetchSummary
- type ProviderInfo
- type ProviderSchema
- type PurgeProviderDataOptions
- type PurgeProviderDataResult
- type ResourceFetchSummary
- type SentryDiagnostic
- type SyncResult
- type SyncState
- type TestOptions
Constants ¶
const DevelopmentVersion = "development"
Variables ¶
var ( // Version variable is injected in build time Version = DevelopmentVersion )
Functions ¶
func CheckCoreUpdate ¶
func CheckCoreUpdate(ctx context.Context, fs afero.Afero, nowUnix, period int64) (*version.Version, error)
CheckCoreUpdate checks if an update to CloudQuery core is available and returns its (new) version. To avoid making those network requests on each CLI invocation it stores last time and version seen on GitHub in a so-called "last update check" file. If there is an error then returned version is nil. To be specific, error is returned if:
* core.Version is not a valid semantic version * if "last update check" file does not exist, and we fail to write to it * if "last update check" file has a single word "disable" in it * GitHub reports an error * last release version on GitHub is not a valid semantic version
Otherwise, new available version is returned that is obtained from either:
* "last update check" content and that version is newer than current * GitHub the latest release version, and it's newer than current
func GetProviderConfiguration ¶
func GetProviderConfiguration(ctx context.Context, pm *plugin.Manager, opts *GetProviderConfigOptions) (*cqproto.GetProviderConfigResponse, diag.Diagnostics)
func ManagedProviders ¶ added in v0.24.2
ManagedProviders returns list of providers which are not in reattach mode
func ParseProviderSource ¶
func ParseProviderSource(requestedProvider *config.RequiredProvider) (org string, provider string, err error)
Types ¶
type AvailableUpdate ¶
type AvailableUpdate struct {
// Name of provider that has an update available
Name string
// CurrentVersion is the version the provider is currently at
CurrentVersion string
// AvailableVersion is the version available for downloading
AvailableVersion string
}
AvailableUpdate notes a pending update available for provider from current version
func CheckAvailableUpdates ¶
func CheckAvailableUpdates(ctx context.Context, reg registry.Registry, opts *CheckUpdatesOptions) ([]AvailableUpdate, diag.Diagnostics)
CheckAvailableUpdates checks if any updates are available for providers, if a provider's version is set to latest, update will check vs "latest" available provider located in the local disk.
type CheckUpdatesOptions ¶
type DiagnosticsSummary ¶
type DiagnosticsSummary struct {
Total int `json:"total,omitempty"`
ByType map[string]int `json:"by_type,omitempty"`
BySeverity map[string]int `json:"by_severity,omitempty"`
}
func SummarizeDiagnostics ¶
func SummarizeDiagnostics(diags diag.Diagnostics) DiagnosticsSummary
type DownloadOptions ¶
type DownloadResult ¶
type DownloadResult struct {
// Downloaded is a list of downloaded providers
Downloaded []registry.ProviderBinary
}
DownloadResult output from Download command
func Download ¶
func Download(ctx context.Context, manager *plugin.Manager, opts *DownloadOptions) (*DownloadResult, diag.Diagnostics)
Download one or more providers from remote registry
type FetchOptions ¶
type FetchOptions struct {
// UpdateCallback allows gets called when the client receives updates on fetch.
UpdateCallback FetchUpdateCallback
// Providers list of providers to call for fetching
ProvidersInfo []ProviderInfo
// Optional: Adds extra fields to the provider
ExtraFields map[string]interface{}
// Optional: unique identifier for the fetch, if this isn't given, a random one is generated.
FetchId uuid.UUID
}
FetchOptions is provided to the Client to execute a fetch on one or more providers
type FetchResponse ¶
type FetchResponse struct {
FetchId uuid.UUID `json:"fetch_id,omitempty"`
ProviderFetchSummary map[string]*ProviderFetchSummary `json:"provider_fetch_summary,omitempty"`
TotalFetched uint64 `json:"total_fetched,omitempty"`
Duration time.Duration `json:"total_fetch_time,omitempty"`
}
FetchResponse is returned after a successful fetch execution, it holds a fetch summary for each provider that was executed.
func Fetch ¶
func Fetch(ctx context.Context, sta *state.Client, storage database.Storage, pm *plugin.Manager, opts *FetchOptions) (res *FetchResponse, diagnostics diag.Diagnostics)
func (FetchResponse) HasErrors ¶
func (fr FetchResponse) HasErrors() bool
type FetchStatus ¶
type FetchStatus int
const ( FetchFailed FetchStatus = iota + 1 FetchConfigureFailed FetchCanceled FetchFinished FetchPartial )
func (FetchStatus) String ¶
func (fs FetchStatus) String() string
type FetchUpdate ¶
type FetchUpdate struct {
Name string
Alias string
Version string
// Map of resources that have finished fetching
FinishedResources map[string]bool
// Amount of resources collected so far
ResourceCount uint64
// Error if any returned by the provider
Error string
// Diagnostic count
DiagnosticCount int
}
func (FetchUpdate) AllDone ¶
func (f FetchUpdate) AllDone() bool
func (FetchUpdate) DoneCount ¶
func (f FetchUpdate) DoneCount() int
type FetchUpdateCallback ¶
type FetchUpdateCallback func(update FetchUpdate)
type GetProviderConfigOptions ¶
type GetProviderConfigOptions struct {
Provider registry.Provider
Format cqproto.ConfigFormat
}
type ProviderFetchSummary ¶
type ProviderFetchSummary struct {
Name string `json:"name,omitempty"`
Alias string `json:"alias,omitempty"`
Version string `json:"version,omitempty"`
TotalResourcesFetched uint64 `json:"total_resources_fetched,omitempty"`
FetchedResources map[string]ResourceFetchSummary `json:"fetch_resources,omitempty"`
Status FetchStatus `json:"status,omitempty"`
Duration time.Duration `json:"duration,omitempty"`
}
ProviderFetchSummary represents a request for the FetchFinishCallback
func (ProviderFetchSummary) Diagnostics ¶
func (p ProviderFetchSummary) Diagnostics() diag.Diagnostics
func (ProviderFetchSummary) Properties ¶
func (p ProviderFetchSummary) Properties() map[string]interface{}
func (ProviderFetchSummary) Resources ¶
func (p ProviderFetchSummary) Resources() []string
func (ProviderFetchSummary) String ¶
func (p ProviderFetchSummary) String() string
type ProviderSchema ¶
type ProviderSchema struct {
*cqproto.GetProviderSchemaResponse
ProtocolVersion int
Unmanaged bool
}
func GetProviderSchema ¶
func GetProviderSchema(ctx context.Context, manager *plugin.Manager, request *GetProviderSchemaOptions) (*ProviderSchema, diag.Diagnostics)
type PurgeProviderDataOptions ¶
type PurgeProviderDataOptions struct {
// Providers to purge data from, the provider name should be the plugin name
Providers []registry.Provider
// LastUpdate defines how long from time.Now() should the resources be removed from the database.
LastUpdate time.Duration
// DryRun whether to run the purge in "dry" mode and only report the amount of affected resources that will be purged, if executed.
DryRun bool
}
type PurgeProviderDataResult ¶
type PurgeProviderDataResult struct {
// Total amount of affected resources, this value is only returned when dry run is set to true
TotalAffected int
// AffectedResources is all tables that have one or more resources affected
AffectedResources map[string]int
}
func PurgeProviderData ¶
func PurgeProviderData(ctx context.Context, storage database.Storage, manager *plugin.Manager, opts *PurgeProviderDataOptions) (*PurgeProviderDataResult, diag.Diagnostics)
PurgeProviderData purges resources that were not updated recently, if dry run is set to true, no resources will be removed.
func (PurgeProviderDataResult) Resources ¶
func (p PurgeProviderDataResult) Resources() []string
type ResourceFetchSummary ¶
type ResourceFetchSummary struct {
// Execution status of resource
Status string `json:"status,omitempty"`
// Total Amount of resources collected by this resource
ResourceCount uint64 `json:"resource_count,omitempty"`
// Diagnostics of failed resource fetch, the diagnostic provides insights such as severity, summary and
// details on how to solve this issue
Diagnostics diag.Diagnostics `json:"-"`
// Duration in seconds
Duration time.Duration `json:"duration,omitempty"`
}
type SentryDiagnostic ¶ added in v0.24.0
type SentryDiagnostic struct {
diag.Diagnostic
Tags map[string]string
Ignore bool
}
func (*SentryDiagnostic) IsSentryDiagnostic ¶ added in v0.24.0
func (d *SentryDiagnostic) IsSentryDiagnostic() (bool, map[string]string, bool)
func (*SentryDiagnostic) Redacted ¶ added in v0.25.0
func (d *SentryDiagnostic) Redacted() diag.Diagnostic
type SyncResult ¶
type TestOptions ¶
type TestOptions struct {
Connection cqproto.ConnectionDetails
Config []byte
CreationInfo *plugin.CreationOptions
}