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 ¶
const DefaultName = "bboxsys-agent"
DefaultName is the binary name used when Options.Name is empty.
Variables ¶
This section is empty.
Functions ¶
func NewCommand ¶
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.