preflight

package
v0.8.0 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2026 License: MIT Imports: 7 Imported by: 0

README

Preflight

The preflight package emits a versioned JSON report that captures a service's effective configuration and dependency readiness before launch. It is designed for external validators that need to compare configuration expectations without running the service.

Report shape

The report includes:

  • schema_version plus service metadata (name, build, config schema version, endpoint contract)
  • effective_config payload provided by a service-specific reporter
  • dependencies list with readiness status and optional details

Redaction

Use RedactionModeRedacted to strip sensitive fields while still reporting hashes for comparison. The HashSHA256Hex helper is provided for stable fingerprints (for example, signing keys or hostnames).

Viper adapter

The preflight/viperconfig package loads YAML configuration with Viper, applies configured environment bindings, and invokes a Redactor to build the effective config payload.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrReport = errors.New("preflight.report.invalid")

ErrReport indicates the report could not be built.

View Source
var ErrServiceInfo = errors.New("preflight.service_info.invalid")

ErrServiceInfo indicates the service metadata is invalid.

Functions

func BuildReport

func BuildReport(ctx context.Context, schemaVersion string, serviceInfo ServiceInfo, reporter ConfigReporter, checkers []DependencyChecker, mode RedactionMode) ([]byte, error)

BuildReport assembles a preflight report.

func HashSHA256Hex

func HashSHA256Hex(payload []byte) string

HashSHA256Hex returns the hex-encoded SHA-256 hash of the payload.

Types

type ConfigReporter

type ConfigReporter interface {
	Build(mode RedactionMode) (json.RawMessage, error)
}

ConfigReporter builds the effective config payload.

type DependencyChecker

type DependencyChecker interface {
	Check(ctx context.Context) (DependencyStatus, error)
}

DependencyChecker validates external dependencies.

type DependencyStatus

type DependencyStatus struct {
	Name    string            `json:"name"`
	Type    string            `json:"type"`
	Ready   bool              `json:"ready"`
	Details map[string]string `json:"details,omitempty"`
}

DependencyStatus describes one dependency check.

type RedactionMode

type RedactionMode int

RedactionMode controls how sensitive fields are reported.

const (
	RedactionModeRedacted RedactionMode = iota + 1
	RedactionModeFull
)

type ServiceInfo

type ServiceInfo interface {
	Name() string
	Version() string
	Commit() string
	BuildTime() string
	ConfigSchemaVersion() string
	EndpointContractVersion() string
	// contains filtered or unexported methods
}

ServiceInfo captures build and schema metadata.

func NewServiceInfo

func NewServiceInfo(name string, version string, commit string, buildTime string, configSchemaVersion string, endpointContractVersion string) (ServiceInfo, error)

NewServiceInfo constructs ServiceInfo with required fields.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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