Documentation ¶
Index ¶
- func AnnotateNamespace(ts *typesystem.ValidatedNamespaceTypeSystem) error
- func CheckNamespaceAndRelation(ctx context.Context, namespace string, relation string, allowEllipsis bool, ...) error
- func CheckNamespaceAndRelations(ctx context.Context, checks []TypeAndRelationToCheck, ds datastore.Reader) error
- func ListReferencedNamespaces(nsdefs []*core.NamespaceDefinition) []string
- func NewDuplicateRelationError(nsName string, relationName string) error
- func NewNamespaceNotFoundErr(nsName string) error
- func NewPermissionsCycleErr(nsName string, permissionNames []string) error
- func NewRelationNotFoundErr(nsName string, relationName string) error
- func NewUnusedCaveatParameterErr(caveatName string, paramName string) error
- func ReadNamespaceAndRelation(ctx context.Context, namespace string, relation string, ds datastore.Reader) (*core.NamespaceDefinition, *core.Relation, error)
- func ValidateCaveatDefinition(caveat *core.CaveatDefinition) error
- type ErrDuplicateRelation
- type ErrNamespaceNotFound
- type ErrPermissionsCycle
- type ErrRelationNotFound
- type ErrUnusedCaveatParameter
- type TypeAndRelationToCheck
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AnnotateNamespace ¶
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 ¶
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 ¶
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 ¶
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 ¶
NewDuplicateRelationError constructs an error indicating that a relation was defined more than once in a namespace.
func NewNamespaceNotFoundErr ¶
NewNamespaceNotFoundErr constructs a new namespace not found error.
func NewPermissionsCycleErr ¶
NewPermissionsCycleErr constructs an error indicating that a cycle exists amongst permissions.
func NewRelationNotFoundErr ¶
NewRelationNotFoundErr constructs a new relation not found error.
func NewUnusedCaveatParameterErr ¶
NewUnusedCaveatParameterErr constructs indicating that a parameter was unused in a caveat expression.
func ReadNamespaceAndRelation ¶
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 ValidateCaveatDefinition ¶
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 ¶
type ErrDuplicateRelation struct {
// contains filtered or unexported fields
}
ErrDuplicateRelation occurs when a duplicate relation was found inside a namespace.
func (ErrDuplicateRelation) DetailsMetadata ¶
func (err ErrDuplicateRelation) DetailsMetadata() map[string]string
DetailsMetadata returns the metadata for details for this error.
func (ErrDuplicateRelation) MarshalZerologObject ¶
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 ¶
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 ¶
type ErrPermissionsCycle struct {
// contains filtered or unexported fields
}
ErrPermissionsCycle occurs when a cycle exists within permissions.
func (ErrPermissionsCycle) DetailsMetadata ¶
func (err ErrPermissionsCycle) DetailsMetadata() map[string]string
DetailsMetadata returns the metadata for details for this error.
func (ErrPermissionsCycle) MarshalZerologObject ¶
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 ¶
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 ¶
type ErrUnusedCaveatParameter struct {
// contains filtered or unexported fields
}
ErrUnusedCaveatParameter indicates that a caveat parameter is unused in the caveat expression.
func (ErrUnusedCaveatParameter) DetailsMetadata ¶
func (err ErrUnusedCaveatParameter) DetailsMetadata() map[string]string
DetailsMetadata returns the metadata for details for this error.
func (ErrUnusedCaveatParameter) MarshalZerologObject ¶
func (err ErrUnusedCaveatParameter) MarshalZerologObject(e *zerolog.Event)
MarshalZerologObject implements zerolog object marshalling.
type TypeAndRelationToCheck ¶
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.