agent

package
v0.0.0-...-890248b Latest Latest
Warning

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

Go to latest
Published: May 21, 2026 License: AGPL-3.0 Imports: 17 Imported by: 0

Documentation

Overview

Package agent provides the usulnet agent that runs on remote Docker hosts. It connects to the central gateway via NATS, receives commands, and reports events and inventory.

Package agent provides the executor wrapper for the usulnet agent.

Index

Constants

This section is empty.

Variables

View Source
var Version = "dev"

Version is the agent version (set at build time).

Functions

This section is empty.

Types

type Agent

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

Agent is the usulnet agent that runs on Docker hosts.

func New

func New(cfg Config, log *logger.Logger) (*Agent, error)

New creates a new agent.

func (*Agent) ID

func (a *Agent) ID() string

ID returns the agent ID.

func (*Agent) Run

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

Run starts the agent and blocks until context is canceled.

func (*Agent) Stop

func (a *Agent) Stop()

Stop stops the agent gracefully.

type Config

type Config struct {
	// AgentID is the unique identifier for this agent (generated if empty)
	AgentID string `yaml:"agent_id"`
	// Token is the authentication token for the gateway
	Token string `yaml:"token"`
	// GatewayURL is the NATS server URL
	GatewayURL string `yaml:"gateway_url"`
	// DockerHost is the Docker daemon address (default: unix:// + configured socket path)
	DockerHost string `yaml:"docker_host"`
	// Hostname is the agent's hostname (auto-detected if empty)
	Hostname string `yaml:"hostname"`
	// Labels are custom labels for this agent
	Labels map[string]string `yaml:"labels"`
	// LogLevel is the logging level
	LogLevel string `yaml:"log_level"`
	// DataDir is the directory for local state storage
	DataDir string `yaml:"data_dir"`
	// BackupEnabled enables backup capabilities on this agent.
	// Not exposed in the YAML schema; flipped by the gateway at runtime.
	BackupEnabled bool `yaml:"-"`
	// ScannerEnabled enables security scanning capabilities on this agent.
	// Not exposed in the YAML schema; flipped by the gateway at runtime.
	ScannerEnabled bool `yaml:"-"`
	// TLS holds the NATS TLS settings (nested under tls: in YAML).
	TLS TLSConfig `yaml:"tls"`
}

Config holds the agent configuration.

YAML tags make this struct directly unmarshalable from the agent's config file (cmd/usulnet-agent). Operator-facing keys (gateway_url, docker_host, log_level, …) are snake_case; the TLS sub-block is nested under tls: in YAML.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns default agent configuration.

type Executor

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

Executor wraps the command executor for the agent.

func NewExecutor

func NewExecutor(dockerClient *docker.Client, log *logger.Logger) *Executor

NewExecutor creates a new executor wrapper.

func (*Executor) Execute

Execute executes a command and returns the result.

type TLSConfig

type TLSConfig struct {
	Enabled  bool   `yaml:"enabled"`
	CertFile string `yaml:"cert_file"`
	KeyFile  string `yaml:"key_file"`
	CAFile   string `yaml:"ca_file"`
}

TLSConfig is the agent's NATS TLS sub-config. Lives at cfg.TLS in memory and `tls:` in the YAML file.

Directories

Path Synopsis
Package connection provides NATS connection management for the usulnet agent.
Package connection provides NATS connection management for the usulnet agent.
Package executor provides command execution for the usulnet agent.
Package executor provides command execution for the usulnet agent.
Package inventory provides Docker resource inventory collection for the agent.
Package inventory provides Docker resource inventory collection for the agent.

Jump to

Keyboard shortcuts

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