Documentation
¶
Overview ¶
Package setup is `locklog profile add`: a profile of the project's .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, and the authenticating proxy of a Compose Loki.
Everything it writes is a proposal: the console shows the profile and every loosening to the human before any log is read.
Index ¶
- Variables
- func DockerProfile(p string) string
- func LokiProfile(p string) string
- func OnlyUnder(f hostfacts.Facts, dirs []string) hostfacts.Facts
- func Render(p Plan) ([]byte, error)
- func RenderProfiles(p Plan) ([]byte, error)
- func SearchProfile(p string) string
- type Detected
- type FileSource
- type Loki
- type LokiSource
- type Options
- type Plan
- type Result
Constants ¶
This section is empty.
Variables ¶
var ErrExists = errors.New("the profile is already in the project's config")
ErrExists refuses a profile already in the project's config: nothing is written (lockkit's verbs code "exists").
var ErrNoSource = errors.New("no log file or journal found here (under /var/log and LOCKLOG_EXTRA_ROOTS, or the --only directories): nothing written; name the directories with --only, or write the profile's sources by hand (docs/usage.md)")
ErrNoSource refuses a profile with no log file or journal found: nothing is written.
var ErrUsage = errors.New("usage")
ErrUsage is an option the run cannot take (verbs code "usage").
Functions ¶
func DockerProfile ¶
DockerProfile, LokiProfile and SearchProfile name the side profiles of p.
func LokiProfile ¶
func RenderProfiles ¶ added in v0.2.0
RenderProfiles writes the profiles of p alone, to append to an existing config (whose loading the caller checks with them).
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 --production; ProductionSet says it was given.
Production, ProductionSet bool
// Ask asks, on In, what the options did not give (the interactive
// form): whether the profile is production, and the proxy of a
// detected Compose Loki. Without it nothing is asked.
Ask bool
// 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 (interactive only: its token is shown on
// TTY); "" asks when one is detected (with Ask).
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
// Credentials is the proxied Loki source's: "ask" (the console asks at
// start) or "vault" (with VaultPath; the console asks the Vault token
// at start).
Credentials, VaultPath string
// In holds the answers; Out is what the run prints (a human's text).
// 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 `locklog profile add` 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 Result ¶
type Result struct {
Profile string
Production bool
// Config is the config file written (created, or the profiles
// appended to it).
Config string
// Created: the config file did not exist before.
Created bool
// Profiles are the profiles written: Profile, and its side profiles
// (Profile-docker for the containers, Profile-loki for a proxied
// Loki).
Profiles []string
// Credentials is the proxied Loki's ("ask" or "vault"); empty when no
// profile written has a secret.
Credentials string
// Proxy is the generated proxy (its Token is shown on TTY only).
Proxy *authproxy.Result
}
Result is what a run did.
func AddProfile ¶ added in v0.2.0
AddProfile is `locklog profile add`: the profile (and its side profiles) from the host's logs, written to the trusted .locklog/ of the project: the file is created, or the profiles appended to it. A profile already there is never rewritten (ErrExists, nothing written). It never takes, asks for or writes a secret: a remote source's is asked by the console at start, or read from Vault.