Documentation
¶
Overview ¶
Package configinit implements "config init" for sqi-server and sqi-worker: it renders a starter configuration file and writes it with the owner, mode or ACL the platform needs. Rendering (Render, DefaultTarget, DataDir, SessionDir) is pure: it builds text and paths for the platform it is given and touches no file.
Index ¶
- func DataDir(b Binary, p Platform, target string) string
- func DefaultTarget(b Binary, p Platform) string
- func NewCommand(spec Spec) *cobra.Command
- func Render(b Binary, p Platform, v Values) ([]byte, error)
- func SessionDir(b Binary, p Platform, target, account string) string
- func ValidateNATSURL(raw string) error
- type Binary
- type Platform
- type Spec
- type Values
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DataDir ¶
DataDir returns the data directory the starter configuration names for b. On Windows it sits beside the target file, so the default location and a per-user one share one rule.
func DefaultTarget ¶
DefaultTarget returns the path "config init" writes b's configuration to when no path is given.
func NewCommand ¶
NewCommand returns the "init" command, which writes a starter configuration for spec.Binary. It reads the root command's persistent --config flag for the file to write.
func SessionDir ¶
SessionDir returns the worker.session_dir a Windows starter for an account (config init --user) names: a sessions directory beside target. Otherwise it is "" and the worker uses its default, under %ProgramData%\sqi on Windows, which only SYSTEM and Administrators can write, so a service running as an account could create no session there.
func ValidateNATSURL ¶
ValidateNATSURL checks a worker's nats.url: one or more comma-separated nats, tls, ws or wss URLs, each with a host and, when present, a valid port.
Types ¶
type Platform ¶
type Platform struct {
GOOS string // "linux", "darwin", "windows"
Home string // user home (macOS defaults)
ProgramData string // %ProgramData% (Windows defaults)
}
Platform is what defaults depend on. Tests build it for any OS.
type Spec ¶
type Spec struct {
Binary Binary
Version string // version.Version
UnixGroup string // the group that reads the system-wide file: "sqiworker" / "sqi"
}
Spec describes the binary a "config init" command is mounted in.
type Values ¶
type Values struct {
Version string // version of the writing binary
NATSURL string // worker only; "" leaves discovery on
DataDir string // from DataDir
// SessionDir is the worker's worker.session_dir, written only when it is
// not "" (config init --user gives one: see SessionDir).
SessionDir string
}
Values are the settings a starter configuration carries.