agent

package
v0.5.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Feb 17, 2025 License: Apache-2.0 Imports: 35 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	// DefaultSpecFetchInterval is the default interval between two reads of the remote device spec
	DefaultSpecFetchInterval = util.Duration(60 * time.Second)
	// DefaultStatusUpdateInterval is the default interval between two status updates
	DefaultStatusUpdateInterval = util.Duration(60 * time.Second)
	// MinSyncInterval is the minimum interval allowed for the spec fetch and status update
	MinSyncInterval = util.Duration(2 * time.Second)
	// DefaultConfigDir is the default directory where the device's configuration is stored
	DefaultConfigDir = "/etc/flightctl"
	// DefaultConfigFile is the default path to the agent's configuration file
	DefaultConfigFile = DefaultConfigDir + "/config.yaml"
	// DefaultDataDir is the default directory where the device's data is stored
	DefaultDataDir = "/var/lib/flightctl"
	// DefaultCertsDir is the default directory where the device's certificates are stored
	DefaultCertsDirName = "certs"
	// DefaultManagementEndpoint is the default address of the device management server
	DefaultManagementEndpoint = "https://localhost:7443"
	// name of the CA bundle file
	CacertFile = "ca.crt"
	// GeneratedCertFile is the name of the cert file which is generated as the result of enrollment
	GeneratedCertFile = "agent.crt"
	// name of the agent's key file
	KeyFile = "agent.key"
	// name of the enrollment certificate file
	EnrollmentCertFile = "client-enrollment.crt"
	// name of the enrollment key file
	EnrollmentKeyFile = "client-enrollment.key"
	// TestRootDirEnvKey is the environment variable key used to set the file system root when testing.
	TestRootDirEnvKey = "FLIGHTCTL_TEST_ROOT_DIR"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent struct {
	// contains filtered or unexported fields
}

func New

func New(log *log.PrefixLogger, config *Config) *Agent

New creates a new agent.

func (*Agent) GetLogPrefix

func (a *Agent) GetLogPrefix() string

func (*Agent) Run

func (a *Agent) Run(ctx context.Context) error

type Config

type Config struct {
	// ConfigDir is the directory where the device's configuration is stored
	ConfigDir string `json:"-"`
	// DataDir is the directory where the device's data is stored
	DataDir string `json:"-"`

	// EnrollmentService is the client configuration for connecting to the device enrollment server
	EnrollmentService EnrollmentService `json:"enrollment-service,omitempty"`
	// ManagementService is the client configuration for connecting to the device management server
	ManagementService ManagementService `json:"management-service,omitempty"`

	// SpecFetchInterval is the interval between two reads of the remote device spec
	SpecFetchInterval util.Duration `json:"spec-fetch-interval,omitempty"`
	// StatusUpdateInterval is the interval between two status updates
	StatusUpdateInterval util.Duration `json:"status-update-interval,omitempty"`

	// TPMPath is the path to the TPM device
	TPMPath string `json:"tpm-path,omitempty"`

	// LogLevel is the level of logging. can be:  "panic", "fatal", "error", "warn"/"warning",
	// "info", "debug" or "trace", any other will be treated as "info"
	LogLevel string `json:"log-level,omitempty"`
	// LogPrefix is the log prefix used for testing
	LogPrefix string `json:"log-prefix,omitempty"`

	// DefaultLabels are automatically applied to this device when the agent is enrolled in a service
	DefaultLabels map[string]string `json:"default-labels,omitempty"`
	// contains filtered or unexported fields
}

func NewDefault

func NewDefault() *Config

func (*Config) Complete

func (cfg *Config) Complete() error

Complete fills in defaults for fields not set by the config file

func (*Config) GetTestRootDir

func (cfg *Config) GetTestRootDir() string

func (*Config) ParseConfigFile

func (cfg *Config) ParseConfigFile(cfgFile string) error

ParseConfigFile reads the config file and unmarshals it into the Config struct

func (*Config) PathFor

func (cfg *Config) PathFor(filePath string) string

Some files are handled from the crypto modules that don't work with our device fileio and need to know the real paths TODO: potentially unify all file writer/readers under some mockable interface

func (*Config) SetEnrollmentMetricsCallback

func (cfg *Config) SetEnrollmentMetricsCallback(cb func(operation string, duractionSeconds float64, err error))

func (*Config) String

func (cfg *Config) String() string

func (*Config) Validate

func (cfg *Config) Validate() error

Validate checks that the required fields are set and ensures that the paths exist.

type EnrollmentService

type EnrollmentService struct {
	client.Config

	// EnrollmentUIEndpoint is the address of the device enrollment UI
	EnrollmentUIEndpoint string `json:"enrollment-ui-endpoint,omitempty"`
}

func (*EnrollmentService) Equal

type ManagementService

type ManagementService struct {
	client.Config
}

func (*ManagementService) Equal

Directories

Path Synopsis
Package client is a generated GoMock package.
Package client is a generated GoMock package.
applications
Package applications is a generated GoMock package.
Package applications is a generated GoMock package.
console
Package console is a generated GoMock package.
Package console is a generated GoMock package.
fileio
Package fileio is a generated GoMock package.
Package fileio is a generated GoMock package.
hook
Package hook is a generated GoMock package.
Package hook is a generated GoMock package.
lifecycle
Package lifecycle is a generated GoMock package.
Package lifecycle is a generated GoMock package.
os
Package os is a generated GoMock package.
Package os is a generated GoMock package.
policy
Package policy is a generated GoMock package.
Package policy is a generated GoMock package.
resource
Package resource is a generated GoMock package.
Package resource is a generated GoMock package.
spec
Package spec is a generated GoMock package.
Package spec is a generated GoMock package.
status
Package status is a generated GoMock package.
Package status is a generated GoMock package.
systemd
Package systemd is a generated GoMock package.
Package systemd is a generated GoMock package.

Jump to

Keyboard shortcuts

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