Creating a Check
Creating a Check
Within Infrahub a Check is defined in an external repository. However, during development and troubleshooting it is easiest to start from your local computer and run the check using infrahubctl check.
The goal of this guide is to develop a Check
and add it to Infrahub, we will achieve this by following these steps.
- Identify the relevant data in the database that you want to use as input for the check using a GraphQL query, that can take an input parameter to filter the data
- Write a Python script that will process and validate the data using your custom business logic
- Create an entry for the check within an .infrahub.yml file
- Create a Git repository
- Test the Check with the
infrahubctl
command - Add the repository to Infrahub as an external repository
- Test the Check in a proposed change
In this guide we are going to work with the builtin tag objects in Infrahub. The goal will be to use a Check
to validate the naming convention of an object using a Regex. Validating a string with a Regex is something we can do directly in the schema so this check won't be super helpful but the goal is instead to show how Checks work. Once you have mastered the basics you will be ready to go on to create more advanced Checks.