Documentation ¶
Index ¶
- Variables
- type SourceCtx
- func Find[T proto.Message](r io.Reader, match func(T) bool, out T, opts ...UnmarshalOpt) (SourceCtx, error)
- func NewEmptySourceCtx() SourceCtx
- func Unmarshal[T proto.Message](r io.Reader, factory func() T, opts ...UnmarshalOpt) ([]T, []SourceCtx, error)
- func UnmarshalBytes[T proto.Message](contents []byte, factory func() T, opts ...UnmarshalOpt) (_ []T, _ []SourceCtx, outErr error)
- type UnmarshalError
- type UnmarshalOpt
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrNotFound = errors.New("not found")
Functions ¶
This section is empty.
Types ¶
type SourceCtx ¶
type SourceCtx struct { *sourcev1.SourceContext // contains filtered or unexported fields }
func Find ¶
func Find[T proto.Message](r io.Reader, match func(T) bool, out T, opts ...UnmarshalOpt) (SourceCtx, error)
Find a single document from the multi-document stream. TODO(cell): Optimize! For our use case, this could be optimized by storing the offset of each document and directly seeking to that offset. However, there are a couple of problems with that:
- The offsets reported by the parser are not always reliable (I am yet to figure out why)
- If YAML anchors have been used, we need to resolve those first by reading through the entire file anyway However, this is a relatively niche case and we can handle that case lazily (seek first, read, and resolve anchors only if they exist in the doc)
In the interest of time, I am leaving those optimizations for later.
func NewEmptySourceCtx ¶
func NewEmptySourceCtx() SourceCtx
func UnmarshalBytes ¶
func (SourceCtx) ContextForYAMLPath ¶
func (SourceCtx) PositionAndContextForProtoPath ¶
func (SourceCtx) PositionForProtoPath ¶
func (SourceCtx) StartPosition ¶
type UnmarshalError ¶
func NewUnmarshalError ¶
func NewUnmarshalError(err *sourcev1.Error) UnmarshalError
func (UnmarshalError) Error ¶
func (ue UnmarshalError) Error() string
func (UnmarshalError) StringWithoutContext ¶
func (ue UnmarshalError) StringWithoutContext() string
type UnmarshalOpt ¶
type UnmarshalOpt func(*unmarshalOpts)
func WithIgnoreUnknownFields ¶
func WithIgnoreUnknownFields() UnmarshalOpt
WithIgnoreUnknownFields ignores unknown fields not defined in the protobuf schema.
func WithValidator ¶
func WithValidator(validator *protovalidate.Validator) UnmarshalOpt
WithValidate validates the unmarshaled message using protovalidate.
Click to show internal directories.
Click to hide internal directories.