Documentation
¶
Index ¶
- func ErrorWithSource(spec []byte, err error) error
- func ParseConfig(spec []byte, cfg any) error
- func ParseConfigFile(ctx context.Context, filename string, cfg any) error
- func ParseConfigFileStrict(ctx context.Context, filename string, cfg any) error
- func ParseConfigStrict(spec []byte, cfg any) error
- func ParseConfigString(spec string, cfg any) error
- func ParseConfigStringStrict(spec string, cfg any) error
- type FlexTime
- type RFC3339Time
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ErrorWithSource ¶
ErrorWithSource returns an error that includes the yaml source code that was the cause of the error to help with debugging YAML errors. Note that the errors reported for the yaml parser may be inaccurate in terms of the lines the error is reported on. This seems to be particularly true for lists where errors with use of tabs to indent are often reported against the previous line rather than the offending one.
func ParseConfig ¶
ParseConfig will parse the yaml config in spec into the requested type. It provides improved error reporting via ErrorWithSource.
func ParseConfigFile ¶
ParseConfigFile reads a yaml config file as per ParseConfig using file.FSReadFile to read the file. The use of FSReadFile allows for the configuration file to be read from storage system, including from embed.FS, instead of the local filesystem if an instance of fs.ReadFileFS is stored in the context.
func ParseConfigFileStrict ¶
ParseConfigFileStrict is like ParseConfigFile but reports an error if there are unknown fields in the yaml specification.
func ParseConfigStrict ¶
ParseConfigStrict is like ParseConfig but reports an error if there are unknown fields in the yaml specification.
func ParseConfigString ¶
ParseConfigString is like ParseConfig but for a string.
func ParseConfigStringStrict ¶
ParseConfigStringStrict is like ParseConfigString but reports an error if there are unknown fields in the yaml specification.
Types ¶
type FlexTime ¶
FlexTime is a time.Time that can be unmarshaled from time.RFC3339, time.DateTime, time.TimeOnly or time.DateOnly formats. It is always marshaled to time.RFC3339.
func (*FlexTime) MarshalYAML ¶
type RFC3339Time ¶
RFC3339Time is a time.Time that marshals to and from RFC3339 format.
func (*RFC3339Time) MarshalYAML ¶
func (t *RFC3339Time) MarshalYAML() (any, error)
func (RFC3339Time) String ¶
func (t RFC3339Time) String() string
func (*RFC3339Time) UnmarshalYAML ¶
func (t *RFC3339Time) UnmarshalYAML(value *yaml.Node) error