config

package
v0.2.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0, Apache-2.0 Imports: 11 Imported by: 0 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

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

View Source
const (
	DefaultConfigDir = "/etc/dd-worker"
	DefaultStateDir  = "/var/lib/dd-worker"
)

Variables

This section is empty.

Functions

func JoinTokenOK

func JoinTokenOK(v string) bool

JoinTokenOK reports whether v looks like a dd_wjn_ join token.

func ParseEnv

func ParseEnv(body []byte) (map[string]string, error)

ParseEnv parses an env file body (KEY=value lines, # comments, optional "export ", double-quoted values). DD: exported for secrets.env.

func ReadJoinToken

func ReadJoinToken(r io.Reader) (string, error)

ReadJoinToken reads one trimmed line from r (stdin, never argv).

func SanitizeHostname

func SanitizeHostname(s string) (string, error)

SanitizeHostname lowercases and replaces characters outside [a-z0-9-] so the enroll frame matches the contract. The result is 1–63 characters.

func ValidateServerURL

func ValidateServerURL(raw string, insecureDev bool) error

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.

func Write

func Write(path string, c Config) error

Write stores c at path atomically, mode 0600.

func WriteFileAtomic

func WriteFileAtomic(path string, data []byte, mode, dirMode os.FileMode) error

WriteFileAtomic is atomicWrite for the worker's other private files.

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).

func Load

func Load(path string) (Config, error)

Load reads path, requires a regular file with mode 0600, and checks the values. Error strings never contain the credential.

func (Config) Validate

func (c Config) Validate() error

Validate checks the server origin, ids and credential shape.

Jump to

Keyboard shortcuts

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