managedplugin

package
v1.13.1 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2023 License: MPL-2.0 Imports: 44 Imported by: 2

Documentation

Index

Constants

View Source
const (
	DefaultDownloadDir = ".cq"
	RetryAttempts      = 5
	RetryWaitTime      = 1 * time.Second
	APIBaseURL         = "https://api.cloudquery.io"
)

Variables

View Source
var (
	ErrLogLineToLong = errors.New("log line too long, discarding")
)

Functions

func DownloadPluginFromGithub

func DownloadPluginFromGithub(ctx context.Context, localPath string, org string, name string, version string, typ PluginType) error

func DownloadPluginFromHub added in v1.11.0

func DownloadPluginFromHub(ctx context.Context, authToken, localPath, team, name, version string, typ PluginType) error

func GenerateRandomUnixSocketName

func GenerateRandomUnixSocketName() string

func WithBinarySuffix

func WithBinarySuffix(filePath string) string

Types

type Client

type Client struct {
	LocalPath string

	Conn *grpc.ClientConn
	// contains filtered or unexported fields
}

func NewClient

func NewClient(ctx context.Context, typ PluginType, config Config, opts ...Option) (*Client, error)

NewClient creates a new plugin client. If registrySpec is GitHub then client downloads the plugin, spawns it and creates a gRPC connection. If registrySpec is Local then client spawns the plugin and creates a gRPC connection. If registrySpec is gRPC then clients creates a new connection If registrySpec is Docker then client downloads the docker image, runs it and creates a gRPC connection.

func (*Client) ConnectionString added in v1.6.0

func (c *Client) ConnectionString() string

func (*Client) MaxVersion

func (c *Client) MaxVersion(ctx context.Context) (int, error)

func (*Client) Metrics added in v1.2.0

func (c *Client) Metrics() Metrics

func (*Client) Name

func (c *Client) Name() string

func (*Client) Terminate

func (c *Client) Terminate() error

func (*Client) Versions

func (c *Client) Versions(ctx context.Context) ([]int, error)

type Clients

type Clients []*Client

func NewClients

func NewClients(ctx context.Context, typ PluginType, specs []Config, opts ...Option) (Clients, error)

typ will be deprecated soon but now required for a transition period

func (Clients) ClientByName

func (c Clients) ClientByName(name string) *Client

func (Clients) Terminate

func (c Clients) Terminate() error

type Config

type Config struct {
	Name     string
	Registry Registry
	Path     string
	Version  string
}

type LogReader

type LogReader struct {
	// contains filtered or unexported fields
}

logReader is a custom implementation similar to bufio.Scanner, but provides a way to handle lines (or tokens) that exceed the buffer size.

func NewLogReader

func NewLogReader(reader io.ReadCloser) *LogReader

newLogReader creates a new logReader to read log lines from an io.ReadCloser

func (*LogReader) NextLine

func (r *LogReader) NextLine() ([]byte, error)

NextLine reads and returns the next log line from the reader. An io.EOF error is returned if the end of the stream has been reached. This implementation is different from bufio.Scanner as it also returns an error if a line is too long to fit into the buffer. In this case, an error is returned together with a limited prefix of the line.

type Metrics added in v1.2.0

type Metrics struct {
	Errors   uint64
	Warnings uint64
}

type Option

type Option func(*Client)

func WithAuthToken added in v1.13.0

func WithAuthToken(authToken string) Option

func WithDirectory

func WithDirectory(directory string) Option

func WithLogger

func WithLogger(logger zerolog.Logger) Option

func WithNoExec added in v1.10.0

func WithNoExec() Option

func WithNoSentry

func WithNoSentry() Option

func WithOtelEndpoint added in v1.8.0

func WithOtelEndpoint(endpoint string) Option

func WithOtelEndpointInsecure added in v1.8.0

func WithOtelEndpointInsecure() Option

type PluginType

type PluginType int

PluginType specifies if a plugin is a source or a destination it actually doesn't really have any effect as plugins can serve both as source and as destinations but it is here for backward compatibility

const (
	PluginSource PluginType = iota
	PluginDestination
)

func (PluginType) String

func (p PluginType) String() string

type Registry

type Registry int
const (
	RegistryGithub Registry = iota
	RegistryLocal
	RegistryGrpc
	RegistryDocker
	RegistryCloudQuery
)

func RegistryFromString

func RegistryFromString(s string) (Registry, error)

func (Registry) MarshalJSON

func (r Registry) MarshalJSON() ([]byte, error)

func (Registry) String

func (r Registry) String() string

func (*Registry) UnmarshalJSON

func (r *Registry) UnmarshalJSON(data []byte) (err error)

Jump to

Keyboard shortcuts

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