Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsRegisteredPackage ¶
IsRegisteredPackage returns whether a parser which returns a type from the given package path was registered. This is only useful to allow restricting reflection recursion (as a first-pass to limit how deep reflection goes).
func IsTarget ¶
IsTarget returns whether the given media-type should be treated as a "target media-type" for the purposes of reference resolution. This means that either the media-type has been registered as a target (using RegisterTarget) or has not been registered as parseable (using RegisterParser).
func RegisterParser ¶
RegisterParser registers a new ParseFunc to be used when the given media-type is encountered during parsing or recursive walks of blobs. See the documentation of ParseFunc for more detail.
func RegisterTarget ¶
func RegisterTarget(mediaType string)
RegisterTarget registers that a given *parseable* media-type (meaning that there is a parser already registered using RegisterParser) should be treated as a "target" for the purposes of reference resolution. This means that if this media-type is encountered during a reference resolution walk, a DescriptorPath to *that* blob will be returned and resolution will not recurse any deeper. All un-parseable blobs are treated as targets, so this is only useful for blobs that have also been given parsers.
Types ¶
type ParseFunc ¶
ParseFunc is a parser that is registered for a given mediatype and called to parse a blob if it is encountered. If possible, the blob should be represented as a native Go object (with all Descriptors represented as ispec.Descriptor objects) -- this will allow umoci to recursively discover blob dependencies.
Currently, we require the returned interface{} to be a raw struct (unexpected behaviour may occur otherwise).
NOTE: Your ParseFunc must be able to accept a nil Reader (the error
value is not relevant). This is used during registration in order to determine the type of the struct (thus you must return a struct that you would return in a non-nil reader scenario). Go doesn't have a way for us to enforce this.
func CustomJSONParser ¶
func CustomJSONParser(v interface{}) ParseFunc
CustomJSONParser creates a custom ParseFunc which JSON-decodes blob data into the type of the given value (which *must* be a struct, otherwise CustomJSONParser will panic). This is intended to make ergonomic use of RegisterParser much simpler.