configcheck

package
v0.2.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package configcheck holds the checks both daemons apply to their configuration file before they open storage, bind listeners or acquire a packet counter. Every error names the configuration key that is wrong, so an operator can correct the file without reading a stack trace.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Endpoint

func Endpoint(field, endpoint string) error

Endpoint checks an address a daemon connects to, written as "host:port".

func File

func File(field, path string) error

File checks a path that must already hold a regular file, such as a certificate the daemon reads at startup.

func Host

func Host(field, host string) error

Host checks an IP address literal or a DNS name.

func Label

func Label(field, value string, maximum int) error

Label checks a short printable identifier such as an executor name.

func LogLevel

func LogLevel(field, level string) error

LogLevel checks a level name the logging subsystem accepts, so that a misspelled level fails instead of quietly falling back to info.

func Milliseconds

func Milliseconds(field string, value int64) error

Milliseconds is Seconds for a field documented in milliseconds.

func Origin

func Origin(field, origin string) error

Origin checks a browser origin: a scheme, a host and an optional port, with no path, query, fragment or credentials.

func Path

func Path(field, path string) error

Path checks a filesystem path the daemon opens or creates.

func Port

func Port(field string, port int) error

Port accepts the documented listener range. Zero is kept: it asks the operating system for an unused port, which readiness then reports.

func Seconds

func Seconds(field string, value int64) error

Seconds checks a configured number of seconds, keeping it inside the range that still converts to a time.Duration instead of wrapping into a short or negative interval.

Types

type Document

type Document struct {
	// contains filtered or unexported fields
}

Document records which keys a configuration file actually sets. Daemons use it to keep a documented default for an omitted key while still rejecting an explicit value that is out of range.

func Decode

func Decode(data []byte, target any) (Document, error)

Decode fills target from a TOML configuration file and reports which keys the file set. Keys the daemon does not support are rejected instead of ignored: a misspelled key otherwise looks like a setting that silently does nothing.

func (Document) Set

func (d Document) Set(path ...string) bool

Set reports whether the configuration file contains the given key. Table and key names are matched the same way the decoder matches them to fields.

Jump to

Keyboard shortcuts

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