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 ReadNamespaceAndTypes(ctx context.Context, nsName string, ds datastore.Reader) (*core.NamespaceDefinition, *typesystem.TypeSystem, error)
- func ValidateCaveatDefinition(caveat *core.CaveatDefinition) error
- type Delta
- type DeltaType
- type Diff
- 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 ¶ 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
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 ¶ added in v1.13.0
NewPermissionsCycleErr constructs an error indicating that a cycle exists amongst permissions.
func NewRelationNotFoundErr ¶
NewRelationNotFoundErr constructs a new relation not found error.
func NewUnusedCaveatParameterErr ¶ added in v1.14.0
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 Delta ¶
type Delta struct { // Type is the type of this delta. Type DeltaType // RelationName is the name of the relation to which this delta applies, if any. RelationName string // AllowedType is the allowed relation type added or removed, if any. AllowedType *core.AllowedRelation }
type DeltaType ¶
type DeltaType string
DeltaType defines the type of namespace deltas.
const ( // NamespaceAdded indicates that the namespace was newly added/created. NamespaceAdded DeltaType = "namespace-added" // NamespaceRemoved indicates that the namespace was removed. NamespaceRemoved DeltaType = "namespace-removed" // NamespaceCommentsChanged indicates that the comment(s) on the namespace were changed. NamespaceCommentsChanged DeltaType = "namespace-comments-changed" // AddedRelation indicates that the relation was added to the namespace. AddedRelation DeltaType = "added-relation" // RemovedRelation indicates that the relation was removed from the namespace. RemovedRelation DeltaType = "removed-relation" // AddedPermission indicates that the permission was added to the namespace. AddedPermission DeltaType = "added-permission" // RemovedPermission indicates that the permission was removed from the namespace. RemovedPermission DeltaType = "removed-permission" // ChangedPermissionImpl indicates that the implementation of the permission has changed in some // way. ChangedPermissionImpl DeltaType = "changed-permission-implementation" // ChangedPermissionComment indicates that the comment of the permission has changed in some way. ChangedPermissionComment DeltaType = "changed-permission-comment" // LegacyChangedRelationImpl indicates that the implementation of the relation has changed in some // way. This is for legacy checks and should not apply to any modern namespaces created // via schema. LegacyChangedRelationImpl DeltaType = "legacy-changed-relation-implementation" // RelationAllowedTypeAdded indicates that an allowed relation type has been added to // the relation. RelationAllowedTypeAdded DeltaType = "relation-allowed-type-added" // RelationAllowedTypeRemoved indicates that an allowed relation type has been removed from // the relation. RelationAllowedTypeRemoved DeltaType = "relation-allowed-type-removed" // ChangedRelationComment indicates that the comment of the relation has changed in some way. ChangedRelationComment DeltaType = "changed-relation-comment" )
type Diff ¶ added in v1.7.0
type Diff struct {
// contains filtered or unexported fields
}
Diff holds the diff between two namespaces.
func DiffNamespaces ¶
func DiffNamespaces(existing *core.NamespaceDefinition, updated *core.NamespaceDefinition) (*Diff, error)
DiffNamespaces performs a diff between two namespace definitions. One or both of the definitions can be `nil`, which will be treated as an add/remove as applicable.
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.