owned

package
v1.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2026 License: MPL-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package owned contains the wrapping state for enforcing ownership.

Index

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

type ModifyOptions struct {
	ExpectedPhase *resource.Phase
	WithNoOwner   bool
}

ModifyOptions for operation Modify.

func ToModifyOptions

func ToModifyOptions(opts ...ModifyOption) ModifyOptions

ToModifyOptions converts variadic options to ModifyOptions.

type Reader

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

type ReaderWriter interface {
	Reader
	Writer
}

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 New

func New(state state.State, owner string) *State

New creates a new state which enforces ownership of resources.

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

func (st *State) Create(ctx context.Context, res resource.Resource, options ...CreateOption) error

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.

func (*State) Teardown

func (st *State) Teardown(ctx context.Context, resourcePointer resource.Pointer, opOpts ...DeleteOption) (bool, error)

Teardown tears down a resource in the state.

Teardown enforces that the resource is owned by the designated owner.

func (*State) Update

func (st *State) Update(ctx context.Context, res resource.Resource) error

Update updates a resource in the state.

Update enforces that the resource is owned by the designated owner.

type Writer

Writer provides write access to the state.

Write methods enforce that the resources are owned by the designated owner.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL