Updates the package parsing logic to only attempt decoding with the
object scheme in the case that the error from decoding in the meta
scheme is due to the GVK not being registered. This does not change the
definition of a valid package, but does result in more informative
errors being returned when a package is invalid due to a malformed meta
type.
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
If a document contains only whitespace and we are not able to decode it
into one of the supported schemas, we ignore it and continue. We want to
avoid skipping a type that does not have a registered schema so that we
do not silently ignore errors when package building, but we consider it
safe to assume that a YAML document with no content is safe to skip.
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
YAML supports a document terminator (...) when reading files in a
stream. This allows for the reader to indicate that the current document
has ended without indicating that the stream is finished. Anything after
the document terminator is ignored by the consumer. Therefore, we write
the terminator at the end of a read file, then immediately follow with a
YAML document separator (---), which is mandatory according to the YAML
spec when using document terminators.
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
The FsReadCloser claimed to implictly skip empty files, but this was
only true when the final file to be read was empty. This updates to add
a SkipEmpty option that will filter out empty files before even
attempting to read file contents.
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Adds the annotate method to FsReadCloser so that it can provide
additional context to parser about most recently read data in the event
of an error.
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
An annotated reader supplies the package parser with additional context
about data that was read. The parser does not require a backend reader
to supply annotation information, but will check to see if the reader
implements the interface and will invoke it if an error is encountered.
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Adds note to NewFsReadCloser to indicate that symbolic links will not be
honored when walking the filesystem.
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Downstream consumers may implement their own linter functions, but the
core linter loop can be generalized, as well as helper functions such as
Or.
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
DefaultParser is not descriptive of the Parser implementation's purpose.
PackageParser indicates the this parser is meant for parsing packages.
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Because the parser eventually passes a runtime.Creater and runtime.Typer
to the underlying serializer, we only require that the passed schemes
implement those interfaces, rather than require that they be
*runtime.Scheme explicitly.
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Adds a package parser and a variety of backends that reads from a YAML
stream, accepting objects that are either part of the meta or object
runtime.Scheme and returning them as a Package.
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>
Implements io.ReadCloser for afero.Fs to allow passing it to a parser
that accepts an io.ReadCloser and reads from it.
Signed-off-by: hasheddan <georgedanielmangum@gmail.com>