Documentation
¶
Overview ¶
Package fileconvert provides functions for marshalling Minder proto objects to and from on-disk formats like YAML.
Package fileconvert provides functions for marshalling Minder proto objects to and from on-disk formats like YAML.
Index ¶
- func ReadResource(input Decoder) (minderv1.ResourceMeta, error)
- func ReadResourceTyped[T proto.Message](input Decoder) (T, error)
- func ResourcesFromPaths(printer Printer, paths ...string) ([]minderv1.ResourceMeta, error)
- func WriteResource(output Encoder, resource minderv1.ResourceMeta) error
- type Decoder
- type Encoder
- type Printer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReadResource ¶
func ReadResource(input Decoder) (minderv1.ResourceMeta, error)
ReadResource reads a single resource from the specified Decoder. Only known resource types are supported; others will return an error. Given that multiple resources can be stored in a single file, the the input may not be fully consumed.
The resource is returned as a proto.Message, which can be type-asserted to the appropriate type (see also ReadResourceTyped). Like WriteResource, this uses proto JSON serialization in addition to naive decoding to handle proto-specific encoding features.
func ReadResourceTyped ¶
ReadResourceTyped reads a single resource from the specified Decoder and returns it as the specified subtype of proto.Messsage. This is a convenience wrapper around ReadResource that handles the type assertion for you.
func ResourcesFromPaths ¶
func ResourcesFromPaths(printer Printer, paths ...string) ([]minderv1.ResourceMeta, error)
ResourcesFromPaths collects
func WriteResource ¶
func WriteResource(output Encoder, resource minderv1.ResourceMeta) error
WriteResource outputs a Minder proto resource to an existing Encoder. Only known resource types are supported; others will return an error.
This uses the proto JSON serialization to convert the resource to an object, as a naive transformation from proto to YAML does not nicely deal with Structs and other proto features. In the case of JSON, this *does* mean that we encode to JSON twice, but this is not expected to be a high-performance path.