agent

package
v1.35.0 Latest Latest
Warning

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

Go to latest
Published: Oct 4, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package agent provides a client for fetching information about agent versions from Github.

Index

Constants

View Source
const (

	// MinSyncAgentVersionsInterval is the minimum value for the SyncAgentVersionsInterval setting, currently 1 hour. 0
	// can also be specified to disable background periodic syncing.
	MinSyncAgentVersionsInterval = 1 * time.Hour
)

The latest version cache keeps the latest version in memory to avoid hitting the store to get the latest version.

View Source
const (
	// VersionLatest can be used in requests instead of an actual version
	VersionLatest = "latest"
)

Variables

View Source
var (
	// ErrVersionNotFound is returned when the agent versions service returns a 404 for a version
	ErrVersionNotFound = errors.New("agent version not found")
)
View Source
var PlatformArtifacts = map[string]PlatformArtifactNames{
	"darwin/amd64": {
		DownloadPackageFormat: "observiq-otel-collector-%s-darwin-amd64.tar.gz",
		InstallerName:         "install_macos.sh",
	},
	"darwin/arm64": {
		DownloadPackageFormat: "observiq-otel-collector-%s-darwin-arm64.tar.gz",
		InstallerName:         "install_macos.sh",
	},
	"linux/amd64": {
		DownloadPackageFormat: "observiq-otel-collector-%s-linux-amd64.tar.gz",
		InstallerName:         "install_unix.sh",
	},
	"linux/arm64": {
		DownloadPackageFormat: "observiq-otel-collector-%s-linux-arm64.tar.gz",
		InstallerName:         "install_unix.sh",
	},
	"linux/arm": {
		DownloadPackageFormat: "observiq-otel-collector-%s-linux-arm.tar.gz",
		InstallerName:         "install_unix.sh",
	},
	"windows/amd64": {
		DownloadPackageFormat: "observiq-otel-collector-%s-windows-amd64.zip",
		InstallerName:         "observiq-otel-collector.msi",
	},
	"windows/386": {
		DownloadPackageFormat: "observiq-otel-collector-%s-windows-386.zip",
		InstallerName:         "observiq-otel-collector-x86.msi",
	},
}

PlatformArtifacts is a map of platform to the download package format and installer name.

Functions

This section is empty.

Types

type PlatformArtifactNames added in v1.25.0

type PlatformArtifactNames struct {
	// DownloadPackageFormat is the format string for the name of the downloadable upgrade package.
	// It must be formatted for use with Sprintf(format, version)
	DownloadPackageFormat string
	// InstallerName is the name of the installer for this platform
	InstallerName string
}

PlatformArtifactNames contains the names for a set of artifacts for a platform.

func (PlatformArtifactNames) DownloadPackageName added in v1.25.0

func (p PlatformArtifactNames) DownloadPackageName(version string) string

DownloadPackageName formats DownloadPackageFormat with the version, giving the name of the downloadable upgrade package.

type Sha256sums

type Sha256sums map[string]string

Sha256sums is a map of file name to sha256sum

func ParseSha256Sums

func ParseSha256Sums(contents []byte) Sha256sums

ParseSha256Sums is an incomplete parser of a .sha256 or -SHA256SUMS file. Technically there are separate text and binary modes, but we only use the text mode. See https://www.gnu.org/software/coreutils/manual/html_node/md5sum-invocation.html for more details on the file format

func (Sha256sums) Sha256Sum

func (s Sha256sums) Sha256Sum(file string) string

Sha256Sum returns the sha256sum for a given file

type VersionClient

type VersionClient interface {
	// Version returns the agent version for the given version string
	Version(version string) (*model.AgentVersion, error)
	// Versions returns all available agent versions
	Versions() ([]*model.AgentVersion, error)
	// LatestVersion returns the latest agent version
	LatestVersion() (*model.AgentVersion, error)
}

VersionClient is an interface for retrieving available agent versions

func NewGitHubVersionClient

func NewGitHubVersionClient() VersionClient

NewGitHubVersionClient creates a new VersionClient for github versions

func NewNoopClient added in v1.25.0

func NewNoopClient() VersionClient

NewNoopClient creates a new client that does not connect to other services

type Versions

type Versions interface {
	// LatestVersionString returns the semver version string of the latest agent version
	LatestVersionString(ctx context.Context) string
	// LatestVersion returns the latest agent version
	LatestVersion(ctx context.Context) (*model.AgentVersion, error)
	// Version returns the agent version for the given semver
	Version(ctx context.Context, version string) (*model.AgentVersion, error)
	// SyncVersion fetches the up-to-date AgentVersion resource, suitable for syncing.
	SyncVersion(version string) (*model.AgentVersion, error)
	// SyncVersions fetches the up-to-date list of AgentVersion resources, suitable for syncing.
	SyncVersions() ([]*model.AgentVersion, error)
}

Versions manages versions of agents that are used during install and upgrade. The versions are stored in the Store as agent-version resources, but Versions provides quick access to the latest version.

func NewVersions

func NewVersions(ctx context.Context, client VersionClient, storeInterface store.Store, settings VersionsSettings) Versions

NewVersions creates an implementation of Versions using the specified client, cache, and settings. To disable caching, pass nil for the Cache.

type VersionsSettings

type VersionsSettings struct {
	Logger *zap.Logger

	// SyncAgentVersionsInterval is the interval at which SyncVersions() will be called to ensure the agent-versions are
	// in sync with GitHub and new releases are available.
	SyncAgentVersionsInterval time.Duration
}

VersionsSettings is configuration for a Versions implementation

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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