configinit

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: AGPL-3.0 Imports: 13 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

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func DataDir

func DataDir(b Binary, p Platform, target string) string

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

func DefaultTarget(b Binary, p Platform) string

DefaultTarget returns the path "config init" writes b's configuration to when no path is given.

func NewCommand

func NewCommand(spec Spec) *cobra.Command

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 Render

func Render(b Binary, p Platform, v Values) ([]byte, error)

Render returns the starter configuration for b.

func SessionDir

func SessionDir(b Binary, p Platform, target, account string) string

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

func ValidateNATSURL(raw string) error

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 Binary

type Binary string

Binary names the program a configuration file is for.

const (
	// Server is sqi-server.
	Server Binary = "sqi-server"
	// Worker is sqi-worker.
	Worker Binary = "sqi-worker"
)

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.

Jump to

Keyboard shortcuts

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