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
- Variables
- func ComputeHash(data []byte) []byte
- func DetermineContentType(filePath string) string
- func NoopReloadFunc([]byte) (bool, error)
- func StringKeyValue(key, value string) *protobufs.KeyValue
- func Version() string
- type AgentID
- func (a *AgentID) MarshalText() ([]byte, error)
- func (a AgentID) MarshalYAML() (any, error)
- func (a AgentID) OpAMPInstanceUID() types.InstanceUid
- func (a AgentID) String() string
- func (a AgentID) Type() string
- func (a *AgentID) UnmarshalText(text []byte) error
- func (a *AgentID) UnmarshalYAML(unmarshal func(any) error) error
- type Client
- type Config
- type ConfigManager
- type DownloadableFileManager
- type ManagedConfig
- type ReloadFunc
- type TLSConfig
Constants ¶
const ( // YAMLContentType content type for .yml or .yaml file YAMLContentType = "text/yaml" // JSONContentType content type for .json file JSONContentType = "text/json" )
Variables ¶
var EmptyAgentID = AgentID{}
EmptyAgentID represents an empty/unset agent ID.
Functions ¶
func ComputeHash ¶
ComputeHash computes a sha256 hash of the passed in data
func DetermineContentType ¶
DetermineContentType looks at the file extension for the given filepath and returns the content type
func NoopReloadFunc ¶
NoopReloadFunc used as a noop reload function if unsure of how to reload
func StringKeyValue ¶
StringKeyValue converts a string key-value pair into a protobuf.KeyValue struct
Types ¶
type AgentID ¶ added in v1.63.0
type AgentID struct {
// contains filtered or unexported fields
}
AgentID represents the ID of the agent
func AgentIDFromUUID ¶ added in v1.63.0
AgentIDFromUUID creates an agent ID from a generated UUID. See ParseAgentID for parsing a UUID string.
func ParseAgentID ¶ added in v1.63.0
ParseAgentID parses an agent ID from the given string
func (*AgentID) MarshalText ¶ added in v1.64.0
MarshalText implements the encoding.TextMarshaler interface
func (AgentID) MarshalYAML ¶ added in v1.63.0
MarshalYAML implements the yaml.Marshaler interface
func (AgentID) OpAMPInstanceUID ¶ added in v1.63.0
func (a AgentID) OpAMPInstanceUID() types.InstanceUid
OpAMPInstanceUID returns the opamp representation of the agent ID
func (AgentID) Type ¶ added in v1.63.0
Type returns the string type of the agent ID (ULID, UUID) as it should be reported to BindPlane.
func (*AgentID) UnmarshalText ¶ added in v1.64.0
UnmarshalText implements the encoding.TextUnmarshaler interface
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" mapstructure:"endpoint"` SecretKey *string `yaml:"secret_key,omitempty" mapstructure:"secret_key,omitempty"` AgentID AgentID `yaml:"agent_id" mapstructure:"agent_id"` TLS *TLSConfig `yaml:"tls_config,omitempty" mapstructure:"tls_config,omitempty"` // Updatable fields Labels *string `yaml:"labels,omitempty" mapstructure:"labels,omitempty"` AgentName *string `yaml:"agent_name,omitempty" mapstructure:"agent_name,omitempty"` MeasurementsInterval time.Duration `yaml:"measurements_interval,omitempty" mapstructure:"measurements_interval,omitempty"` ExtraMeasurementsAttributes map[string]string `yaml:"extra_measurements_attributes,omitempty" mapstructure:"extra_measurements_attributes,omitempty"` }
Config contains the configuration for the collector to communicate with an OpAmp enabled platform.
func ParseConfig ¶
ParseConfig given a configuration file location will parse the config
func (Config) CmpUpdatableFields ¶
CmpUpdatableFields compares updatable fields for equality
func (Config) GetSecretKey ¶
GetSecretKey returns secret key if set else returns empty string
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 ¶
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" mapstructure:"insecure_skip_verify"` KeyFile *string `yaml:"key_file" mapstructure:"key_file"` CertFile *string `yaml:"cert_file" mapstructure:"cert_file"` CAFile *string `yaml:"ca_file" mapstructure:"ca_file"` }
TLSConfig represents the TLS config to connect to OpAmp server