agentconf

package
v0.0.0-...-dd75922 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2024 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ReadAgentConfig

func ReadAgentConfig(c AgentConfigWriter, agentId string) error

ReadAgentConfig is a helper to read either machine or controller agent config, whichever is there. Machine config gets precedence.

func SetupAgentLogging

func SetupAgentLogging(context *loggo.Context, config agent.Config)

Types

type AgentConf

type AgentConf interface {

	// AddFlags injects common agent flags into f.
	AddFlags(f *gnuflag.FlagSet)

	// CheckArgs reports whether the given args are valid for this agent.
	CheckArgs(args []string) error

	// DataDir returns the directory where this agent should store its data.
	DataDir() string

	// ReadConfig reads the agent's config from its config file.
	ReadConfig(tag string) error

	// CurrentConfig returns the agent config for this agent.
	CurrentConfig() agent.Config

	// ChangeConfig modifies this configuration using the given mutator.
	ChangeConfig(change agent.ConfigMutator) error
}

AgentConf is a terribly confused interface.

Parts of it are a mixin for cmd.Command implementations; others are a mixin for agent.Agent implementations; others bridge the two. We should be aiming to separate the cmd responsibilities from the agent responsibilities.

func NewAgentConf

func NewAgentConf(dataDir string) AgentConf

NewAgentConf returns a new value that satisfies AgentConf

type AgentConfigWriter

type AgentConfigWriter interface {
	// ReadConfig reads the config for the given tag from disk.
	ReadConfig(tag string) error
	// ChangeConfig executes the given agent.ConfigMutator in a
	// thread-safe context.
	ChangeConfig(agent.ConfigMutator) error
	// CurrentConfig returns a copy of the in-memory agent config.
	CurrentConfig() agent.Config
}

AgentConfigWriter encapsulates disk I/O operations with the agent config.

Jump to

Keyboard shortcuts

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