Documentation
¶
Overview ¶
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, The Zip API Object Framework Authors and Unikraft GmbH. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, The Zip API Object Framework Authors and Unikraft GmbH. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
Package api.zip enables Kubernetes-inspired objects without the hassle of code generation.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, The Zip API Object Framework Authors and Unikraft GmbH. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, The Zip API Object Framework Authors and Unikraft GmbH. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, The Zip API Object Framework Authors and Unikraft GmbH. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, The Zip API Object Framework Authors and Unikraft GmbH. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, The Zip API Object Framework Authors and Unikraft GmbH. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
SPDX-License-Identifier: BSD-3-Clause Copyright (c) 2022, The Zip API Object Framework Authors and Unikraft GmbH. Licensed under the BSD-3-Clause License (the "License"). You may not use this file except in compliance with the License.
Index ¶
- Constants
- Variables
- func Register(schemes ...AddToScheme) error
- type AddToScheme
- type ClientConfig
- type ClientOption
- type Method
- type MethodClient
- type MethodStrategy
- type Object
- func (in *Object[Spec, Status]) DeepCopy() *Object[Spec, Status]
- func (in *Object[Spec, Status]) DeepCopyInto(out *Object[Spec, Status])
- func (in Object[_, _]) DeepCopyObject() runtime.Object
- func (obj *Object[_, _]) GetObjectKind() schema.ObjectKind
- func (obj *Object[_, _]) GroupVersionKind() schema.GroupVersionKind
- func (obj *Object[_, _]) Reference() (string, error)
- func (obj *Object[_, _]) SetGroupVersionKind(gvk schema.GroupVersionKind)
- type ObjectList
- func (list *ObjectList[Spec, Status]) DeepCopy() *ObjectList[Spec, Status]
- func (in *ObjectList[Spec, Status]) DeepCopyInto(out *ObjectList[Spec, Status])
- func (list *ObjectList[_, _]) DeepCopyObject() runtime.Object
- func (list *ObjectList[_, _]) GetObjectKind() schema.ObjectKind
- func (list *ObjectList[_, _]) GroupVersionKind() schema.GroupVersionKind
- func (list *ObjectList[_, _]) Reference() (string, error)
- func (list *ObjectList[_, _]) SetGroupVersionKind(gvk schema.GroupVersionKind)
- type OnAfter
- type OnBefore
- type Referencable
- type ReferenceObject
- type Store
- type StoreRehydrationMode
- type Stream
- type StreamClient
- type StreamStrategy
Constants ¶
const ( // Always rehydrate the reference object StoreRehydrationAlways = StoreRehydrationMode("always") // Only rehydratae the reference object when its Spec is nil StoreRehydrationSpecNil = StoreRehydrationMode("specnil") // Never rehydrate the reference object StoreRehydrationNever = StoreRehydrationMode("never") )
Variables ¶
var ( Schemes = runtime.NewScheme() Codecs = serializer.NewCodecFactory(Schemes) ParameterCodec = runtime.NewParameterCodec(Schemes) )
Functions ¶
func Register ¶ added in v0.1.1
func Register(schemes ...AddToScheme) error
Register accepts a slice of AddToScheme methods which are then registered against the list of global schemes.
Types ¶
type AddToScheme ¶ added in v0.1.1
AddToScheme is a prototype to describe the method which can be used to append a new scheme to the list of global schemes.
type ClientConfig ¶
type ClientConfig struct {
// contains filtered or unexported fields
}
ClientConfig contains configuration which is passed to a Zip API client.
type ClientOption ¶
type ClientOption func(*ClientConfig) error
ClientOption is a Zip API client config option-method handler.
func WithAfter ¶ added in v0.1.1
func WithAfter(after ...OnAfter) ClientOption
WithAfter provides post-call functions which manipulate the outbound object after the client has invoked its method strategy.
func WithBefore ¶ added in v0.1.1
func WithBefore(before ...OnBefore) ClientOption
WithBefore provides pre-call functions which manipulate the inbound object before the client invokes its method strategy.
func WithStore ¶
func WithStore[Spec, Status any](store Store, mode StoreRehydrationMode) ClientOption
WithStore sets the Abstract client's store to the specified interface implementation. An additional positional argument for the rehydration mode is used to configure when the store on the before call is used and how it manipulates the value of the reference object.
type Method ¶
type Method[In, Out ReferenceObject] func(context.Context, In) (Out, error)
Method represents a generic API function call.
type MethodClient ¶
type MethodClient[In, Out ReferenceObject] struct { // contains filtered or unexported fields }
MethodClient is the generic Zip API client.
type MethodStrategy ¶
type MethodStrategy[In, Out ReferenceObject] interface { // Do performs the request by invoking the provided generic Method. Do(context.Context, In) (Out, error) }
MethodStrategy is a generic method handler which standardizes implementation of a client such that the action performed on a specific endpoint for a given input type In which returns a known output type Out is consistently implemented.
func NewMethodClient ¶
func NewMethodClient[In, Out ReferenceObject]( ctx context.Context, fn Method[In, Out], opts ...ClientOption, ) ( MethodStrategy[In, Out], error, )
NewMethodClient instantiates a new Zip API method client.
type Object ¶
type Object[Spec, Status any] struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. metav1.ObjectMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // Specification of the desired behavior of the Object. Spec Spec `json:"spec,omitempty" protobuf:"bytes,2,opt,name=spec"` // Most recently observed status of the Object. Status Status `json:"status,omitempty" protobuf:"bytes,3,opt,name=status"` }
Object represents a generic low-level Kubernetes-inspired object which contains information about the object type, its metadata, a specification which is used to describe the object and its current status.
func (*Object[Spec, Status]) DeepCopyInto ¶
DeepCopyInto is a deepcopy function, copying the receiver, writing into out.
func (Object[_, _]) DeepCopyObject ¶
DeepCopyObject implements runtime.Object.
func (*Object[_, _]) GetObjectKind ¶
func (obj *Object[_, _]) GetObjectKind() schema.ObjectKind
GetObjectKind implements runtime.Object.
func (*Object[_, _]) GroupVersionKind ¶
func (obj *Object[_, _]) GroupVersionKind() schema.GroupVersionKind
GroupVersionKind returns the API version and kind of the object reference.
func (*Object[_, _]) SetGroupVersionKind ¶
func (obj *Object[_, _]) SetGroupVersionKind(gvk schema.GroupVersionKind)
SetGroupVersionKind sets the API version and kind of the object reference.
type ObjectList ¶
type ObjectList[Spec, Status any] struct { metav1.TypeMeta `json:",inline"` // Standard object's metadata. metav1.ListMeta `json:"metadata,omitempty" protobuf:"bytes,1,opt,name=metadata"` // Items contains the list of machines. Items []Object[Spec, Status] `json:"items" protobuf:"bytes,2,rep,name=items"` }
ObjectList represents a list of Objects.
func (*ObjectList[Spec, Status]) DeepCopy ¶
func (list *ObjectList[Spec, Status]) DeepCopy() *ObjectList[Spec, Status]
DeepCopy copies the receiver, creating a new ObjectList.
func (*ObjectList[Spec, Status]) DeepCopyInto ¶
func (in *ObjectList[Spec, Status]) DeepCopyInto(out *ObjectList[Spec, Status])
DeepCopyInto copies the receiver, writing into out. in must be non-nil.
func (*ObjectList[_, _]) DeepCopyObject ¶
func (list *ObjectList[_, _]) DeepCopyObject() runtime.Object
DeepCopyObject implements runtime.Object.
func (*ObjectList[_, _]) GetObjectKind ¶
func (list *ObjectList[_, _]) GetObjectKind() schema.ObjectKind
GetObjectKind implements runtime.Object.
func (*ObjectList[_, _]) GroupVersionKind ¶
func (list *ObjectList[_, _]) GroupVersionKind() schema.GroupVersionKind
GroupVersionKind returns the API version and kind of the object reference
func (*ObjectList[_, _]) Reference ¶
func (list *ObjectList[_, _]) Reference() (string, error)
Reference implements Referencable.
func (*ObjectList[_, _]) SetGroupVersionKind ¶
func (list *ObjectList[_, _]) SetGroupVersionKind(gvk schema.GroupVersionKind)
SetGroupVersionKind sets the API version and kind of the object reference
type OnAfter ¶
type OnAfter func(context.Context, ReferenceObject, ReferenceObject) (any, error)
OnAfter is a prototype for a function that can be called on a referencable object after it has been returned by the client.
type OnBefore ¶
type OnBefore func(context.Context, ReferenceObject) (any, error)
OnBefore is a prototype for a function that can be called on a referencable object before it is invoked by the client.
type Referencable ¶
Referencable is an interface for allowing the object to return a unique reference for lookups.
type ReferenceObject ¶
type ReferenceObject interface { Referencable runtime.Object }
ReferenceObject combines the low-level Kubernetes-centric runtime.Object and the Zip API Referencable to allow mutable, copyable objects to be referenced at runtime.
type StoreRehydrationMode ¶ added in v0.1.2
type StoreRehydrationMode string
StoreRehydrationMode is a switch that dictates how the store's before call is used to manipulate the
type StreamClient ¶
type StreamClient[In ReferenceObject, Out any] struct { // contains filtered or unexported fields }
StreamClient provides the interface for connecting to a remote service which returns a stream.
type StreamStrategy ¶
type StreamStrategy[In ReferenceObject, Out any] interface { // Channel performs the request with the provide input In and returns a // channel which allows returning a stream of content. Any issues from the // stream itself will be propagated back through the error channel. // Initialization errors are returned through the standard error. Channel(context.Context, In) (chan Out, chan error, error) }
StreamMethodStrategy is a generic handler which standardizes the implementation of a streaming client which performs actions on an input In which resolves to a stream (implemented as a Go channel) Out.
func NewStreamClient ¶
func NewStreamClient[In ReferenceObject, Out any]( ctx context.Context, fn Stream[In, Out], opts ...ClientOption, ) ( StreamStrategy[In, Out], error, )
NewStreamClient instantiates a new stream-enable client for the given stream provider.