managedplugin

package
v1.19.9 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MPL-2.0 Imports: 47 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultDownloadDir = ".cq"
	RetryAttempts      = 5
	RetryWaitTime      = 1 * time.Second
)
View Source
const (
	DefaultCloudQueryDockerHost = "docker.cloudquery.io"
)

Variables

View Source
var (
	ErrLoginRequired = fmt.Errorf("login required")
	ErrTeamRequired  = fmt.Errorf("team required")
)
View Source
var (
	ErrLogLineToLong = errors.New("log line too long, discarding")
)

Functions

func APIBaseURL added in v1.11.0

func APIBaseURL() string

func DownloadPluginFromGithub

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

func DownloadPluginFromHub added in v1.11.0

func DownloadPluginFromHub(ctx context.Context, c *cloudquery_api.ClientWithResponses, ops HubDownloadOptions) 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
	Environment []string // environment variables to pass to the plugin in key=value format
	DockerAuth  string
}

type HubDownloadOptions added in v1.14.0

type HubDownloadOptions struct {
	AuthToken     string
	TeamName      string
	LocalPath     string
	PluginTeam    string
	PluginKind    string
	PluginName    string
	PluginVersion 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 WithCloudQueryDockerHost added in v1.17.0

func WithCloudQueryDockerHost(dockerHost string) Option

func WithDirectory

func WithDirectory(directory string) Option

func WithLicenseFile added in v1.15.0

func WithLicenseFile(licenseFile 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

func WithTeamName added in v1.14.0

func WithTeamName(teamName string) 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