scheme

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 16 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package scheme provides the runtime scheme and codecs for all supported versions of the FYT API.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrLoad is returned if any error occurred during loading configuration file.
	ErrLoad = errors.New("could not load configuration file")
	// ErrDecode is returned if there was an error during object decoding operations.
	ErrDecode = errors.New("could not decode object")
)
View Source
var (
	// Scheme contains the internal configuration API and every supported wire
	// version.
	Scheme = runtime.NewScheme()

	// Strict performs strict decoding, defaulting, and conversion between the
	// registered configuration API versions.
	//
	// Use [DecodeVersionedInvoiceConfig] or [DecodeVersionedInvoiceConfigList]
	// for invoice documents. Those functions require one document with the
	// expected invoice structure and reject nulls and mismatched list item
	// type metadata. They also check YAML monetary precision before converting
	// to JSON.
	Strict = new(serializer.NewCodecFactory(Scheme, serializer.EnableStrict))
	// Unstrict performs decoding with strict disabled.
	Unstrict = new(serializer.NewCodecFactory(Scheme))
)

Functions

func Decode

func Decode(r io.Reader, opts ...*Option) (*internal.Config, error)

Decode decodes a JSON or YAML configuration, applies defaults for its declared API version, and converts it to the internal Config type.

The document must contain a registered apiVersion and kind. Strict decoding rejects unknown and duplicate fields by default. Pass OptNoStrict to allow them. For YAML streams, Decode reads the first document.

func DecodeInvoiceSettingsOverride

func DecodeInvoiceSettingsOverride(r io.Reader) (*v1alpha1.InvoiceSettingsOverride, error)

DecodeInvoiceSettingsOverride reads a strict JSON or YAML document with only an invoice section, preserving explicitly empty values.

func DecodeVersionedConfig

func DecodeVersionedConfig(r io.Reader, opts ...*Option) (*v1alpha1.Config, error)

DecodeVersionedConfig decodes a registered configuration, applies defaults for its declared version, and returns it in the v1alpha1 API version.

func DecodeVersionedInvoiceConfig

func DecodeVersionedInvoiceConfig(r io.Reader) (*v1alpha1.InvoiceConfig, error)

DecodeVersionedInvoiceConfig reads one strict JSON or YAML InvoiceConfig. It preserves explicitly empty values and does not apply invoice defaults.

func DecodeVersionedInvoiceConfigList

func DecodeVersionedInvoiceConfigList(r io.Reader) (*v1alpha1.InvoiceConfigList, error)

DecodeVersionedInvoiceConfigList reads one strict JSON or YAML InvoiceConfigList. It preserves item order and applies no invoice defaults to its items.

func DefaultConfig

func DefaultConfig() *internal.Config

DefaultConfig returns default configuration entry.

func Load

func Load(path string, opts ...*Option) (*internal.Config, error)

Load reads a configuration file using Decode.

func LoadVersionedConfig

func LoadVersionedConfig(path string, opts ...*Option) (*v1alpha1.Config, error)

LoadVersionedConfig loads and decodes a configuration into the v1alpha1 API version.

Types

type Option

type Option struct {
	// UseStrict overrides strict decoding when set.
	UseStrict *bool
}

Option configures decoding. The zero value enables strict decoding.

func OptNoStrict

func OptNoStrict() *Option

OptNoStrict enforces strict mode: off.

func (*Option) Codecs

func (o *Option) Codecs() *serializer.CodecFactory

Codecs returns the selected codec factory. A nil or zero Option uses Strict.

Jump to

Keyboard shortcuts

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