Documentation
¶
Index ¶
- Constants
- func DefaultName(now time.Time) string
- func IsKeyName(s string) bool
- func IsSecretName(name string) bool
- func LogName(service string) string
- func RunDoctorChild(ctx context.Context, dir string, exe func() (string, error)) (string, error)
- func TrimQuotes(v string) string
- func WriteTarball(b *Bundle, path string, now time.Time) (size int64, err error)
- type Bundle
- type DockerSetup
- type File
- type Options
- type Scrubber
- type SecretValue
- type Sources
- type TimeoutError
Constants ¶
const ( ClassValue = "value" ClassPEM = "pem" ClassUserinfo = "url_userinfo" ClassPattern = "pattern" ClassAssignment = "assignment" )
Redaction classes counted in manifest.json.
const ContainerLogTimeout = 60 * time.Second
ContainerLogTimeout bounds one container's log read (N3).
const DefaultMaxLogBytes = 4 << 20
DefaultMaxLogBytes caps one service log (the tail is kept).
const DoctorTimeout = 120 * time.Second
DoctorTimeout bounds the doctor child process.
const MinSecretLen = 6
MinSecretLen is the shortest value that is used as a literal scrub input.
Variables ¶
This section is empty.
Functions ¶
func DefaultName ¶
DefaultName is nself-report-<UTC timestamp>.tar.gz.
func IsSecretName ¶
IsSecretName reports whether an env/compose key name looks secret-bearing.
func LogName ¶
LogName maps a service name to logs/<name>.log with no path separators or dot-dot components.
func RunDoctorChild ¶
RunDoctorChild runs `<this binary> doctor` in dir and returns its combined output. exe is the seam for os.Executable.
func TrimQuotes ¶
TrimQuotes removes one matching pair of surrounding quotes.
Types ¶
type DockerSetup ¶
type DockerSetup struct {
ProjectDir string
DockerPath string // empty: docker from PATH
ComposeFiles []string
EnvFiles []string
}
DockerSetup tells the real log source which stack to read.
type Options ¶
type Options struct {
ProjectDir string
// NginxDir is the served nginx directory (internal/nginxtopo); empty skips nginx.
NginxDir string
Notes []string // caller notes carried into manifest.json
LogLines int
// ComposeFragments are the compose files of the stack (.nself/compose-files.txt
// resolved): read as scrub inputs only, never bundled.
ComposeFragments []string
// ComposeEnvFiles are the env files `nself build` writes for compose
// interpolation (build.ComposeEnvFiles: .env and .nself/compose.env); read as
// scrub inputs only.
ComposeEnvFiles []string
// Environ is the process environment seam; nil means os.Environ.
Environ func() []string
// MaxLogBytes caps each service log; 0 means DefaultMaxLogBytes.
MaxLogBytes int
}
Options configure one collection.
type Scrubber ¶
type Scrubber struct {
// contains filtered or unexported fields
}
Scrubber holds the literal inputs and the running counts.
func NewScrubber ¶
func NewScrubber(values []SecretValue) *Scrubber
NewScrubber builds a scrubber over the given secret values.
type SecretValue ¶
SecretValue is one literal to remove, in every spelling it may take.
func ExpandSecretValues ¶
func ExpandSecretValues(key, value string) []SecretValue
ExpandSecretValues returns every literal the scrubber should learn from one key=value pair: the value itself when the key is secret-like; the password of a URL-shaped value (any key, DATABASE_URL style, even when url.Parse refuses it: see urlcreds.go); and, for a secret-like key holding a JSON object (HASURA_GRAPHQL_JWT_SECRET), each string field of it that is secret-like or named "key", so the inner key is scrubbed on its own.
func NewSecretValue ¶
func NewSecretValue(key, value string) (SecretValue, bool)
NewSecretValue returns the scrub input for key=value, or false when the key is not secret-like, the value is too short, or it is only a ${REF}.
type Sources ¶
type Sources struct {
Versions func(ctx context.Context) map[string]string
Doctor func(ctx context.Context) (string, error)
// Logs returns the log tail of each service, keyed by service name.
Logs func(ctx context.Context, tail int) (map[string]string, error)
// LogNotes returns the notes the Logs call collected (for example a
// container whose log read timed out); optional, called right after Logs.
LogNotes func() []string
Now func() time.Time
}
Sources are the seams tests replace.
func RealSources ¶
func RealSources(ds DockerSetup) Sources
RealSources returns the production seams.
type TimeoutError ¶
TimeoutError reports that the doctor child ran out of time.
func (*TimeoutError) Error ¶
func (e *TimeoutError) Error() string
Source Files
¶
- child.go
- collect.go
- collect_logs.go
- compose_runtime.go
- dotenv.go
- inputs.go
- inputs_build.go
- inputs_envfile.go
- inputs_extra.go
- inputs_interp.go
- inputs_nodes.go
- inputs_structure.go
- nginx.go
- scrub.go
- scrub_block.go
- scrub_patterns.go
- scrub_patterns_extra.go
- scrub_pem.go
- secrets.go
- sources.go
- tarball.go
- urlcreds.go
- variants.go