decode

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2026 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FileTypeUnknown = iota
	FileTypeYaml
	FileTypeZed
)

Variables

View Source
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

func DecoderFromURL(u *url.URL) (*Decoder, error)

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.

Jump to

Keyboard shortcuts

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