resource

package
v1.16.100 Latest Latest
Warning

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

Go to latest
Published: Aug 14, 2023 License: MPL-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissing                  = errors.New("missing required field")
	ErrEmpty                    = errors.New("cannot be empty")
	ErrReferenceTenancyNotEqual = errors.New("resource tenancy and reference tenancy differ")
)
View Source
var (
	TypeV1Tombstone = &pbresource.Type{
		Group:        "internal",
		GroupVersion: "v1",
		Kind:         "Tombstone",
	}
)

Functions

func EqualCondition

func EqualCondition(a, b *pbresource.Condition) bool

EqualCondition compares two conditions for equality without reflection.

func EqualID

func EqualID(a, b *pbresource.ID) bool

EqualType compares two resource IDs for equality without reflection.

func EqualReference

func EqualReference(a, b *pbresource.Reference) bool

EqualReference compares two references for equality without reflection.

func EqualStatus

func EqualStatus(a, b *pbresource.Status, compareUpdatedAt bool) bool

EqualStatus compares two statuses for equality without reflection.

Pass true for compareUpdatedAt to compare the UpdatedAt timestamps, which you generally *don't* want when dirty checking the status in a controller.

func EqualStatusMap

func EqualStatusMap(a, b map[string]*pbresource.Status) bool

EqualStatusMap compares two status maps for equality without reflection.

func EqualTenancy

func EqualTenancy(a, b *pbresource.Tenancy) bool

EqualType compares two resource tenancies for equality without reflection.

func EqualType

func EqualType(a, b *pbresource.Type) bool

EqualType compares two resource types for equality without reflection.

func Reference

func Reference(id *pbresource.ID, section string) *pbresource.Reference

Reference returns a reference to the resource with the given ID.

func ToGVK

func ToGVK(resourceType *pbresource.Type) string

Types

type ACLHooks

type ACLHooks struct {
	// Read is used to authorize Read RPCs and to filter results in List
	// RPCs.
	//
	// If it is omitted, `operator:read` permission is assumed.
	Read func(acl.Authorizer, *pbresource.ID) error

	// Write is used to authorize Write and Delete RPCs.
	//
	// If it is omitted, `operator:write` permission is assumed.
	Write func(acl.Authorizer, *pbresource.ID) error

	// List is used to authorize List RPCs.
	//
	// If it is omitted, we only filter the results using Read.
	List func(acl.Authorizer, *pbresource.Tenancy) error
}

type ErrDataParse

type ErrDataParse struct {
	TypeName string
	Wrapped  error
}

func NewErrDataParse

func NewErrDataParse(msg protoreflect.ProtoMessage, err error) ErrDataParse

func (ErrDataParse) Error

func (err ErrDataParse) Error() string

func (ErrDataParse) Unwrap

func (err ErrDataParse) Unwrap() error

type ErrInvalidField

type ErrInvalidField struct {
	Name    string
	Wrapped error
}

func (ErrInvalidField) Error

func (err ErrInvalidField) Error() string

func (ErrInvalidField) Unwrap

func (err ErrInvalidField) Unwrap() error

type ErrInvalidListElement

type ErrInvalidListElement struct {
	Name    string
	Index   int
	Wrapped error
}

func (ErrInvalidListElement) Error

func (err ErrInvalidListElement) Error() string

func (ErrInvalidListElement) Unwrap

func (err ErrInvalidListElement) Unwrap() error

type ErrInvalidMapKey

type ErrInvalidMapKey struct {
	Map     string
	Key     string
	Wrapped error
}

func (ErrInvalidMapKey) Error

func (err ErrInvalidMapKey) Error() string

func (ErrInvalidMapKey) Unwrap

func (err ErrInvalidMapKey) Unwrap() error

type ErrInvalidMapValue

type ErrInvalidMapValue struct {
	Map     string
	Key     string
	Wrapped error
}

func (ErrInvalidMapValue) Error

func (err ErrInvalidMapValue) Error() string

func (ErrInvalidMapValue) Unwrap

func (err ErrInvalidMapValue) Unwrap() error

type ErrInvalidReferenceType

type ErrInvalidReferenceType struct {
	AllowedType *pbresource.Type
}

func (ErrInvalidReferenceType) Error

func (err ErrInvalidReferenceType) Error() string

type ErrOwnerTenantInvalid

type ErrOwnerTenantInvalid struct {
	ResourceType    *pbresource.Type
	ResourceTenancy *pbresource.Tenancy
	OwnerTenancy    *pbresource.Tenancy
}

func (ErrOwnerTenantInvalid) Error

func (err ErrOwnerTenantInvalid) Error() string

type ErrOwnerTypeInvalid

type ErrOwnerTypeInvalid struct {
	ResourceType *pbresource.Type
	OwnerType    *pbresource.Type
}

func (ErrOwnerTypeInvalid) Error

func (err ErrOwnerTypeInvalid) Error() string

type Registration

type Registration struct {
	// Type is the GVK of the resource type.
	Type *pbresource.Type

	// Proto is the resource's protobuf message type.
	Proto proto.Message

	// ACLs are hooks called to perform authorization on RPCs.
	ACLs *ACLHooks

	// Validate is called to structurally validate the resource (e.g.
	// check for required fields).
	Validate func(*pbresource.Resource) error

	// Mutate is called to fill out any autogenerated fields (e.g. UUIDs).
	Mutate func(*pbresource.Resource) error
}

type Registry

type Registry interface {
	// Register the given resource type and its hooks.
	Register(reg Registration)

	// Resolve the given resource type and its hooks.
	Resolve(typ *pbresource.Type) (reg Registration, ok bool)
}

func NewRegistry

func NewRegistry() Registry

type TypeRegistry

type TypeRegistry struct {
	// contains filtered or unexported fields
}

Resource type registry

func (*TypeRegistry) Register

func (r *TypeRegistry) Register(registration Registration)

func (*TypeRegistry) Resolve

func (r *TypeRegistry) Resolve(typ *pbresource.Type) (reg Registration, ok bool)

Directories

Path Synopsis
Package demo includes fake resource types for working on Consul's generic state storage without having to refer to specific features.
Package demo includes fake resource types for working on Consul's generic state storage without having to refer to specific features.

Jump to

Keyboard shortcuts

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