In the Porter manifest you can define a dependency on another Porter authored bundle, and when you build the bundle, the root bundle and its dependencies are combined into a single composite bundle. The final bundle is a CNAB compliant bundle that can be used with any CNAB tool.
Since the CNAB Spec does not allow for dependencies between bundles, this dependency feature is unique to Porter, and only bundles that have been authored by Porter can be used as dependencies.
Here is a full example of a Porter manifest that uses dependencies.
Define a dependency
In the manifest, list the dependencies in the order that they should be installed.
dependencies: - name: mysql
Currently dependencies are assumed to be located in one of the locations below. Once the CNAB spec has a mechanism for distributing bundles via registries, this will be revisited.
- bundles (in the same directory as the Porter manifest)
Consolidating Parameters and Credentials
Porter consolidates the parameters and credentials from the dependencies and promotes them to the root bundle. This allows the user executing the bundle to interact with the parameter or credential from a dependency just as they would from one defined on the root bundle.
When a parameter or credential has the same type and name, then it is consolidated. When the same name is used, but not the same type then the bundle build fails.
Note: Porter doesn’t yet have a conflict resolution mechanism in place to allow an author to force consolidating parameters/credentials, or resolve a conflict.
Parameters defined in a dependent bundle can be defaulted from the root bundle.
In the example below, the mysql bundle defined the
mysql_user parameters, and the root bundle (Wordpress) defaulted those parameters
to a specific value, so that the user wouldn’t be required to choose a value for
those parameters when installing Wordpress.
dependencies: - name: mysql parameters: database_name: wordpress mysql_user: wordpress
Currently Porter only supports direct dependencies. Dependencies of dependencies, transitive dependencies, are ignored. See Design: Dependency Graph Resolution for more information.
Depending on the action being performed, Porter handles executing the dependent bundle’s steps either before or after the steps in the root bundle.
- Install - The steps are executed before the steps in the root bundle.
- Upgrade - The steps are executed before the steps in the root bundle.
- Uninstall - The steps are executed after the steps in the root bundle.