Documentation ¶
Overview ¶
Package safe provides a safe wrappers around the cosi runtime.
Index ¶
- func ReaderGet[T resource.Resource](ctx context.Context, rdr controller.Reader, ptr resource.Pointer) (T, error)
- func ReaderWatchFor[T resource.Resource](ctx context.Context, rdr controller.Reader, ptr resource.Pointer, ...) (T, error)
- func ReaderWatchForResource[T resource.Resource](ctx context.Context, rdr controller.Reader, r T, ...) (T, error)
- func StateGet[T resource.Resource](ctx context.Context, st state.State, ptr resource.Pointer, ...) (T, error)
- func StateGetResource[T resource.Resource](ctx context.Context, st state.State, r T, options ...state.GetOption) (T, error)
- func StateUpdateWithConflicts[T resource.Resource](ctx context.Context, st state.State, ptr resource.Pointer, ...) (T, error)
- func StateWatch[T resource.Resource](ctx context.Context, st state.State, ptr resource.Pointer, ...) error
- func StateWatchFor[T resource.Resource](ctx context.Context, st state.State, ptr resource.Pointer, ...) (T, error)
- func StateWatchKind[T resource.Resource](ctx context.Context, st state.State, kind resource.Kind, ...) error
- func WriterModify[T resource.Resource](ctx context.Context, writer controller.Writer, r T, fn func(T) error) error
- type List
- type ListIterator
- type WrappedStateEvent
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ReaderGet ¶
func ReaderGet[T resource.Resource](ctx context.Context, rdr controller.Reader, ptr resource.Pointer) (T, error)
ReaderGet is a type safe wrapper around reader.Get.
func ReaderWatchFor ¶
func ReaderWatchFor[T resource.Resource](ctx context.Context, rdr controller.Reader, ptr resource.Pointer, conds ...state.WatchForConditionFunc) (T, error)
ReaderWatchFor is a type safe wrapper around Reader.WatchFor.
func ReaderWatchForResource ¶
func ReaderWatchForResource[T resource.Resource](ctx context.Context, rdr controller.Reader, r T, conds ...state.WatchForConditionFunc) (T, error)
ReaderWatchForResource is a type safe wrapper around Reader.WatchFor which accepts typed resource.Resource and gets the metadata from it.
func StateGet ¶
func StateGet[T resource.Resource](ctx context.Context, st state.State, ptr resource.Pointer, options ...state.GetOption) (T, error)
StateGet is a type safe wrapper around state.Get.
func StateGetResource ¶
func StateGetResource[T resource.Resource](ctx context.Context, st state.State, r T, options ...state.GetOption) (T, error)
StateGetResource is a type safe wrapper around state.Get which accepts typed resource.Resource and gets the metadata from it.
func StateUpdateWithConflicts ¶
func StateUpdateWithConflicts[T resource.Resource](ctx context.Context, st state.State, ptr resource.Pointer, updateFn func(T) error, options ...state.UpdateOption) (T, error)
StateUpdateWithConflicts is a type safe wrapper around state.UpdateWithConflicts.
func StateWatch ¶
func StateWatch[T resource.Resource](ctx context.Context, st state.State, ptr resource.Pointer, eventCh chan<- WrappedStateEvent[T], opts ...state.WatchOption) error
StateWatch is a type safe wrapper around State.Watch.
func StateWatchFor ¶
func StateWatchFor[T resource.Resource](ctx context.Context, st state.State, ptr resource.Pointer, opts ...state.WatchForConditionFunc) (T, error)
StateWatchFor is a type safe wrapper around State.WatchFor.
func StateWatchKind ¶
func StateWatchKind[T resource.Resource](ctx context.Context, st state.State, kind resource.Kind, eventCh chan<- WrappedStateEvent[T], opts ...state.WatchKindOption) error
StateWatchKind is a type safe wrapper around State.WatchKind.
func WriterModify ¶
func WriterModify[T resource.Resource](ctx context.Context, writer controller.Writer, r T, fn func(T) error) error
WriterModify is a type safe wrapper around writer.Modify.
Types ¶
type List ¶
type List[T any] struct { // contains filtered or unexported fields }
List is a type safe wrapper around resource.List.
func ReaderList ¶
func ReaderList[T resource.Resource](ctx context.Context, rdr controller.Reader, kind resource.Kind, opts ...state.ListOption) (List[T], error)
ReaderList is a type safe wrapper around Reader.List.
type ListIterator ¶
type ListIterator[T any] struct { // contains filtered or unexported fields }
ListIterator is a generic iterator over resource.Resource slice.
func IteratorFromList ¶
func IteratorFromList[T any](list List[T]) ListIterator[T]
IteratorFromList returns a new iterator over the given list.
func (*ListIterator[T]) Next ¶
func (it *ListIterator[T]) Next() bool
Next returns the next element of the iterator.
func (*ListIterator[T]) Value ¶
func (it *ListIterator[T]) Value() T
Value returns the current element of the iterator.
type WrappedStateEvent ¶
WrappedStateEvent holds a state.Event that can be cast to its original Resource type when accessed with Event().
func (*WrappedStateEvent[T]) Error ¶ added in v0.2.0
func (wse *WrappedStateEvent[T]) Error() error
Error returns the error of wrapped event.
func (*WrappedStateEvent[T]) Old ¶
func (wse *WrappedStateEvent[T]) Old() (T, error)
Old returns the typed Old resource of the wrapped event.
func (*WrappedStateEvent[T]) Resource ¶
func (wse *WrappedStateEvent[T]) Resource() (T, error)
Resource returns the typed resource of the wrapped event.
func (*WrappedStateEvent[T]) Type ¶
func (wse *WrappedStateEvent[T]) Type() state.EventType
Type returns the EventType of the wrapped event.