Documentation
¶
Overview ¶
Package owned contains the wrapping state for enforcing ownership.
Index ¶
- type CreateOption
- type CreateOptions
- type DeleteOption
- type DeleteOptions
- type ModifyOption
- type ModifyOptions
- type Reader
- type ReaderWriter
- type State
- func (st *State) AddFinalizer(ctx context.Context, ptr resource.Pointer, finalizers ...resource.Finalizer) error
- func (st *State) ContextWithTeardown(ctx context.Context, ptr resource.Pointer) (context.Context, error)
- func (st *State) Create(ctx context.Context, res resource.Resource, options ...CreateOption) error
- func (st *State) Destroy(ctx context.Context, resourcePointer resource.Pointer, opOpts ...DeleteOption) 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) Modify(ctx context.Context, emptyResource resource.Resource, ...) error
- func (st *State) ModifyWithResult(ctx context.Context, emptyResource resource.Resource, ...) (resource.Resource, error)
- func (st *State) RemoveFinalizer(ctx context.Context, ptr resource.Pointer, finalizers ...resource.Finalizer) error
- func (st *State) Teardown(ctx context.Context, resourcePointer resource.Pointer, opOpts ...DeleteOption) (bool, error)
- func (st *State) Update(ctx context.Context, res resource.Resource) error
- type Writer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateOption ¶ added in v1.13.0
type CreateOption func(*CreateOptions)
CreateOption for operation Create.
func WithCreateNoOwner ¶ added in v1.13.0
func WithCreateNoOwner() CreateOption
WithCreateNoOwner creates the resource without setting the owner.
type CreateOptions ¶ added in v1.13.0
type CreateOptions struct {
WithNoOwner bool
}
CreateOptions for operation Create.
type DeleteOption ¶
type DeleteOption func(*DeleteOptions)
DeleteOption for operation Teardown/Destroy.
func WithOwner ¶
func WithOwner(owner string) DeleteOption
WithOwner allows to specify owner of the resource.
type DeleteOptions ¶
type DeleteOptions struct {
Owner *string
}
DeleteOptions for operation Teardown/Destroy.
func ToDeleteOptions ¶
func ToDeleteOptions(opts ...DeleteOption) DeleteOptions
ToDeleteOptions converts variadic options to DeleteOptions.
type ModifyOption ¶
type ModifyOption func(*ModifyOptions)
ModifyOption for operation Modify.
func WithExpectedPhase ¶
func WithExpectedPhase(phase resource.Phase) ModifyOption
WithExpectedPhase allows to specify expected phase of the resource.
func WithExpectedPhaseAny ¶
func WithExpectedPhaseAny() ModifyOption
WithExpectedPhaseAny allows to specify any phase of the resource.
func WithModifyNoOwner ¶ added in v1.13.0
func WithModifyNoOwner() ModifyOption
WithModifyNoOwner creates/updates the resource without setting the owner.
type ModifyOptions ¶
ModifyOptions for operation Modify.
func ToModifyOptions ¶
func ToModifyOptions(opts ...ModifyOption) ModifyOptions
ToModifyOptions converts variadic options to ModifyOptions.
type Reader ¶
type Reader interface {
Get(context.Context, resource.Pointer, ...state.GetOption) (resource.Resource, error)
List(context.Context, resource.Kind, ...state.ListOption) (resource.List, error)
ContextWithTeardown(context.Context, resource.Pointer) (context.Context, error)
}
Reader provides read-only access to the state.
Is is identical to the state.State interface, and it does not provide any additional methods.
type ReaderWriter ¶
ReaderWriter combines Reader and Writer interfaces.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State enforces ownership of resources which are being created/modified via the state.
func (*State) AddFinalizer ¶
func (st *State) AddFinalizer(ctx context.Context, ptr resource.Pointer, finalizers ...resource.Finalizer) error
AddFinalizer adds finalizers to the resource.
func (*State) ContextWithTeardown ¶
func (st *State) ContextWithTeardown(ctx context.Context, ptr resource.Pointer) (context.Context, error)
ContextWithTeardown is passthrough to the underlying state.
func (*State) Create ¶
Create creates a resource in the state.
Create enforces that the resource is owned by the designated owner.
func (*State) Destroy ¶
func (st *State) Destroy(ctx context.Context, resourcePointer resource.Pointer, opOpts ...DeleteOption) error
Destroy destroys a resource in the state.
Destroy enforces that the resource is owned by the designated owner.
func (*State) Get ¶
func (st *State) Get(ctx context.Context, ptr resource.Pointer, opts ...state.GetOption) (resource.Resource, error)
Get is passthrough to the underlying state.
func (*State) List ¶
func (st *State) List(ctx context.Context, kind resource.Kind, opts ...state.ListOption) (resource.List, error)
List is passthrough to the underlying state.
func (*State) Modify ¶
func (st *State) Modify(ctx context.Context, emptyResource resource.Resource, updateFunc func(resource.Resource) error, options ...ModifyOption) error
Modify modifies a resource in the state.
Modify enforces that the resource is owned by the designated owner.
func (*State) ModifyWithResult ¶
func (st *State) ModifyWithResult(ctx context.Context, emptyResource resource.Resource, updateFunc func(resource.Resource) error, options ...ModifyOption) (resource.Resource, error)
ModifyWithResult modifies a resource in the state and returns the modified resource.
ModifyWithResult enforces that the resource is owned by the designated owner.
func (*State) RemoveFinalizer ¶
func (st *State) RemoveFinalizer(ctx context.Context, ptr resource.Pointer, finalizers ...resource.Finalizer) error
RemoveFinalizer removes finalizers from the resource.
type Writer ¶
type Writer interface {
Create(context.Context, resource.Resource, ...CreateOption) error
Update(context.Context, resource.Resource) error
Modify(context.Context, resource.Resource, func(resource.Resource) error, ...ModifyOption) error
ModifyWithResult(context.Context, resource.Resource, func(resource.Resource) error, ...ModifyOption) (resource.Resource, error)
Teardown(context.Context, resource.Pointer, ...DeleteOption) (bool, error)
Destroy(context.Context, resource.Pointer, ...DeleteOption) error
AddFinalizer(context.Context, resource.Pointer, ...resource.Finalizer) error
RemoveFinalizer(context.Context, resource.Pointer, ...resource.Finalizer) error
}
Writer provides write access to the state.
Write methods enforce that the resources are owned by the designated owner.