Documentation
¶
Overview ¶
Package setup is `locklog setup`: the project's first .locklog/config.toml from what the host holds (log files with their rotated and compressed siblings, the journal, the running containers, a Compose Loki), the production question, the agent wiring at project scope, the authenticating proxy of a Compose Loki, and the own-container recipe.
Everything it writes is a proposal: the console shows the profile and every loosening to the human before any log is read.
Index ¶
- Constants
- func ContainerRecipe(w io.Writer, o RecipeOptions)
- func DockerProfile(p string) string
- func LeaRecipe(w io.Writer)
- func LokiProfile(p string) string
- func OnlyUnder(f hostfacts.Facts, dirs []string) hostfacts.Facts
- func Render(p Plan) ([]byte, error)
- func SearchProfile(p string) string
- type Detected
- type FileSource
- type Loki
- type LokiSource
- type Options
- type Plan
- type RecipeOptions
- type Result
Constants ¶
const ( AgentHost = "host" AgentContainer = "container" AgentLea = "lea" )
Agent placements.
Variables ¶
This section is empty.
Functions ¶
func ContainerRecipe ¶
func ContainerRecipe(w io.Writer, o RecipeOptions)
ContainerRecipe prints the own-container recipe: the Dockerfile snippet of the agent's image (a non-root agent user without sudo in the clients group, the locklog binary and a root-owned system file copied from the locklog image by digest), the run lines, and the console's --allowed-uids when the agent's uid is not one the console's image knows.
func DockerProfile ¶
DockerProfile, LokiProfile and SearchProfile name the side profiles of p.
func LokiProfile ¶
func SearchProfile ¶
Types ¶
type Detected ¶
type Detected struct {
Files []FileSource
Journald bool
Containers []string
Lokis []Loki
}
Detected is what the host offers for a first profile.
type FileSource ¶
FileSource is one detected log file family: a file and its rotated and compressed siblings, under one glob (or two, when a shorter family in the same directory would otherwise take its files).
type LokiSource ¶
type LokiSource struct {
URL, User, CACert string
// Credentials is "ask" or "vault" (with VaultPath).
Credentials, VaultPath string
// Selector is "label=value"; empty writes the profile commented out
// (a Loki source needs at least one label matcher).
Selector string
// Network is the Compose network the console joins.
Network string
}
LokiSource is the profile entry of a Loki behind the generated proxy.
type Options ¶
type Options struct {
// Root is the project directory (absolute): .locklog/ is created in it.
Root string
// Home is the user's home directory, never a project ("" unknown).
Home string
// Facts are the host's.
Facts hostfacts.Facts
// Production is the answer when set; nil asks (an unanswered question
// is yes).
Production *bool
// Yes takes the default answer of every other question.
Yes bool
// Agent is the placement ("" asks; unanswered: container for a
// production profile, host otherwise).
Agent string
// Agents overrides the detected agents (host placement).
Agents []string
// Only limits detection to the log files under these directories: no
// journal, no container (scripted runs that know their logs).
Only []string
// Profile is the main profile's name ("" : prod or staging).
Profile string
// LokiProxy is the Compose Loki service (or container) to put behind
// the authenticating proxy; "" asks when one is detected (and Yes
// skips it).
LokiProxy string
// LokiSelector is the Loki source's "label=value" matcher.
LokiSelector string
// ProxyBase is the directory, outside the project, that holds the
// proxies' directories (created 0700).
ProxyBase string
// VaultPath stores the proxy's token in Vault (credentials = "vault");
// empty: the console asks for it.
VaultPath string
// Recipe is the own-container recipe's image and agent uid.
Recipe RecipeOptions
// In holds the answers; Out is what setup prints. TTY is the human's
// terminal, the only place the proxy's token is shown (nil: no
// terminal, and no proxy is generated).
In io.Reader
Out io.Writer
TTY io.Writer
}
Options of one setup run.
type Plan ¶
type Plan struct {
// Profile is the main profile's name; the containers go to
// Profile-docker (a docker source needs a console of its own), a
// proxied Loki to Profile-loki (a console on the Compose network).
Profile string
Production bool
Detected Detected
// LokiProxy, when set, is the proxied Loki's source.
LokiProxy *LokiSource
}
Plan is the config setup writes.
type RecipeOptions ¶
type RecipeOptions struct {
// Image is the locklog image to copy from: a digest reference
// (registry@sha256:...) for a release, or a local tag.
Image string
// AgentUID is the agent user's uid in its image (default 10052, the
// locklog image's agent account, which the console already admits).
AgentUID int
// Profile is the profile the console serves (for the run lines).
Profile string
}
RecipeOptions describe the agent's own image.
type Result ¶
type Result struct {
Profile string
Production bool
Agent string
// ConfigWritten is false when a config was already there (kept).
ConfigWritten bool
// Proxy is the generated proxy (its Token is shown on TTY only).
Proxy *authproxy.Result
}
Result is what a setup run did, for its tests.