3.7. Hooks#

While most aspects of your project and its workflows are already highly customizable via the provided control center configurations, there may still remain some complex routines you wish to add that are not covered by the available options. Therefore, PyPackIT also allows you to add custom plugins for maximum flexibility. These can hook into different stages of your workflows to perform arbitrary tasks. Plugins are defined in Python modules added to a subdirectory named hooks located at the root of the control center directory. For each workflow, PyPackIT looks for a specific Python file in this directory. Each file must contain a class named Hooks with a predefined signature, which will be instantiated at the beginning of the corresponding workflow. This class must define specific methods for hooking into certain stages of the workflow. At each stage, if a corresponding method exists, it will be called with a set of relevant arguments. Also, before running your hooks, PyPackIT will look for a requirements.txt file in the hooks directory, and will install the specified packages using pip.

Note that the cca_inline.py module serves a slightly different purpose, which is documented in the Templating section.

3.7.1. CCA#

CCA plugins hook into the Continuous Configuration Automation pipeline that processes your control center configuration files to synchronize your repository. They can be added to the Hooks class in the cca.py module, which is included in your repository by default. This class can define 9 public methods, corresponding to the 9 stages of the CCA pipeline. No return value is expected from any of the methods, but most are given mutable input arguments that they may modify in-place.