Documentation
¶
Overview ¶
Package scheme provides the runtime scheme and codecs for all supported versions of the FYT API.
Index ¶
- Variables
- func Decode(r io.Reader, opts ...*Option) (*internal.Config, error)
- func DecodeInvoiceSettingsOverride(r io.Reader) (*v1alpha1.InvoiceSettingsOverride, error)
- func DecodeVersionedConfig(r io.Reader, opts ...*Option) (*v1alpha1.Config, error)
- func DecodeVersionedInvoiceConfig(r io.Reader) (*v1alpha1.InvoiceConfig, error)
- func DecodeVersionedInvoiceConfigList(r io.Reader) (*v1alpha1.InvoiceConfigList, error)
- func DefaultConfig() *internal.Config
- func Load(path string, opts ...*Option) (*internal.Config, error)
- func LoadVersionedConfig(path string, opts ...*Option) (*v1alpha1.Config, error)
- type Option
Constants ¶
This section is empty.
Variables ¶
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") )
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 ¶
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 ¶
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 ¶
DefaultConfig returns default configuration entry.
Types ¶
type Option ¶
type Option struct {
// UseStrict overrides strict decoding when set.
UseStrict *bool
}
Option configures decoding. The zero value enables strict decoding.
func (*Option) Codecs ¶
func (o *Option) Codecs() *serializer.CodecFactory
Codecs returns the selected codec factory. A nil or zero Option uses Strict.