Documentation
¶
Overview ¶
Vendored from bot-agent internal/agent/config (Apache-2.0, see ../NOTICE). DD changes: the temp file prefix. WriteFileAtomic exports it for the worker's other 0600 files.
Package config loads and rewrites the dd-worker credential env file.
Vendored from bot-agent internal/agent/config (Apache-2.0, see ../NOTICE). DD changes: the keys are DD_WORKER_* and the paths /etc/dd-worker (host owner's config, never written by the worker) and /var/lib/dd-worker (state, with the credential in credential/, a 0700 dir); the server is an https origin (http only on loopback with the insecure-dev flag) from which the worker derives the socket URL; ids are worker protocol ids, not UUIDs; there is no process-environment overlay (the credential is read from the file only); the join token is not stored, because enrolment dials at once; ParseEnv is exported for secrets.env. The env-file parser and writer, the atomic write, the join-token reader and SanitizeHostname are kept.
Index ¶
- Constants
- func JoinTokenOK(v string) bool
- func ParseEnv(body []byte) (map[string]string, error)
- func ReadJoinToken(r io.Reader) (string, error)
- func SanitizeHostname(s string) (string, error)
- func ValidateServerURL(raw string, insecureDev bool) error
- func Write(path string, c Config) error
- func WriteFileAtomic(path string, data []byte, mode, dirMode os.FileMode) error
- type Config
Constants ¶
const ( DefaultConfigDir = "/etc/dd-worker" DefaultStateDir = "/var/lib/dd-worker" )
Variables ¶
This section is empty.
Functions ¶
func JoinTokenOK ¶
JoinTokenOK reports whether v looks like a dd_wjn_ join token.
func ParseEnv ¶
ParseEnv parses an env file body (KEY=value lines, # comments, optional "export ", double-quoted values). DD: exported for secrets.env.
func ReadJoinToken ¶
ReadJoinToken reads one trimmed line from r (stdin, never argv).
func SanitizeHostname ¶
SanitizeHostname lowercases and replaces characters outside [a-z0-9-] so the enroll frame matches the contract. The result is 1–63 characters.
func ValidateServerURL ¶
ValidateServerURL accepts an https origin, and http only on loopback with insecureDev (protocol v1 §1: the Mac dev loop with AUTH=none). No path, query, fragment or userinfo.
Types ¶
type Config ¶
type Config struct {
Path string
ServerURL string
WorkerID string
OrgID string
Credential string
InsecureDev bool
}
Config is one credential env file (env or env.prev).