hooks

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAddDirectGroup

func NewAddDirectGroup(c tree.RefContext) (tree.EntityHook, error)

NewAddDirectGroup returns a DirectGroupManager initialized in add mode.

func NewAddEntityKey

func NewAddEntityKey(c tree.RefContext) (tree.EntityHook, error)

NewAddEntityKey returns a hook initialized for adding keys.

func NewAddEntityUM

func NewAddEntityUM(c tree.RefContext) (tree.EntityHook, error)

NewAddEntityUM returns a configured hook in UPSERT mode.

func NewAddGroupUM

func NewAddGroupUM(c tree.RefContext) (tree.GroupHook, error)

NewAddGroupUM returns a configured hook in UPSERT mode.

func NewCheckExpansionCycles

func NewCheckExpansionCycles(c tree.RefContext) (tree.GroupHook, error)

NewCheckExpansionCycles returns a configured hook ready for use.

func NewCheckExpansionTargets

func NewCheckExpansionTargets(c tree.RefContext) (tree.GroupHook, error)

NewCheckExpansionTargets returns a configured hook, ready for use.

func NewCheckImmediateExpansions

func NewCheckImmediateExpansions(c tree.RefContext) (tree.GroupHook, error)

NewCheckImmediateExpansions returns a configured hook for use.

func NewCreateEntityIfMissing

func NewCreateEntityIfMissing(c tree.RefContext) (tree.EntityHook, error)

NewCreateEntityIfMissing returns an initalized hook for use during tree initialization.

func NewDelDirectGroup

func NewDelDirectGroup(c tree.RefContext) (tree.EntityHook, error)

NewDelDirectGroup returns a DirectGroupManager initialized in delete mode.

func NewDelEntityKey

func NewDelEntityKey(c tree.RefContext) (tree.EntityHook, error)

NewDelEntityKey returns a hook initialized for removing keys.

func NewDelExactEntityUM

func NewDelExactEntityUM(c tree.RefContext) (tree.EntityHook, error)

NewDelExactEntityUM returns a configured hook in CLEAREXACT mode.

func NewDelExactGroupUM

func NewDelExactGroupUM(c tree.RefContext) (tree.GroupHook, error)

NewDelExactGroupUM returns a configured hook in CLEAREXACT mode.

func NewDelFuzzyEntityUM

func NewDelFuzzyEntityUM(c tree.RefContext) (tree.EntityHook, error)

NewDelFuzzyEntityUM returns a configured hook in CLEARFUZZY mode.

func NewDelFuzzyGroupUM

func NewDelFuzzyGroupUM(c tree.RefContext) (tree.GroupHook, error)

NewDelFuzzyGroupUM returns a configured hook in CLEARFUZZY mode.

func NewDestroyEntity

func NewDestroyEntity(c tree.RefContext) (tree.EntityHook, error)

NewDestroyEntity returns an initialized DestroyEntity hook for use.

func NewDestroyGroup

func NewDestroyGroup(c tree.RefContext) (tree.GroupHook, error)

NewDestroyGroup returns an initialized DestroyGroup hook for use.

func NewELMLock

func NewELMLock(c tree.RefContext) (tree.EntityHook, error)

NewELMLock returns a configured hook in LOCK mode.

func NewELMUnlock

func NewELMUnlock(c tree.RefContext) (tree.EntityHook, error)

NewELMUnlock returns a configured hook in UNLOCK mode.

func NewEnsureEntityMeta

func NewEnsureEntityMeta(c tree.RefContext) (tree.EntityHook, error)

NewEnsureEntityMeta returns an initialized hook to the caller.

func NewFailOnExistingEntity

func NewFailOnExistingEntity(c tree.RefContext) (tree.EntityHook, error)

NewFailOnExistingEntity will return an initialized hook ready for use.

func NewFailOnExistingGroup

func NewFailOnExistingGroup(c tree.RefContext) (tree.GroupHook, error)

NewFailOnExistingGroup returns an initialized hook ready for use.

func NewLoadEntity

func NewLoadEntity(c tree.RefContext) (tree.EntityHook, error)

NewLoadEntity returns an initialized hook ready for use.

func NewLoadGroup

func NewLoadGroup(c tree.RefContext) (tree.GroupHook, error)

NewLoadGroup returns an initialized hook ready for use.

func NewMergeEntityMeta

func NewMergeEntityMeta(c tree.RefContext) (tree.EntityHook, error)

NewMergeEntityMeta returns a MergeEntityMeta hook configured and ready for use.

func NewMergeGroupMeta

func NewMergeGroupMeta(c tree.RefContext) (tree.GroupHook, error)

NewMergeGroupMeta returns a MergeGroupMeta hook configured and ready for use.

func NewPatchGroupExpansions

func NewPatchGroupExpansions(tree.RefContext) (tree.GroupHook, error)

NewPatchGroupExpansions returns an initialized hook for use.

func NewRemoveEntityCapability

func NewRemoveEntityCapability(c tree.RefContext) (tree.EntityHook, error)

NewRemoveEntityCapability returns a ManageEntityCapability hook pre-configured into the subtractive mode.s

func NewRemoveGroupCapability

func NewRemoveGroupCapability(c tree.RefContext) (tree.GroupHook, error)

NewRemoveGroupCapability returns a ManageGroupCapability hook pre-configured into the subtractive mode.s

func NewSaveEntity

func NewSaveEntity(c tree.RefContext) (tree.EntityHook, error)

NewSaveEntity returns an initialized hook ready for use.

func NewSaveGroup

func NewSaveGroup(c tree.RefContext) (tree.GroupHook, error)

NewSaveGroup returns a configured hook for use.

func NewSetEntityCapability

func NewSetEntityCapability(c tree.RefContext) (tree.EntityHook, error)

NewSetEntityCapability returns a ManageEntityCapability hook pre-configured into the additive mode.

func NewSetEntityID

func NewSetEntityID(c tree.RefContext) (tree.EntityHook, error)

NewSetEntityID returns a SetEntityID hook initialized and ready for use.

func NewSetEntityNumber

func NewSetEntityNumber(c tree.RefContext) (tree.EntityHook, error)

NewSetEntityNumber returns a SetEntityNumber hook ready for use.

func NewSetEntitySecret

func NewSetEntitySecret(c tree.RefContext) (tree.EntityHook, error)

NewSetEntitySecret returns an initialized hook for use.

func NewSetGroupCapability

func NewSetGroupCapability(c tree.RefContext) (tree.GroupHook, error)

NewSetGroupCapability returns a ManageGroupCapability hook pre-configured into the additive mode.

func NewSetGroupDisplayName

func NewSetGroupDisplayName(c tree.RefContext) (tree.GroupHook, error)

NewSetGroupDisplayName returns an initialized hook ready for use.

func NewSetGroupName

func NewSetGroupName(c tree.RefContext) (tree.GroupHook, error)

NewSetGroupName returns an initialized hook.

func NewSetGroupNumber

func NewSetGroupNumber(c tree.RefContext) (tree.GroupHook, error)

NewSetGroupNumber returns a hook initialized and ready for use.

func NewSetManagingGroup

func NewSetManagingGroup(c tree.RefContext) (tree.GroupHook, error)

NewSetManagingGroup returns a hook initialized for use.

func NewValidateEntitySecret

func NewValidateEntitySecret(c tree.RefContext) (tree.EntityHook, error)

NewValidateEntitySecret returns an initialized hook ready for use.

func NewValidateEntityUnlocked

func NewValidateEntityUnlocked(c tree.RefContext) (tree.EntityHook, error)

NewValidateEntityUnlocked returns an initialized hook.

Types

type CheckExpansionCycles

type CheckExpansionCycles struct {
	tree.BaseHook
	db.DB
}

CheckExpansionCycles ensures that there is no path from the group g to expansions requested in the data group that could lead to a cycle in the inclusion graph.

func (*CheckExpansionCycles) Run

func (cec *CheckExpansionCycles) Run(g, dg *pb.Group) error

Run will iterate through all expansions requested in dg and ensure that no cycles exist between the g and the requested include. If the mode for any expansion is DROP that expansion will be skipped without checking.

type CheckExpansionTargets

type CheckExpansionTargets struct {
	tree.BaseHook
	db.DB
}

CheckExpansionTargets verifies that all expansions requested target groups that exist, unless the expansion type is DROP.

func (*CheckExpansionTargets) Run

func (cet *CheckExpansionTargets) Run(g, dg *pb.Group) error

Run iterates through all expansions on dg and ensures that if the expansion type isn't DROP that the group actually exists. This allows groups that have been deleted to effectively skip this check, since the only expansion that makes sense targeting a deleted group is to drop it.

type CheckImmediateExpansions

type CheckImmediateExpansions struct {
	tree.BaseHook
}

CheckImmediateExpansions checks if a new expansion conflicts with an existing on attatched to the parent group. Expansions of type DROP are unchecked.

func (*CheckImmediateExpansions) Run

func (cie *CheckImmediateExpansions) Run(g, dg *pb.Group) error

Run iterates over the expansions already on g, for each comparing to each expansion in dg. Excepting the case of an expansion type of DROP, which is unchecked, any matching expansion will result in an ErrExistingExpansion being returned.

type CreateEntityIfMissing

type CreateEntityIfMissing struct {
	tree.BaseHook
	db.DB
	crypto.EMCrypto
}

CreateEntityIfMissing is an Entity hook that will ensure that e exists and is populated before returning. This hook is primarily used for bootstrap actions where an entity needs to either exist or be created and it isn't important which of these happens.

func (*CreateEntityIfMissing) Run

func (c *CreateEntityIfMissing) Run(e, de *pb.Entity) error

Run will attempt to load the entity from an external source. If the load returns that the failure is due to an unknown entity, then one will be created. Any other load failure will result in an error being returned. Returned errors will be of a db.* type.

type DestroyEntity

type DestroyEntity struct {
	tree.BaseHook
	db.DB
}

DestroyEntity removes an entity from the system.

func (*DestroyEntity) Run

func (d *DestroyEntity) Run(e, de *pb.Entity) error

Run will request the underlying datastore to remove the entity, returning any status provided. If the entity ID is not specified in e, it will be obtained from de.

type DestroyGroup

type DestroyGroup struct {
	tree.BaseHook
	db.DB
}

DestroyGroup removes an entity from the system.

func (*DestroyGroup) Run

func (d *DestroyGroup) Run(g, dg *pb.Group) error

Run will request the underlying datastore to remove the group, returning any status provided. If the group Name is not specified in g, it will be obtained from dg.

type DirectGroupManager

type DirectGroupManager struct {
	tree.BaseHook
	// contains filtered or unexported fields
}

DirectGroupManager implements a hook type that can add or remove the groups that an entity is directly a member of.

func (*DirectGroupManager) Run

func (dgm *DirectGroupManager) Run(e, de *pb.Entity) error

Run iterates through all groups in de.Meta.Groups and adds or removes them from e.Meta.Groups based on the value of dgm.mode. True will add groups, false will remove them.

type EnsureEntityMeta

type EnsureEntityMeta struct {
	tree.BaseHook
}

EnsureEntityMeta has one function: to ensure that the metadata struct on an entity is not nil.

func (*EnsureEntityMeta) Run

func (*EnsureEntityMeta) Run(e, de *pb.Entity) error

Run will apply an empty metadata struct if one is not already present.

type EntityLockManager

type EntityLockManager struct {
	tree.BaseHook
	// contains filtered or unexported fields
}

The EntityLockManager is a configurable hook that can either lock or unlock entities as needed.

func (*EntityLockManager) Run

func (elm *EntityLockManager) Run(e, de *pb.Entity) error

Run will set the entity lock status unconditionally to the configured value for the instantiated hook.

type FailOnExistingEntity

type FailOnExistingEntity struct {
	tree.BaseHook
	db.DB
}

FailOnExistingEntity checks with the data store to see if an entity exists. If one does, then the hook will return an error that a duplicate ID already exists.

func (*FailOnExistingEntity) Run

func (l *FailOnExistingEntity) Run(e, de *pb.Entity) error

Run contacts the data store, attempts to load an entity and selectively inverts the return status from the load call (errors from the storage backend will be returned to the caller).

type FailOnExistingGroup

type FailOnExistingGroup struct {
	tree.BaseHook
	db.DB
}

FailOnExistingGroup is a hook that can be used to guard creation processes on groups.

func (*FailOnExistingGroup) Run

func (f *FailOnExistingGroup) Run(g, dg *pb.Group) error

Run contacts the datastore and attempts to load the group specified by dg. If the group loads successfully then an error is returned, in other cases nil is returned.

type LoadEntity

type LoadEntity struct {
	tree.BaseHook
	db.DB
}

LoadEntity loads an entity from the database.

func (*LoadEntity) Run

func (l *LoadEntity) Run(e, de *pb.Entity) error

Run attempts to load the entity specified by de.ID and if successful performs a deepcopy into the address pointed to by e. Any errors returned will be from the data storage layer.

type LoadGroup

type LoadGroup struct {
	tree.BaseHook
	db.DB
}

LoadGroup loads an entity from the database.

func (*LoadGroup) Run

func (l *LoadGroup) Run(g, dg *pb.Group) error

Run attempts to load the group specified by de.Name and if successful performs a deepcopy into the address pointed to by g. Any errors returned will be from the data storage layer.

type ManageEntityCapabilities

type ManageEntityCapabilities struct {
	tree.BaseHook
	// contains filtered or unexported fields
}

ManageEntityCapabilities is a configurable runtime hook that adds or removes capabilities as configured. Two convenience constructors exist to return hooks in either mode.

func (*ManageEntityCapabilities) Run

func (mec *ManageEntityCapabilities) Run(e, de *pb.Entity) error

Run modifies the stored capabilities on an entity depending on the value of the mode variable. When the mode is set to true, any capabilities stored in de will be copied to e if they are not already present. In false capabilities will be subtracted.

type ManageEntityKeys

type ManageEntityKeys struct {
	tree.BaseHook
	// contains filtered or unexported fields
}

ManageEntityKeys is a configurable hook that adds and removes keys.

func (*ManageEntityKeys) Run

func (mek *ManageEntityKeys) Run(e, de *pb.Entity) error

Run iterates on all keys in the request and adds or removes them from the entity's keystore.

type ManageEntityUM

type ManageEntityUM struct {
	tree.BaseHook
	// contains filtered or unexported fields
}

ManageEntityUM is a configurable plugin that manages the untyped metadata for entities.

func (*ManageEntityUM) Run

func (mm *ManageEntityUM) Run(e, de *pb.Entity) error

Run will process metadata provided via de onto e according to the mode the plugin is configured for. "UPSERT" will add or update fields as appropriate. "CLEARFUZZY" will ignore Z-Indexing annotations. "CLEAREXACT" will require exact key specifications.

type ManageGroupCapabilities

type ManageGroupCapabilities struct {
	tree.BaseHook
	// contains filtered or unexported fields
}

ManageGroupCapabilities is a configurable runtime hook that adds or removes capabilities as configured. Two convenience constructors exist to return hooks in either mode.

func (*ManageGroupCapabilities) Run

func (mec *ManageGroupCapabilities) Run(g, dg *pb.Group) error

Run modifies the stored capabilities on an entity depending on the value of the mode variable. When the mode is set to true, any capabilities stored in de will be copied to e if they are not already present. In false capabilities will be subtracted.

type ManageGroupUM

type ManageGroupUM struct {
	tree.BaseHook
	// contains filtered or unexported fields
}

ManageGroupUM is a configurable plugin that manages the untyped metadata for groups.

func (*ManageGroupUM) Run

func (mm *ManageGroupUM) Run(g, dg *pb.Group) error

Run will process metadata provided via dg onto g according to the mode the plugin is configured for. "UPSERT" will add or update fields as appropriate. "CLEARFUZZY" will ignore Z-Indexing annotations. "CLEAREXACT" will require exact key specifications.

type MergeEntityMeta

type MergeEntityMeta struct {
	tree.BaseHook
}

MergeEntityMeta provides a hook to copy metadata fields from the dataEntity to the entity.

func (*MergeEntityMeta) Run

func (*MergeEntityMeta) Run(e, de *pb.Entity) error

Run attempts to copy the metadata from one entity to another. Select fields are nil-ed out beforehand since they either require a specialized mechanism to edit, or a specialized capability.

type MergeGroupMeta

type MergeGroupMeta struct {
	tree.BaseHook
}

MergeGroupMeta provides a hook to copy metadata fields from the dataGroup to the group.

func (*MergeGroupMeta) Run

func (*MergeGroupMeta) Run(g, dg *pb.Group) error

Run attempts to copy the metadata from one group to another. Select fields are nil-ed out beforehand since they either require a specialized mechanism to edit, or a specialized capability.

type PatchGroupExpansions

type PatchGroupExpansions struct {
	tree.BaseHook
}

PatchGroupExpansions handles the application of group expansions. Checks that verify the referential integrity of these expansions should have already run before executing this hook.

func (*PatchGroupExpansions) Run

func (*PatchGroupExpansions) Run(g, dg *pb.Group) error

Run iterates through the expansions in dg and applies them to g. DROP expansions are processed with fuzzy group name matching.

type SaveEntity

type SaveEntity struct {
	tree.BaseHook
	db.DB
}

SaveEntity is designed to be a terminal processor in a chain. On success, the provided entity will be saved to the data store.

func (*SaveEntity) Run

func (s *SaveEntity) Run(e, de *pb.Entity) error

Run will pass e to the data storage mechanism's "SaveEntity" method.

type SaveGroup

type SaveGroup struct {
	tree.BaseHook
	db.DB
}

SaveGroup is a hook intended to terminate processing chains by saving a modified group to the database.

func (*SaveGroup) Run

func (s *SaveGroup) Run(g, dg *pb.Group) error

Run will pass the group specified by g to the datastore and request it to be saved.

type SetEntityID

type SetEntityID struct {
	tree.BaseHook
}

SetEntityID copies the ID from one entity to another.

func (*SetEntityID) Run

func (*SetEntityID) Run(e, de *pb.Entity) error

Run copies the ID from de to e, no checks are enforced during the copy.

type SetEntityNumber

type SetEntityNumber struct {
	tree.BaseHook
	db.DB
}

SetEntityNumber sets the number on an entity either statically with the number provided or dynamically with an automatically chosen number.

func (*SetEntityNumber) Run

func (s *SetEntityNumber) Run(e, de *pb.Entity) error

Run will provision a number in one of two ways. If the number is not equal to -1 then it will be used directly with no further checks and will be applied to the entity. If the number is -1 then the data storage system will be queried for the next available number. These numbers are not guaranteed to be in order or have any mathematical progression, only uniqueness.

type SetEntitySecret

type SetEntitySecret struct {
	tree.BaseHook
	crypto.EMCrypto
}

SetEntitySecret takes a plaintext secret and converts it to a secured secret for storage.

func (*SetEntitySecret) Run

func (s *SetEntitySecret) Run(e, de *pb.Entity) error

Run takes a plaintext secret from de.Secret and secures it using a crypto engine. The secured secret will be written to e.Secret.

type SetGroupDisplayName

type SetGroupDisplayName struct {
	tree.BaseHook
}

SetGroupDisplayName copies the display name from dg to g.

func (*SetGroupDisplayName) Run

func (*SetGroupDisplayName) Run(g, dg *pb.Group) error

Run copies the DisplayName from dg to g, no checking is performed.

type SetGroupName

type SetGroupName struct {
	tree.BaseHook
}

SetGroupName copies the name from dg to g.

func (*SetGroupName) Run

func (*SetGroupName) Run(g, dg *pb.Group) error

Run sets the name on g to the name on dg, no checks or validation are run during this hook.

type SetGroupNumber

type SetGroupNumber struct {
	tree.BaseHook
	db.DB
}

SetGroupNumber assigns a group number either by using the statically provided one, or dynamically requesting one from the database.

func (*SetGroupNumber) Run

func (s *SetGroupNumber) Run(g, dg *pb.Group) error

Run will set the group number on g. If dg.Number is provided as a non-zero positive integer, it will be used directly (care should be taken this number is not already allocated). If dg.Number is -1, a number will be dynamically provisioned by the database. It is recommended to use automatic provisioning unless strictly necessary to do otherwise.

type SetManagingGroup

type SetManagingGroup struct {
	tree.BaseHook
	db.DB
}

SetManagingGroup performs validation checks on the managing group and then sets it.

func (*SetManagingGroup) Run

func (c *SetManagingGroup) Run(g, dg *pb.Group) error

Run will attempt to set the managing group of g to the specified group on dg. If the managing group is the empty string, i.e. unmanaged, the hook will return immediately, otherwise the group is checked for either existence, or identity to the group being created.

type ValidateEntitySecret

type ValidateEntitySecret struct {
	tree.BaseHook
	crypto.EMCrypto
}

ValidateEntitySecret passes the secret to the crypto engine for validation.

func (*ValidateEntitySecret) Run

func (v *ValidateEntitySecret) Run(e, de *pb.Entity) error

Run calls VerifySecret to compare de.Secret with the secured copy from e.Secret.

type ValidateEntityUnlocked

type ValidateEntityUnlocked struct {
	tree.BaseHook
}

ValidateEntityUnlocked returns an error if the entity is locked.

func (*ValidateEntityUnlocked) Run

func (*ValidateEntityUnlocked) Run(e, de *pb.Entity) error

Run queries the locked status of an entity and returns either ErrEntityLocked or nil, depending on if the entity is locked.

Jump to

Keyboard shortcuts

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