preset

package
v0.45.0 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package preset loads and installs layered-configuration presets independently of any forge. Callers fetch a local file or HTTPS URL, optionally validate a SHA-256 digest, and install the bytes unchanged as .fullsend/config.base.yaml while leaving .fullsend/config.yaml as the repository-local overlay (ADR 0069).

Index

Constants

View Source
const (

	// BasePath is the repository-relative path of the vendor/base layer.
	BasePath = ".fullsend/config.base.yaml"
	// OverlayPath is the repository-relative path of the repo-local overlay.
	OverlayPath = ".fullsend/config.yaml"
)

Variables

This section is empty.

Functions

func Fetch

func Fetch(ctx context.Context, source string) ([]byte, error)

Fetch reads a preset configuration from a local file path or an HTTPS URL. Returns the raw content bytes.

func IsRemote

func IsRemote(source string) bool

IsRemote reports whether source is a URL rather than a local path, matching the schemes Fetch itself treats as remote (https:// only). A bare scheme check via url.Parse would misclassify strings such as a Windows-style path ("C:\presets\org.yaml", scheme "C") as remote even though Fetch treats them as local paths.

func Load

func Load(ctx context.Context, source, hash string) ([]byte, error)

Load fetches a preset, optionally validates a SHA-256 hex digest, and checks that the content is syntactically valid YAML. hash may be empty to skip digest verification. Layer-specific semantic validation is left to the caller.

func ValidateHash

func ValidateHash(data []byte, expectedHex string) error

ValidateHash checks that the SHA-256 hash of data matches the expected hex-encoded hash string. Returns nil on match.

func ValidateYAML

func ValidateYAML(data []byte) error

ValidateYAML checks that data is syntactically valid YAML.

Types

type Plan

type Plan struct {
	// Base is the exact preset bytes to write to BasePath.
	Base []byte
	// Overlay is the existing overlay, copied unchanged. Nil if none existed.
	Overlay []byte
	// BaseChanged is true when Base differs from the previous base
	// (including when no previous base existed).
	BaseChanged bool
}

Plan is the forge-independent result of installing a preset as the base layer. Overlay is never rewritten by preset installation.

func Apply

func Apply(preset, existingBase, existingOverlay []byte) Plan

Apply returns the layered-config files after installing preset as the base layer. Overlay is preserved byte-for-byte. Base is replaced wholesale with a copy of preset; it is never merged with the overlay or with the previous base. Callers that commit via a forge API write Plan.Base to BasePath when Plan.BaseChanged (or always, for compatibility with github setup --config).

Jump to

Keyboard shortcuts

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