client

package
v0.13.4 Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: MPL-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// Optional: Logger framework can use to log.
	// default: global logger provided.
	Logger hclog.Logger

	// Optional: Hub client to use to download plugins, the Hub is used to download and pluginManager providers binaries
	// if not specified, default cloudquery registry is used.
	Hub registry.Registry

	// manager manages all plugins lifecycle
	Manager *plugin.Manager
	// contains filtered or unexported fields
}

Client is the client for executing providers, fetching data and running queries and polices

func New

func New(config *config.Config, options ...Option) (*Client, error)

func (Client) Close

func (c Client) Close()

func (Client) ExecutePolicy

func (c Client) ExecutePolicy(ctx context.Context, request ExecutePolicyRequest) (*PolicyExecutionResult, error)

func (*Client) Fetch

func (c *Client) Fetch(ctx context.Context, request FetchRequest) error

func (Client) GetProviderConfiguration

func (c Client) GetProviderConfiguration(ctx context.Context, providerName string) (*cqproto.GetProviderConfigResponse, error)

func (Client) GetProviderSchema

func (c Client) GetProviderSchema(ctx context.Context, providerName string) (*cqproto.GetProviderSchemaResponse, error)

func (*Client) Initialize

func (c *Client) Initialize(ctx context.Context) error

Initialize downloads all provider binaries

type ExecutePolicyRequest

type ExecutePolicyRequest struct {
	// Path to the policy, currently we still use the old .yml format, future versions will change to HCL
	PolicyPath string
	// UpdateCallback allows gets called when the client receives updates on policy execution.
	UpdateCallback PolicyExecutionCallback
	// if True policy execution will stop on first failure
	StopOnFailure bool
	// Path to save policy result
	OutputPath string
}

type FetchDoneResult

type FetchDoneResult struct {
	// Map of providers and resources that have finished fetching
	DoneResources map[string]map[string]bool
	// Amount of resources collected so far
	ResourceCount string
}

type FetchRequest

type FetchRequest struct {
	// UpdateCallback allows gets called when the client receives updates on fetch.
	UpdateCallback FetchUpdateCallback
	// Providers list of providers to call for fetching
	Providers []*config.Provider
}

FetchRequest is provided to the Client to execute a fetch on one or more providers

type FetchUpdate

type FetchUpdate struct {
	Provider 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
}

func (FetchUpdate) AllDone

func (f FetchUpdate) AllDone() bool

func (FetchUpdate) DoneCount

func (f FetchUpdate) DoneCount() int

type FetchUpdateCallback

type FetchUpdateCallback func(update FetchUpdate)

type Option

type Option func(options *Client)

type PolicyExecutionCallback

type PolicyExecutionCallback func(name string, passed bool, resultCount int)

type PolicyExecutionResult

type PolicyExecutionResult struct {
	// True if all policies have passed
	Passed bool
	// Map of all query result sets
	Results map[string]*PolicyResult
}

type PolicyResult

type PolicyResult struct {
	Name    string          `json:"name"`
	Columns []string        `json:"result_headers"`
	Data    [][]interface{} `json:"result_rows"`
	Passed  bool            `json:"check_passed"`
}

Jump to

Keyboard shortcuts

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