agent

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: Apache-2.0 Imports: 22 Imported by: ? 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

Overview

Package agent is the headless host agent: a CLI that registers a workload with a central admin server and then runs on that host, applying the configuration the server handed back and restarting itself when that configuration changes on disk.

A product builds its own agent binary by wrapping the command with its branding:

func main() {
	if err := agent.Execute(agent.Options{Name: "acme-agent"}); err != nil {
		os.Exit(1)
	}
}

The `register` subcommand POSTs the host's FQDN and host ID to `{admin-server-url}/api/v1/agents/configuration` with a bearer token and writes the returned agent configuration (credentials, controller URL, PF configs) to the default agent config path for the chosen kind (`--as-service` selects the system-wide config directory). The `run` subcommand loads that file through host.AgentConfigFromFile, starts a host.Agent and watches the file, recreating the agent whenever it changes.

The `api` subcommand calls a service's HTTP API over NATS with the agent's own credentials (`agent api GET /api/v1/users`), and `services` lists the services answering in the agent's account. Both need only the controller URL and credentials that `register` stored; see natsapi for the protocol.

Index

Constants

View Source
const DefaultName = "bboxsys-agent"

DefaultName is the binary name used when Options.Name is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(opts Options) error

Execute builds the command and runs it against os.Args.

func NewCommand

func NewCommand(opts Options) *cobra.Command

NewCommand returns the root cobra command with the `register`, `run`, `api` and `services` subcommands attached. Callers that embed the agent in a larger CLI add the returned command to their own root.

Types

type Options

type Options struct {
	// Name is the binary name shown in help text and used as the logger's
	// application name. Defaults to DefaultName.
	Name string
	// Short and Long override the root command's help text. Both default to
	// generic descriptions that mention Name.
	Short string
	Long  string
}

Options brands the agent command for a product.

Jump to

Keyboard shortcuts

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