opamp

package
v1.44.0 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package opamp contains configurations and protocol implementations to handle OpAmp communication.

Package opamp contains configurations and protocol implementations to handle OpAmp communication.

Index

Constants

View Source
const (
	// YAMLContentType content type for .yml or .yaml file
	YAMLContentType = "text/yaml"

	// JSONContentType content type for .json file
	JSONContentType = "text/json"
)

Variables

This section is empty.

Functions

func ComputeHash

func ComputeHash(data []byte) []byte

ComputeHash computes a sha256 hash of the passed in data

func DetermineContentType

func DetermineContentType(filePath string) string

DetermineContentType looks at the file extension for the given filepath and returns the content type

func NoopReloadFunc

func NoopReloadFunc([]byte) (bool, error)

NoopReloadFunc used as a noop reload function if unsure of how to reload

func StringKeyValue

func StringKeyValue(key, value string) *protobufs.KeyValue

StringKeyValue converts a string key-value pair into a protobuf.KeyValue struct

func Version

func Version() string

Version returns the internally set OpAMP version

Types

type Client

type Client interface {

	// Connect initiates a connection to the OpAmp server based on the supplied configuration
	Connect(ctx context.Context) error

	// Disconnect disconnects from the server
	Disconnect(ctx context.Context) error
}

Client implements a connection with OpAmp enabled server

type Config

type Config struct {
	Endpoint  string     `yaml:"endpoint"`
	SecretKey *string    `yaml:"secret_key,omitempty"`
	AgentID   string     `yaml:"agent_id"`
	TLS       *TLSConfig `yaml:"tls_config,omitempty"`

	// Updatable fields
	Labels    *string `yaml:"labels,omitempty"`
	AgentName *string `yaml:"agent_name,omitempty"`
}

Config contains the configuration for the collector to communicate with an OpAmp enabled platform.

func ParseConfig

func ParseConfig(configLocation string) (*Config, error)

ParseConfig given a configuration file location will parse the config

func (Config) CmpUpdatableFields

func (c Config) CmpUpdatableFields(o Config) (equal bool)

CmpUpdatableFields compares updatable fields for equality

func (Config) Copy

func (c Config) Copy() *Config

Copy creates a deep copy of this config

func (Config) GetSecretKey

func (c Config) GetSecretKey() string

GetSecretKey returns secret key if set else returns empty string

func (Config) ToTLS

func (c Config) ToTLS() (*tls.Config, error)

ToTLS converts the config to a tls.Config

type ConfigManager

type ConfigManager interface {
	// AddConfig adds a config to be tracked by the config manager with it's corresponding validator function.
	AddConfig(configName string, reloader *ManagedConfig)

	// ComposeEffectiveConfig reads in all config files and calculates the effective config
	ComposeEffectiveConfig() (*protobufs.EffectiveConfig, error)

	// ApplyConfigChanges compares the remoteConfig to the existing and applies changes.
	// Calculates new effective config
	ApplyConfigChanges(remoteConfig *protobufs.AgentRemoteConfig) (changed bool, err error)
}

ConfigManager handles remote configuration of local configs

type DownloadableFileManager

type DownloadableFileManager interface {
	// FetchAndExtractArchive fetches the archive at the specified URL.
	// It then checks to see if it matches the expected sha256 sum of the file.
	// If it matches, the archive is extracted.
	// If the archive cannot be extracted, downloaded, or verified, then an error is returned.
	FetchAndExtractArchive(*protobufs.DownloadableFile) error
	// CleanupArtifacts removes temporary artifacts from previous download/installs
	CleanupArtifacts()
}

DownloadableFileManager handles DownloadableFile's from a PackagesAvailable message

type ManagedConfig

type ManagedConfig struct {
	// ConfigPath is the path on disk where the configuration lives
	ConfigPath string

	// Reload will be called when any changes to this config occur.
	Reload ReloadFunc
	// contains filtered or unexported fields
}

ManagedConfig is a structure that can manage an on disk config file

func NewManagedConfig

func NewManagedConfig(configPath string, reload ReloadFunc, required bool) (*ManagedConfig, error)

NewManagedConfig creates a new Managed config and computes its hash

func (*ManagedConfig) ComputeConfigHash

func (m *ManagedConfig) ComputeConfigHash() error

ComputeConfigHash reads in the config file, computes the hash for the contents, and saves it on the ManagedConfig.

func (*ManagedConfig) GetCurrentConfigHash

func (m *ManagedConfig) GetCurrentConfigHash() []byte

GetCurrentConfigHash retrieves the current config hash

type ReloadFunc

type ReloadFunc func([]byte) (changed bool, err error)

ReloadFunc is a function that handles reloading a config given the new contents Reload function should return true for changed is the in memory or on disk copy of the config was changed in any way. If neither was altered the changed return value should be false.

type TLSConfig

type TLSConfig struct {
	InsecureSkipVerify bool    `yaml:"insecure_skip_verify"`
	KeyFile            *string `yaml:"key_file"`
	CertFile           *string `yaml:"cert_file"`
	CAFile             *string `yaml:"ca_file"`
}

TLSConfig represents the TLS config to connect to OpAmp server

Directories

Path Synopsis
Package observiq contains OpAmp structures compatible with the observiq client
Package observiq contains OpAmp structures compatible with the observiq client

Jump to

Keyboard shortcuts

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