configgen

package
v0.1.11 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: MIT Imports: 23 Imported by: 0

Documentation

Overview

Package configgen implements the development-time generator behind cmd/kms-config-gen.

Index

Constants

View Source
const DefaultsFuncName = "Defaults"

DefaultsFuncName is the defaults function the generator looks for when none is named explicitly.

Variables

View Source
var ErrStale = errors.New("generated configuration artifacts are stale")

ErrStale marks verification failures caused by missing or out-of-date files.

Functions

func Verify

func Verify(paths OutputPaths, artifacts Artifacts) error

Verify compares generated artifacts without changing the filesystem.

func Write

func Write(paths OutputPaths, artifacts Artifacts) error

Write writes all artifacts atomically. Existing files whose content already matches are left untouched.

Types

type Artifacts

type Artifacts struct {
	Binding  []byte
	Schema   []byte
	Contract []byte
}

Artifacts contains the three complete, newline-terminated generated files. Binding has already been gofmt formatted.

func Generate

func Generate(ctx context.Context, options Options) (Artifacts, error)

Generate loads and validates a root type, then renders all artifacts from a single normalized intermediate representation.

type Options

type Options struct {
	Package        string
	Dir            string
	Type           string
	BindingPackage string
	Env            []string
	// DefaultsFunc names the package-level function whose returned literal
	// supplies schema defaults. Empty looks for Defaults when present; "-"
	// disables the lookup; any other name is required to exist.
	DefaultsFunc string
}

Options describes one generator invocation. Package defaults to the current package ("."). Dir controls the working directory used by go/packages.

type OutputPaths

type OutputPaths struct {
	Binding  string
	Schema   string
	Contract string
}

OutputPaths identifies the application-controlled artifact destinations.

type StaleError

type StaleError struct{ Paths []string }

StaleError lists every stale artifact rather than failing at the first file.

func (*StaleError) Error

func (e *StaleError) Error() string

func (*StaleError) Unwrap

func (e *StaleError) Unwrap() error

Jump to

Keyboard shortcuts

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