Entity hooks
Entity hooks let you define custom behavior during the lifecycle of your entities: applications, scopes, and deployments.
When you configure a hook, nullplatform calls your endpoint on specific entity lifecycle events, running either before or after its own processing. Your system handles the notification and responds with the outcome. For before-hooks, if no response is received, the entity is blocked and will not proceed.
Entity hooks vs. approvals
While both entity hooks and approvals help control entity lifecycle events, they serve different purposes:
- Entity hooks enable automated, programmatic checks before or after an entity operation. They ensure required preconditions, such as infrastructure setup, are met before proceeding.
- Approvals enforce governance policies by requiring human verification before certain actions are executed. They allow for decisions based on contextual metadata, such as blocking deployments during restricted periods. See Approvals for more information.
Using both entity hooks and approvals, organizations can automate workflows while maintaining control over critical processes.
When both are configured on the same event, approvals take precedence:
- The approval request is sent first, leaving the hook pending the result.
- Once the approval is granted, the hook notification is sent through the channel.
- If the approval is denied, the hook is not sent and remains in a
cancelledstate.
Common use cases
Ensuring application configuration
When creating an application, you may need to set up specific configurations, such as AWS accounts or Kubernetes clusters, to ensure future scopes and deployments function correctly.
A hook lets you enforce these configurations before the repository is created and before the application becomes available to developers. Without hooks, the application could become available before the required configurations are in place, potentially causing errors when creating scopes.
Managing deployment-related infrastructure
Some deployments require infrastructure not managed directly by nullplatform. For example, if a scope has a custom domain, a hook can verify that the domain exists and is properly configured before the deployment starts.
Next steps
- Set up entity hooks: configure a notification channel, create a hook action, and implement the callback handler.
- Filters: narrow which events trigger your hook using MongoDB-style filter expressions.
Tutorials
- Automatically update application repositories on creation: use a before-hook on
application:createto add files to every new repo automatically. - Notify when a deployment fully shifts traffic: use an after-hook with filters to run logic only once a deployment reaches 100% traffic.