Documentation
¶
Index ¶
Constants ¶
const ( FileTypeUnknown = iota FileTypeYaml FileTypeZed )
Variables ¶
var ErrInvalidYamlTryZed = errors.New("invalid yaml")
Functions ¶
This section is empty.
Types ¶
type Decoder ¶ added in v0.36.0
type Decoder struct {
Contents []byte
// FS is rooted at the directory of the fetched file. It is non-nil only
// for local (file://) URLs.
FS fs.FS
}
Decoder holds fetched file contents along with a filesystem for resolving relative paths (e.g. schemaFile references). For remote URLs the filesystem is nil because relative file references are not supported.
func DecoderFromURL ¶ added in v0.36.0
DecoderFromURL interprets the URL, fetches the content, and returns a Decoder. For local files the Decoder's FS is rooted at the file's directory so that relative schemaFile paths can be resolved.
func (*Decoder) UnmarshalAsYAMLOrSchema ¶ added in v0.36.0
func (d *Decoder) UnmarshalAsYAMLOrSchema() (*validationfile.ValidationFile, error)
UnmarshalAsYAMLOrSchema tries to unmarshal as YAML first, falling back to treating the contents as a raw schema.
func (*Decoder) UnmarshalSchemaValidationFile ¶ added in v0.36.0
func (d *Decoder) UnmarshalSchemaValidationFile() *validationfile.ValidationFile
UnmarshalSchemaValidationFile wraps raw schema bytes into a ValidationFile.
func (*Decoder) UnmarshalYAMLValidationFile ¶ added in v0.36.0
func (d *Decoder) UnmarshalYAMLValidationFile() (*validationfile.ValidationFile, error)
UnmarshalYAMLValidationFile unmarshals YAML validation file contents. If the YAML contains a schemaFile reference, the Decoder's FS is used to resolve it.