namespace

package
v1.29.0 Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2024 License: Apache-2.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AnnotateNamespace added in v1.7.0

func AnnotateNamespace(ts *typesystem.ValidatedNamespaceTypeSystem) error

AnnotateNamespace annotates the namespace in the type system with computed aliasing and cache key metadata for more efficient dispatching.

func CheckNamespaceAndRelation added in v1.8.0

func CheckNamespaceAndRelation(
	ctx context.Context,
	namespace string,
	relation string,
	allowEllipsis bool,
	ds datastore.Reader,
) error

CheckNamespaceAndRelation checks that the specified namespace and relation exist in the datastore.

Returns datastore.ErrNamespaceNotFound if the namespace cannot be found. Returns ErrRelationNotFound if the relation was not found in the namespace. Returns the direct downstream error for all other unknown error.

func CheckNamespaceAndRelations added in v1.22.0

func CheckNamespaceAndRelations(ctx context.Context, checks []TypeAndRelationToCheck, ds datastore.Reader) error

CheckNamespaceAndRelations ensures that the given namespace+relation checks all succeed. If any fail, returns an error.

Returns ErrNamespaceNotFound if the namespace cannot be found. Returns ErrRelationNotFound if the relation was not found in the namespace. Returns the direct downstream error for all other unknown error.

func ListReferencedNamespaces added in v1.12.0

func ListReferencedNamespaces(nsdefs []*core.NamespaceDefinition) []string

ListReferencedNamespaces returns the names of all namespaces referenced in the given namespace definitions. This includes the namespaces themselves, as well as any found in type information on relations.

func NewDuplicateRelationError added in v1.13.0

func NewDuplicateRelationError(nsName string, relationName string) error

NewDuplicateRelationError constructs an error indicating that a relation was defined more than once in a namespace.

func NewNamespaceNotFoundErr

func NewNamespaceNotFoundErr(nsName string) error

NewNamespaceNotFoundErr constructs a new namespace not found error.

func NewPermissionsCycleErr added in v1.13.0

func NewPermissionsCycleErr(nsName string, permissionNames []string) error

NewPermissionsCycleErr constructs an error indicating that a cycle exists amongst permissions.

func NewRelationNotFoundErr

func NewRelationNotFoundErr(nsName string, relationName string) error

NewRelationNotFoundErr constructs a new relation not found error.

func NewUnusedCaveatParameterErr added in v1.14.0

func NewUnusedCaveatParameterErr(caveatName string, paramName string) error

NewUnusedCaveatParameterErr constructs indicating that a parameter was unused in a caveat expression.

func ReadNamespaceAndRelation added in v1.8.0

func ReadNamespaceAndRelation(
	ctx context.Context,
	namespace string,
	relation string,
	ds datastore.Reader,
) (*core.NamespaceDefinition, *core.Relation, error)

ReadNamespaceAndRelation checks that the specified namespace and relation exist in the datastore.

Returns ErrNamespaceNotFound if the namespace cannot be found. Returns ErrRelationNotFound if the relation was not found in the namespace. Returns the direct downstream error for all other unknown error.

func ReadNamespaceAndTypes added in v1.8.0

func ReadNamespaceAndTypes(
	ctx context.Context,
	nsName string,
	ds datastore.Reader,
) (*core.NamespaceDefinition, *typesystem.TypeSystem, error)

ReadNamespaceAndTypes reads a namespace definition, version, and type system and returns it if found.

func ValidateCaveatDefinition added in v1.14.0

func ValidateCaveatDefinition(caveat *core.CaveatDefinition) error

ValidateCaveatDefinition validates the parameters and types within the given caveat definition, including usage of the parameters.

Types

type ErrDuplicateRelation added in v1.13.0

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

ErrDuplicateRelation occurs when a duplicate relation was found inside a namespace.

func (ErrDuplicateRelation) DetailsMetadata added in v1.14.0

func (err ErrDuplicateRelation) DetailsMetadata() map[string]string

DetailsMetadata returns the metadata for details for this error.

func (ErrDuplicateRelation) MarshalZerologObject added in v1.13.0

func (err ErrDuplicateRelation) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements zerolog object marshalling.

type ErrNamespaceNotFound

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

ErrNamespaceNotFound occurs when a namespace was not found.

func (ErrNamespaceNotFound) DetailsMetadata added in v1.14.0

func (err ErrNamespaceNotFound) DetailsMetadata() map[string]string

DetailsMetadata returns the metadata for details for this error.

func (ErrNamespaceNotFound) MarshalZerologObject

func (err ErrNamespaceNotFound) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements zerolog object marshalling.

func (ErrNamespaceNotFound) NotFoundNamespaceName

func (err ErrNamespaceNotFound) NotFoundNamespaceName() string

NotFoundNamespaceName is the name of the namespace not found.

type ErrPermissionsCycle added in v1.13.0

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

ErrPermissionsCycle occurs when a cycle exists within permissions.

func (ErrPermissionsCycle) DetailsMetadata added in v1.14.0

func (err ErrPermissionsCycle) DetailsMetadata() map[string]string

DetailsMetadata returns the metadata for details for this error.

func (ErrPermissionsCycle) MarshalZerologObject added in v1.13.0

func (err ErrPermissionsCycle) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements zerolog object marshalling.

type ErrRelationNotFound

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

ErrRelationNotFound occurs when a relation was not found under a namespace.

func (ErrRelationNotFound) DetailsMetadata added in v1.14.0

func (err ErrRelationNotFound) DetailsMetadata() map[string]string

DetailsMetadata returns the metadata for details for this error.

func (ErrRelationNotFound) MarshalZerologObject

func (err ErrRelationNotFound) MarshalZerologObject(e *zerolog.Event)

func (ErrRelationNotFound) NamespaceName

func (err ErrRelationNotFound) NamespaceName() string

NamespaceName returns the name of the namespace in which the relation was not found.

func (ErrRelationNotFound) NotFoundRelationName

func (err ErrRelationNotFound) NotFoundRelationName() string

NotFoundRelationName returns the name of the relation not found.

type ErrUnusedCaveatParameter added in v1.14.0

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

ErrUnusedCaveatParameter indicates that a caveat parameter is unused in the caveat expression.

func (ErrUnusedCaveatParameter) DetailsMetadata added in v1.14.0

func (err ErrUnusedCaveatParameter) DetailsMetadata() map[string]string

DetailsMetadata returns the metadata for details for this error.

func (ErrUnusedCaveatParameter) MarshalZerologObject added in v1.14.0

func (err ErrUnusedCaveatParameter) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements zerolog object marshalling.

type TypeAndRelationToCheck added in v1.22.0

type TypeAndRelationToCheck struct {
	// NamespaceName is the namespace name to ensure exists.
	NamespaceName string

	// RelationName is the relation name to ensure exists under the namespace.
	RelationName string

	// AllowEllipsis, if true, allows for the ellipsis as the RelationName.
	AllowEllipsis bool
}

TypeAndRelationToCheck is a single check of a namespace+relation pair.

Jump to

Keyboard shortcuts

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