Documentation ¶
Overview ¶
Package types contains all of the type metadata for entities output by chronoctl
Index ¶
- Variables
- func Description(typeKind string, idKeyPairs ...string) string
- func DisplayName(typeKind string, identifier string) string
- func EncodeYAML(v interface{}) ([]byte, error)
- func MustDecodeSingleObject[T Object](r io.Reader, permissiveParsing bool) (T, error)
- func MustRegisterObject(meta TypeMeta, obj Object)
- func TypeDescription(obj Object, idKeyPairs ...string) string
- func WrongObjectErr(want, actual Object) error
- type Object
- type ObjectRegistry
- type TypeMeta
Constants ¶
This section is empty.
Variables ¶
var Registry = make(ObjectRegistry)
Registry contains the type information for all objects in the Chronosphere API.
Functions ¶
func Description ¶
Description creates a friendly identifying description of an object based on its king and a list of key-value pairs. The idKeyPairs must have an even number of elements, although values can be empty. Example: TypeDescription("Foo") will result in "Foo{}" Example: TypeDescription("Foo", "id", "xyz", "name", "thing") will result in "Foo{id="xyz", name="thing"}" Example: TypeDescription("Foo", "id", "", "name", "thing") will result in "Foo{name="thing"}"
func DisplayName ¶
DisplayName creates a name for a type based on its metadata.
func EncodeYAML ¶
EncodeYAML marshals an object as YAML.
func MustDecodeSingleObject ¶
MustDecodeSingleObject reads a single object and returns an error if there are more than one object in the input stream.
func MustRegisterObject ¶
MustRegisterObject registers a Chronosphere object. `meta` must define the object's Kind and API version, be a pointer to a struct, and there must not be a different object with the same Kind and API version in Registry already. If any of these conditions aren't met the function will panic. MustRegisterObject is intended to be called in init functions to register all valid types at startup.
func TypeDescription ¶
TypeDescription creates a friendly identifying description of an object based on its king and a list of key-value pairs. See Description for examples.
func WrongObjectErr ¶
WrongObjectErr returns an error indicating that the object the CLI is formatting is not what was expected.
Types ¶
type ObjectRegistry ¶
ObjectRegistry is a map from the type information of an object to it's actual Go type.
type TypeMeta ¶
type TypeMeta struct { // APIVersion is the versioned schema of this representation of an object. APIVersion string `json:"api_version,omitempty"` // Kind is the name of the resource this object represents in the Chronosphere API. Kind string `json:"kind,omitempty"` }
TypeMeta describes an object in the Chronosphere API. Note that the json tags for the object use snake case instead of camel case for field names to match the convention used by the API.