Documentation ¶
Overview ¶
Package namespaced provides an implementation of state split by namespaces.
Index ¶
- type State
- func (st *State) Create(ctx context.Context, res resource.Resource, opts ...state.CreateOption) error
- func (st *State) Destroy(ctx context.Context, ptr resource.Pointer, opts ...state.DestroyOption) error
- func (st *State) Get(ctx context.Context, ptr resource.Pointer, opts ...state.GetOption) (resource.Resource, error)
- func (st *State) List(ctx context.Context, kind resource.Kind, opts ...state.ListOption) (resource.List, error)
- func (st *State) Update(ctx context.Context, newResource resource.Resource, opts ...state.UpdateOption) error
- func (st *State) Watch(ctx context.Context, ptr resource.Pointer, ch chan<- state.Event, ...) error
- func (st *State) WatchKind(ctx context.Context, kind resource.Kind, ch chan<- state.Event, ...) error
- func (st *State) WatchKindAggregated(ctx context.Context, kind resource.Kind, ch chan<- []state.Event, ...) error
- type StateBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type State ¶
type State struct {
// contains filtered or unexported fields
}
State implements delegating State for each namespace.
func NewState ¶
func NewState(builder StateBuilder) *State
NewState initializes new namespaced State.
func (*State) Create ¶
func (st *State) Create(ctx context.Context, res resource.Resource, opts ...state.CreateOption) error
Create a resource.
If a resource already exists, Create returns an error.
func (*State) Destroy ¶
func (st *State) Destroy(ctx context.Context, ptr resource.Pointer, opts ...state.DestroyOption) error
Destroy a resource.
If a resource doesn't exist, error is returned.
func (*State) Get ¶
func (st *State) Get(ctx context.Context, ptr resource.Pointer, opts ...state.GetOption) (resource.Resource, error)
Get a resource by type and ID.
If a resource is not found, error is returned.
func (*State) List ¶
func (st *State) List(ctx context.Context, kind resource.Kind, opts ...state.ListOption) (resource.List, error)
List resources by kind.
func (*State) Update ¶
func (st *State) Update(ctx context.Context, newResource resource.Resource, opts ...state.UpdateOption) error
Update a resource.
If a resource doesn't exist, error is returned. On update current version of resource `new` in the state should match the version on the backend, otherwise conflict error is returned.
func (*State) Watch ¶
func (st *State) Watch(ctx context.Context, ptr resource.Pointer, ch chan<- state.Event, opts ...state.WatchOption) error
Watch state of a resource by type.
It's fine to watch for a resource which doesn't exist yet. Watch is canceled when context gets canceled. Watch sends initial resource state as the very first event on the channel, and then sends any updates to the resource as events.