agent

package
v1.17.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2023 License: Apache-2.0 Imports: 12 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]struct {
	// format for use with Sprintf(format, version)
	DownloadPackageFormat string
	// name of the installer for this platform
	InstallerName string
}{
	"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

func IsGitHubAgentVersion

func IsGitHubAgentVersion(v *model.AgentVersion) (bool, error)

IsGitHubAgentVersion determines if the agent version points to github or not

Types

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, as determined by Github
	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

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(version string) (*model.AgentVersion, error)
	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, store 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

	// Offline is true if the server is in offline mode and should not contact GitHub automatically. Sync methods called
	// by 'bindplanectl sync' commands will still attempt to contact GitHub.
	Offline bool
}

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