core

package
v0.32.12 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2022 License: MPL-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const DevelopmentVersion = "development"
View Source
const (

	// UpdateCheckPeriod specifies how much time in seconds must pass between
	// subsequent checks for CloudQuery core update availability.
	UpdateCheckPeriod = int64(23 * time.Hour / time.Second)
)

Variables

View Source
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 Drop

func Drop(ctx context.Context, sta *state.Client, pm *plugin.Manager, provider registry.Provider) diag.Diagnostics

func ManagedProviders

func ManagedProviders(pm *plugin.Manager, provs []registry.Provider) []registry.Provider

ManagedProviders returns list of providers which are not in reattach mode

func ParseProviderSource

func ParseProviderSource(requestedProvider *config.RequiredProvider) (org string, provider string, err error)

func Test

func Test(ctx context.Context, pm *plugin.Manager, opts TestOptions) (bool, error)

Test checks if a provider's configure will work, this method is usually used to check that the credentials / provider configuration is correct works.

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 CheckUpdatesOptions struct {
	Providers []registry.Provider
}

type DownloadOptions

type DownloadOptions struct {
	// Providers to purge data from, the provider name should be the plugin name
	Providers []registry.Provider
	// Whether download should verify plugins after they are downloaded
	NoVerify bool
}

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"`
	TelemetryEvents      []analytics.TelemetryEvent       `json:"-"`
}

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
}

type GetProviderSchemaOptions

type GetProviderSchemaOptions struct {
	Provider registry.Provider
}

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 ProviderInfo

type ProviderInfo struct {
	Provider registry.Provider
	Config   *config.Provider
}

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

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:"-"`
	// TelemetryEvents is a list of telemetry events that occurred during the fetch
	TelemetryEvents []analytics.TelemetryEvent `json:"-"`
	// Duration in seconds
	Duration time.Duration `json:"duration,omitempty"`
}

type SentryDiagnostic

type SentryDiagnostic struct {
	diag.Diagnostic

	Tags   map[string]string
	Ignore bool
}

func (*SentryDiagnostic) IsSentryDiagnostic

func (d *SentryDiagnostic) IsSentryDiagnostic() (bool, map[string]string, bool)

func (*SentryDiagnostic) Redacted

func (d *SentryDiagnostic) Redacted() diag.Diagnostic

type SyncResult

type SyncResult struct {
	State      SyncState
	OldVersion string
	NewVersion string
}

func Sync

type SyncState

type SyncState int
const (
	Installed SyncState = iota + 1
	Upgraded
	Downgraded
	NoChange
)

func (SyncState) String

func (s SyncState) String() string

type TestOptions

type TestOptions struct {
	Connection   cqproto.ConnectionDetails
	Config       []byte
	CreationInfo *plugin.CreationOptions
}

Directories

Path Synopsis
Package state interacts with core database schema and stores cloudquery metadata such as fetch summaries
Package state interacts with core database schema and stores cloudquery metadata such as fetch summaries

Jump to

Keyboard shortcuts

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