agent

package
v0.0.0-...-2b06d51 Latest Latest
Warning

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

Go to latest
Published: Apr 17, 2024 License: Apache-2.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultSpecFetchInterval is the default interval between two reads of the remote device spec
	DefaultSpecFetchInterval = time.Second * 60
	// DefaultStatusUpdateInterval is the default interval between two status updates
	DefaultStatusUpdateInterval = time.Second * 60
	// 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:3333"
	// 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"
)

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 *logrus.Logger, 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 {
	// Key is the path to the agent's private key
	Key string `yaml:"key"`
	// Cacert is the path to the CA certificate
	Cacert string `yaml:"ca-cert"`
	// GenerateCert is the path to the cert file which is generated as the result of enrollment
	GeneratedCert string `yaml:"generated-cert"`
	// DataDir is the directory where the device's data is stored
	DataDir string `yaml:"data-dir"`
	// ConfigDir is the directory where the device's configuration is stored
	ConfigDir string `yaml:"config-dir"`
	// EnrollmentCertFile is the path to the enrollment certificate
	EnrollmentCertFile string `yaml:"enrollment-cert-file"`
	// EnrollmentKeyFile is the path to the enrollment key
	EnrollmentKeyFile string `yaml:"enrollment-key-file"`
	// ManagementEndpoint is the address of the device management server
	ManagementEndpoint string `yaml:"management-endpoint,omitempty"`
	// EnrollmentEndpoint is the address of the device enrollment server
	EnrollmentEndpoint string `yaml:"enrollment-endpoint,omitempty"`
	// EnrollmentUIEndpoint is the address of the device enrollment UI
	EnrollmentUIEndpoint string `yaml:"enrollment-ui-endpoint,omitempty"`
	// TPMPath is the path to the TPM device
	TPMPath string `yaml:"tpm-path,omitempty"`
	// SpecFetchInterval is the interval between two reads of the remote device spec
	SpecFetchInterval time.Duration `yaml:"spec-fetch-interval,omitempty"`
	// StatusUpdateInterval is the interval between two status updates
	StatusUpdateInterval time.Duration `yaml:"status-update-interval,omitempty"`
	// LogPrefix is the log prefix used for testing
	LogPrefix string `yaml:"log-prefix,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 `yaml:"log-level,omitempty"`
	// contains filtered or unexported fields
}

func NewDefault

func NewDefault() *Config

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) SetTestRootDir

func (cfg *Config) SetTestRootDir(rootDir string)

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 that the paths exist.

Directories

Path Synopsis
status
Package status is a generated GoMock package.
Package status is a generated GoMock package.

Jump to

Keyboard shortcuts

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