Documentation ¶
Index ¶
- Variables
- func BuildInstance(ctx *cue.Context, relpath string, pkg string, overlay fs.FS) (cue.Value, error)
- func CUEFramework(ctx *cue.Context) cue.Value
- func LoadInstance(relpath string, pkg string, overlay fs.FS) (*build.Instance, error)
- func Ptr[T any](v T) *T
- func SchemaInterfaces(ctx *cue.Context) map[string]SchemaInterface
- func ToKindProps[T KindProperties](v cue.Value) (T, error)
- type BasicMetadataObject
- func (b *BasicMetadataObject) CommonMetadata() CommonMetadata
- func (b *BasicMetadataObject) CustomMetadata() CustomMetadata
- func (b *BasicMetadataObject) SetCommonMetadata(m CommonMetadata)
- func (b *BasicMetadataObject) SetStaticMetadata(m StaticMetadata)
- func (b *BasicMetadataObject) StaticMetadata() StaticMetadata
- type CommonMetadata
- type CommonProperties
- type Composable
- type ComposableProperties
- type Core
- type CoreProperties
- type Custom
- type CustomMetadata
- type CustomProperties
- type Decoder
- type Def
- type Encoder
- type FullIdentifier
- type Identifier
- type Kind
- type KindProperties
- type ListMetadata
- type ListResource
- type Maturity
- type Resource
- type ResourceKind
- type SchemaInterface
- type SimpleCustomMetadata
- type SomeDef
- type SomeKindProperties
- type StaticMetadata
- type TypedCore
- type TypedCustom
- type UnmarshalConfig
- type UnstructuredResource
- type WireFormat
Constants ¶
This section is empty.
Variables ¶
var ( // ErrValueNotExist indicates that a necessary CUE value did not exist. ErrValueNotExist = errors.New("cue value does not exist") // ErrValueNotAKind indicates that a provided CUE value is not any variety of // Kind. This is almost always a user error - they oops'd and provided the // wrong path, file, etc. ErrValueNotAKind = errors.New("not a kind") // ErrInvalidCUE indicates that the CUE representing the kind is invalid. ErrInvalidCUE = errors.New("CUE syntax error") )
var CueSchemaFS embed.FS
CueSchemaFS embeds all CUE files in the Kindsys project.
Functions ¶
func BuildInstance ¶
func CUEFramework ¶
CUEFramework returns a cue.Value representing all the kindsys framework raw CUE files.
For low-level use in constructing other types and APIs, while still letting us define all the frameworky CUE bits in a single package. Other Go types make the constructs in the returned cue.Value easy to use.
Calling this with a nil cue.Context (the singleton returned from [CUEContext]) will memoize certain CUE operations. Prefer passing nil unless a different cue.Context is specifically required.
func LoadInstance ¶
LoadInstance returns a build.Instance populated with the CueSchemaFS at the root and an optional overlay filesystem.
func Ptr ¶
func Ptr[T any](v T) *T
Ptr returns a pointer to a value of an arbitrary type.
This function is provided to compensate for Grafana's Go code generation that represents optional fields using pointers.
Pointers are the only technically correct, non-ambiguous way of representing an optional field in Go's type system. However, Go does not allow taking the address of certain primitive types inline. That is, this is invalid Go code:
var str *string str = &"colorless green ideas sleep furiously"
This func allows making such declarations in a single line:
var str *string str = kindsys.Ptr("colorless green ideas sleep furiously")
func SchemaInterfaces ¶
func SchemaInterfaces(ctx *cue.Context) map[string]SchemaInterface
SchemaInterfaces returns a map of all [SchemaInterface]s defined by the given framework.
TODO link to framework docs
func ToKindProps ¶
func ToKindProps[T KindProperties](v cue.Value) (T, error)
ToKindProps takes a cue.Value expected to represent a kind of the category specified by the type parameter and populates the Go type from the cue.Value.
Types ¶
type BasicMetadataObject ¶
type BasicMetadataObject struct { StaticMeta StaticMetadata `json:"staticMetadata"` CommonMeta CommonMetadata `json:"commonMetadata"` CustomMeta SimpleCustomMetadata `json:"customMetadata"` }
BasicMetadataObject is a composable base struct to attach Metadata, and its associated functions, to another struct. BasicMetadataObject provides a Metadata field composed of StaticMetadata and ObjectMetadata, as well as the ObjectMetadata(),SetObjectMetadata(), StaticMetadata(), and SetStaticMetadata() receiver functions.
func (*BasicMetadataObject) CommonMetadata ¶
func (b *BasicMetadataObject) CommonMetadata() CommonMetadata
CommonMetadata returns the object's CommonMetadata
func (*BasicMetadataObject) CustomMetadata ¶
func (b *BasicMetadataObject) CustomMetadata() CustomMetadata
CustomMetadata returns the object's CustomMetadata
func (*BasicMetadataObject) SetCommonMetadata ¶
func (b *BasicMetadataObject) SetCommonMetadata(m CommonMetadata)
SetCommonMetadata overwrites the ObjectMetadata.Common() supplied by BasicMetadataObject.ObjectMetadata()
func (*BasicMetadataObject) SetStaticMetadata ¶
func (b *BasicMetadataObject) SetStaticMetadata(m StaticMetadata)
SetStaticMetadata overwrites the StaticMetadata supplied by BasicMetadataObject.StaticMetadata()
func (*BasicMetadataObject) StaticMetadata ¶
func (b *BasicMetadataObject) StaticMetadata() StaticMetadata
StaticMetadata returns the object's StaticMetadata
type CommonMetadata ¶
type CommonMetadata struct { // UID is the unique ID of the object. This can be used to uniquely identify objects, // but is not guaranteed to be usable for lookups. UID string `json:"uid"` // ResourceVersion is a version string used to identify any and all changes to the object. // Any time the object changes in storage, the ResourceVersion will be changed. // This can be used to block updates if a change has been made to the object between when the object was // retrieved, and when the update was applied. ResourceVersion string `json:"resourceVersion"` // Labels are string key/value pairs attached to the object. They can be used for filtering, // or as additional metadata. Labels map[string]string `json:"labels"` // CreationTimestamp indicates when the resource has been created. CreationTimestamp time.Time `json:"creationTimestamp"` // DeletionTimestamp indicates that the resource is pending deletion as of the provided time if non-nil. // Depending on implementation, this field may always be nil, or it may be a "tombstone" indicator. // It may also indicate that the system is waiting on some task to finish before the object is fully removed. DeletionTimestamp *time.Time `json:"deletionTimestamp,omitempty"` // Finalizers are a list of identifiers of interested parties for delete events for this resource. // Once a resource with finalizers has been deleted, the object should remain in the store, // DeletionTimestamp is set to the time of the "delete," and the resource will continue to exist // until the finalizers list is cleared. Finalizers []string `json:"finalizers"` // UpdateTimestamp is the timestamp of the last update to the resource. UpdateTimestamp time.Time `json:"updateTimestamp"` // CreatedBy is a string which indicates the user or process which created the resource. // Implementations may choose what this indicator should be. CreatedBy string `json:"createdBy"` // UpdatedBy is a string which indicates the user or process which last updated the resource. // Implementations may choose what this indicator should be. UpdatedBy string `json:"updatedBy"` // ExtraFields stores implementation-specific metadata. // Not all Client implementations are required to honor all ExtraFields keys. // Generally, this field should be shied away from unless you know the specific // Client implementation you're working with and wish to track or mutate extra information. ExtraFields map[string]any `json:"extraFields"` }
CommonMetadata is the system-defined common metadata associated with a Resource. It combines Kubernetes standard metadata with certain Grafana-specific additions.
It is analogous to k8s.io/apimachinery/pkg/apis/meta/v1.ObjectMeta in vanilla Kubernetes.
TODO generate this from the CUE definition TODO review this for optionality
type CommonProperties ¶
type CommonProperties struct { Name string `json:"name"` PluralName string `json:"pluralName"` MachineName string `json:"machineName"` PluralMachineName string `json:"pluralMachineName"` LineageIsGroup bool `json:"lineageIsGroup"` Maturity Maturity `json:"maturity"` Description string `json:"description,omitempty"` }
CommonProperties contains the metadata common to all categories of kinds.
type Composable ¶
type Composable interface { Kind // Def returns a wrapper around the underlying CUE value that represents the // loaded and validated kind definition. Def() Def[ComposableProperties] }
Composable is the untyped runtime representation of a Grafana core kind definition. It is one in a family of interfaces, see Kind for context.
TODO sort out the Go type used for generic associated...objects? do we even need one?
func BindComposable ¶
func BindComposable(rt *thema.Runtime, def Def[ComposableProperties], opts ...thema.BindOption) (Composable, error)
TODO docs
type ComposableProperties ¶
type ComposableProperties struct { CommonProperties CurrentVersion thema.SyntacticVersion `json:"currentVersion"` SchemaInterface string `json:"schemaInterface"` }
ComposableProperties represents the static properties in the definition of a Composable kind that are representable with basic Go types. This excludes Thema schemas.
func (ComposableProperties) Common ¶
func (m ComposableProperties) Common() CommonProperties
type Core ¶
type Core interface { ResourceKind // Def returns a wrapper around the underlying CUE value that represents the // loaded and validated kind definition. Def() Def[CoreProperties] }
Core is the dynamically typed runtime representation of a Grafana core kind definition. It is one in a family of interfaces, see Kind for context.
A Core kind provides interactions with its corresponding Resource using UnstructuredResource.
func BindCore ¶
func BindCore(rt *thema.Runtime, def Def[CoreProperties], opts ...thema.BindOption) (Core, error)
TODO docs
type CoreProperties ¶
type CoreProperties struct { CommonProperties CurrentVersion thema.SyntacticVersion `json:"currentVersion"` CRD struct { Group string `json:"group"` Scope string `json:"scope"` DummySchema bool `json:"dummySchema"` } `json:"crd"` }
CoreProperties represents the static properties in the definition of a Core kind that are representable with basic Go types. This excludes Thema schemas.
When .cue file(s) containing a Core definition is loaded through the standard [LoadCoreKindDef], func, it is fully validated and populated according to all rules specified in CUE for Core kinds.
func (CoreProperties) Common ¶
func (m CoreProperties) Common() CommonProperties
type Custom ¶
type Custom interface { ResourceKind // Def returns a wrapper around the underlying CUE value that represents the // loaded and validated kind definition. Def() Def[CustomProperties] }
Custom is the dynamically typed runtime representation of a Grafana custom kind definition. It is one in a family of interfaces, see Kind for context.
A Custom kind provides interactions with its corresponding Resource using UnstructuredResource.
Custom kinds are declared in Grafana extensions, rather than in Grafana core. It is likely that this distinction will go away in the future, leaving only Custom kinds.
func BindCustom ¶
func BindCustom(rt *thema.Runtime, def Def[CustomProperties], opts ...thema.BindOption) (Custom, error)
BindCustom creates a Custom-implementing type from a def, runtime, and opts
type CustomMetadata ¶
type CustomMetadata interface { // MapFields converts the custom metadata's fields into a map of field key to value. // This is used so Clients don't need to engage in reflection for marshaling metadata, // as various implementations may not store kind-specific metadata the same way. MapFields() map[string]any }
CustomMetadata is an interface describing a kindsys.Resource's kind-specific metadata
type CustomProperties ¶
type CustomProperties struct { CommonProperties CurrentVersion thema.SyntacticVersion `json:"currentVersion"` IsCRD bool `json:"isCRD"` Group string `json:"group"` CRD struct { Group string `json:"group"` Scope string `json:"scope"` GroupOverride *string `json:"groupOverride"` } `json:"crd"` Codegen struct { Frontend bool `json:"frontend"` Backend bool `json:"backend"` } `json:"codegen"` }
CustomProperties represents the static properties in the definition of a Custom kind that are representable with basic Go types. This excludes Thema schemas.
func (CustomProperties) Common ¶
func (m CustomProperties) Common() CommonProperties
type Decoder ¶
type Decoder interface {
Decode(b []byte) (encoding.GrafanaShapeBytes, error)
}
Decoder takes a []byte representing a serialized resource and decodes it into the intermediate encoding.GrafanaShapeBytes form. Implementations should vary in the form of the []byte they expect to take - e.g. JSON vs. YAML; Kubernetes shape vs. Grafana shape.
TODO do less with these by deciding on a single, consistent object format
type Def ¶
type Def[T KindProperties] struct { // V is the cue.Value containing the entire Kind definition. V cue.Value // Properties contains the kind's declarative non-schema properties. Properties T }
Def represents a single kind definition, having been loaded and validated by a func such as [LoadCoreKindDef].
Its type parameter indicates the category of kind.
Thema lineages in the contained definition have not yet necessarily been validated.
func ToDef ¶
func ToDef[T KindProperties](v cue.Value) (Def[T], error)
ToDef takes a cue.Value expected to represent a kind of the category specified by the type parameter and populates a Def from the CUE value. The cue.Value in Def.V will be the unified value of the parameter cue.Value and the kindsys CUE kind (Core, Custom, Composable).
type FullIdentifier ¶
type FullIdentifier struct { Namespace string Name string Group string Version string Kind string Plural string }
FullIdentifier is a globally-unique identifier, consisting of Schema identity information (Group, Version, Kind, Plural) and within-schema identity information (Namespace, Name)
type Identifier ¶
type Kind ¶
type Kind interface { // Name returns the kind's name, as specified in the name field of the kind definition. // // Note that this is the capitalized name of the kind. For other names and // common kind properties, see [Props.CommonProperties]. Name() string // MachineName returns the kind's machine name, as specified in the machineName // field of the kind definition. MachineName() string // Maturity indicates the maturity of this kind, one of the enum of values we // accept in the maturity field of the kind definition. Maturity() Maturity // Props returns a [SomeKindProps], representing the properties // of the kind as declared in the .cue source. The underlying type is // determined by the category of kind. Props() SomeKindProperties // CurrentVersion returns the version number of the schema that is considered // the 'current' version, usually the latest version. When initializing object // instances of this Kind, the current version is used by default. CurrentVersion() thema.SyntacticVersion // Lineage returns the kind's [thema.Lineage]. The lineage contains the full // history of object schemas associated with the kind. // // TODO separate this onto an optional, additional interface Lineage() thema.Lineage }
Kind is a runtime representation of a Grafana kind definition.
Kind definitions are canonically written in CUE. Loading and validating such CUE definitions produces instances of this type. Kind, and its sub-interfaces, are the expected canonical way of working with kinds in Go.
Kind has six sub-interfaces, all of which provide:
- Access to the kind's defined meta-properties, such as `name`, `pluralName`, or `maturity` - Access to the schemas defined in the kind - Methods for certain key operations on the kind and object instances of its schemas
Kind definitions are written in CUE. The meta-schema specifying how to write kind definitions are also written in CUE. See the files at the root of the kindsys repository.
There are three categories of kinds, each having its own sub-interface: Core, Custom, and Composable. All kind definitions are in exactly one category (a kind can't be both Core and Composable). Correspondingly, all instances of Kind also implement exactly one of these sub-interfaces.
Conceptually, kinds are similar to class definitions in object-oriented programming. They define a particular type of object, and how instances of that object should be created. The object defined by a Core or Custom kind is called a Resource. TODO name for the associated object for composable kinds
Core, Custom and Composable all provide methods for unmarshaling []byte into an unstructured Go type, UnstructuredResource, similar to how json.Unmarshal can use map[string]any as a universal fallback. Relying on this untyped approach is recommended for use cases that need to work generically on any Kind. This is especially because untyped Kinds are portable, and can be loaded at runtime in Go: the original CUE definition is sufficient to create instances of Core, Custom or Composable.
However, when working with a specific, finite set of kinds, it is usually preferable to use the typed interfaces:
- Core -> TypedCore - Custom -> TypedCustom - Composable -> [TypedComposable] (TODO not yet implemented)
Each embeds the corresponding untyped interface, and takes a generic type parameter. The provided struct is verified to be assignable to the latest schema defined in the kind. (See thema.BindType) Additional methods are provided on Typed* variants that do the same as their untyped counterparts, but using the type given in the generic type parameter.
Directly implementing this interface is discouraged. Strongly prefer instead to rely on BindCore, BindCustom, or BindComposable.
type KindProperties ¶
type KindProperties interface { CoreProperties | CustomProperties | ComposableProperties }
KindProperties is a type parameter that comprises the base possible set of kind metadata configurations.
type ListMetadata ¶
type ListMetadata struct { ResourceVersion string `json:"resourceVersion"` Continue string `json:"continue"` RemainingItemCount *int64 `json:"remainingItemCount"` // ExtraFields stores implementation-specific metadata. // Not all Client implementations are required to honor all ExtraFields keys. // Generally, this field should be shied away from unless you know the specific // Client implementation you're working with and wish to track or mutate extra information. ExtraFields map[string]any `json:"extraFields"` }
ListMetadata is metadata for a list of objects. This is typically only used in responses from the storage layer.
type ListResource ¶
type ListResource interface { ListMetadata() ListMetadata SetListMetadata(ListMetadata) ListItems() []Resource SetItems([]Resource) }
ListResource represents a List of Resource-implementing objects with list metadata. The simplest way to use it is to use the implementation returned by a Client's List call.
type Resource ¶
type Resource interface { // CommonMetadata returns the Resource's CommonMetadata CommonMetadata() CommonMetadata // SetCommonMetadata overwrites the CommonMetadata of the object. // Implementations should always overwrite, rather than attempt merges of the metadata. // Callers wishing to merge should get current metadata with CommonMetadata() and set specific values. SetCommonMetadata(metadata CommonMetadata) // StaticMetadata returns the Resource's StaticMetadata StaticMetadata() StaticMetadata // SetStaticMetadata overwrites the Resource's StaticMetadata with the provided StaticMetadata. // Implementations should always overwrite, rather than attempt merges of the metadata. // Callers wishing to merge should get current metadata with StaticMetadata() and set specific values. // Note that StaticMetadata is only mutable in an object create context. SetStaticMetadata(metadata StaticMetadata) // CustomMetadata returns metadata unique to this Resource's kind, as opposed to Common and Static metadata, // which are the same across all kinds. An object may have no kind-specific CustomMetadata. // CustomMetadata can only be read from this interface, for use with resource.Client implementations, // those who wish to set CustomMetadata should use the interface's underlying type. CustomMetadata() CustomMetadata // SpecObject returns the actual "schema" object, which holds the main body of data SpecObject() any // Subresources returns a map of subresource name(s) to the object value for that subresource. // Spec is not considered a subresource, and should only be returned by SpecObject Subresources() map[string]any // Copy returns a full copy of the Resource with all its data Copy() Resource }
A Resource is a single instance of a Grafana Kind, either Core or Custom.
The relationship between Resource and Kind is similar to the relationship between objects and classes in conventional object oriented design:
- Objects are instantiated from classes. The name of the class is the type of object. - Resources are instantiated from kinds. The name of the kind is the type of resource.
Resource is an interface, rather than a concrete struct, for two reasons:
- Some use cases need to operate generically over resources of any kind. - Go generics do not allow the ergonomic expression of certain needed constraints.
The Core and Custom interfaces are intended for the generic operation use case, fulfilling Resource using UnstructuredResource.
For known, specific kinds, it is usually possible to rely on code generation to produce a struct that implements Resource for each kind. Such a struct can be used as the generic type parameter to create a TypedCore or TypedCustom
func CopyResource ¶
CopyResource is an implementation of the receiver method `Copy()` required for implementing Resource. It should be used in your own runtime.Resource implementations if you do not wish to implement custom behavior. Example:
func (c *CustomResource) Copy() kindsys.Resource { return resource.CopyResource(c) }
type ResourceKind ¶
type ResourceKind interface { Kind // Validate takes a []byte representing an object instance of this kind and // checks that it is a valid instance of at least one schema defined in the // kind. // // A decoder must be provided that knows how to decode the []byte into an // intermediate form. At minimum, the right decoder must be chosen for the // format - for example, JSON vs YAML. For resource kinds, a decoder must // also know how to transform the input from a Kubernetes resource object // shape to Grafana's object shape. See [github.com/grafana/kindsys/encoding]. Validate(b []byte, codec Decoder) error // FromBytes takes a []byte and a decoder, validates it against schema, and // if validation is successful, unmarshals it into an UnstructuredResource. FromBytes(b []byte, codec Decoder) (*UnstructuredResource, error) // Group returns the kind's group, as defined in the group field of the kind definition. // // This is equivalent to the group of a Kubernetes CRD. Group() string }
ResourceKind represents a kind that defines a root object, or Kubernetish resource.
TODO this is a temporary intermediate while we combine Core and Custom. This name will probably go away.
type SchemaInterface ¶
type SchemaInterface struct {
// contains filtered or unexported fields
}
SchemaInterface represents one of Grafana's named schema interfaces.
Canonical definition of schema interfaces is done in CUE. Instances of this type simply represent that information in Go. TODO link to framework docs
func FindSchemaInterface ¶
func FindSchemaInterface(name string) (SchemaInterface, error)
func (SchemaInterface) Contract ¶
func (s SchemaInterface) Contract() cue.Value
Contract returns the cue.Value representing the meta-schema that is the contract between core/custom kinds that consume schemas that are instances of the SchemaInterface contract, and composable kinds that produce such schemas.
func (SchemaInterface) IsGroup ¶
func (s SchemaInterface) IsGroup() bool
IsGroup indicates whether the slot specifies a group lineage - one in which each top-level key represents a distinct schema for objects that are expected to exist in the wild, but objects corresponding to the root of the schema are not expected to exist.
func (SchemaInterface) Name ¶
func (s SchemaInterface) Name() string
Name returns the name of the SchemaInterface.
The name is also used as the path at which a SchemaInterface lineage is defined in a plugin models.cue file.
func (SchemaInterface) Should ¶
func (s SchemaInterface) Should(plugintype string) bool
Should indicates whether the given plugin type is expected (but not required) to produce a composable kind that implements this SchemaInterface.
type SimpleCustomMetadata ¶
SimpleCustomMetadata is an implementation of CustomMetadata
func (SimpleCustomMetadata) MapFields ¶
func (s SimpleCustomMetadata) MapFields() map[string]any
MapFields returns a map of string->value for all CustomMetadata fields
type SomeDef ¶
type SomeDef struct { // V is the cue.Value containing the entire Kind definition. V cue.Value // Properties contains the kind's declarative non-schema properties. Properties SomeKindProperties }
SomeDef represents a single kind definition, having been loaded and validated by a func such as [LoadCoreKindDef].
The underlying type of the Properties field indicates the category of kind.
func (SomeDef) BindKindLineage ¶
func (def SomeDef) BindKindLineage(rt *thema.Runtime, opts ...thema.BindOption) (thema.Lineage, error)
BindKindLineage binds the lineage for the kind definition.
For kinds with a corresponding Go type, it is left to the caller to associate that Go type with the lineage returned from this function by a call to thema.BindType.
func (SomeDef) IsComposable ¶
IsComposable indicates whether the represented kind is a composable kind.
type SomeKindProperties ¶
type SomeKindProperties interface { Common() CommonProperties // contains filtered or unexported methods }
SomeKindProperties is an interface type to abstract over the different kind property struct types: CoreProperties, CustomProperties, ComposableProperties.
It is the traditional interface counterpart to the generic type constraint KindProperties.
type StaticMetadata ¶
type StaticMetadata struct { Group string `json:"group"` Version string `json:"version"` Kind string `json:"kind"` Namespace string `json:"namespace"` Name string `json:"name"` }
StaticMetadata consists of all non-mutable metadata for an object. It is set in the initial Create call for an Resource, then will always remain the same.
func (StaticMetadata) FullIdentifier ¶
func (s StaticMetadata) FullIdentifier() FullIdentifier
FullIdentifier returns a FullIdentifier struct from the StaticMetadata. Plural cannot be inferred so is left empty.
func (StaticMetadata) Identifier ¶
func (s StaticMetadata) Identifier() Identifier
Identifier creates an Identifier struct from the StaticMetadata
type TypedCore ¶
type TypedCore[R Resource] interface { Core // TypeFromBytes is the same as [Core.FromBytes], but returns an instance of the // associated generic struct type instead of an [UnstructuredResource]. TypeFromBytes(b []byte, codec Decoder) (R, error) }
TypedCore is the statically typed runtime representation of a Grafana core kind definition. It is one in a family of interfaces, see Kind for context.
A TypedCore provides typed interactions with the Resource type given as its generic type parameter. As it embeds Core, untyped interaction is also available.
A TypedCore is created by calling BindCoreResource on a Core with a Go type to which it is assignable (see thema.BindType).
type TypedCustom ¶
type TypedCustom[R Resource] interface { Custom // TypeFromBytes is the same as [Custom.FromBytes], but returns an instance of the // associated generic struct type instead of an [UnstructuredResource]. TypeFromBytes(b []byte, codec Decoder) (R, error) }
TypedCustom is the statically typed runtime representation of a Grafana core kind definition. It is one in a family of interfaces, see Kind for context.
A TypedCustom provides typed interactions with the Resource type given as its generic type parameter. As it embeds Custom, untyped interaction is also available.
A TypedCustom is created by calling BindCustomResource on a Custom with a Go type to which it is assignable (see thema.BindType).
func BindCustomResource ¶
func BindCustomResource[R Resource](k Custom) (TypedCustom[R], error)
TODO docs
type UnmarshalConfig ¶
type UnmarshalConfig struct { // WireFormat is the wire format of the provided payload WireFormat WireFormat // VersionHint is what the client thinks the version is (if non-empty) VersionHint string }
UnmarshalConfig is the config used for unmarshaling Resources. It consists of fields that are descriptive of the underlying content, based on knowledge the caller has.
type UnstructuredResource ¶
type UnstructuredResource struct { BasicMetadataObject Spec map[string]any `json:"spec,omitempty"` Status map[string]any `json:"status,omitempty"` }
UnstructuredResource is an untyped representation of Resource. In the same way that map[string]any can represent any JSON []byte, UnstructuredResource can represent a Resource for any Core or Custom kind. But it is not strongly typed, and lacks any user-defined methods that may exist on a kind-specific struct that implements Resource.
func (*UnstructuredResource) Copy ¶
func (u *UnstructuredResource) Copy() Resource
func (*UnstructuredResource) SpecObject ¶
func (u *UnstructuredResource) SpecObject() any
func (*UnstructuredResource) Subresources ¶
func (u *UnstructuredResource) Subresources() map[string]any
type WireFormat ¶
type WireFormat int
WireFormat enumerates values for possible message wire formats. Constants with these values are in this package with a `WireFormat` prefix.
const ( // WireFormatUnknown is an unknown message wire format. WireFormatUnknown WireFormat = iota // WireFormatJSON is a JSON message wire format, which should be handle-able by the `json` package. // (messages which _contain_ JSON, but are not parsable by the go json package should not be // considered to be of the JSON wire format). WireFormatJSON )