Chapter 4. About Software Templates
Software Templates in Red Hat Developer Hub provide a streamlined way to create software components and publish them to different version control repositories such as Git. Platform engineers create and maintain Software Templates in Red Hat Developer Hub.
4.1. Versioning a Software Template in Red Hat Developer Hub Copy linkLink copied to clipboard!
As a platform administrator, you can version Software Templates by using the existing custom actions catalog:scaffolded-from and catalog:template:version within the scaffolder backend module. By using these custom actions, you can track the scaffolder template version and the corresponding version of the entities created from it, which improves lifecycle management.
Prerequisites
- You have administrator rights to Red Hat Developer Hub.
Procedure
To add versioning to a Software Template yaml file, complete the following steps:
- Modify the Software Template that you want to update.
Complete one or both of the following tasks:
-
Include the
backstage.io/template-versionannotation in your template. When this annotation is present in your template, it is automatically used to annotate your catalog entity and a default version value is displayed. -
Pass the
backstage.io/template-versionannotation as input to the action. This method takes precedence over the annotation in the template itself. It allows the user running the template to specify the version they wish to generate.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
Include the
Verification
- Create a catalog component using the updated Software Template. This step creates a new component in Backstage and optionally, pushes files to an external repository (For example, GitHub, GitLab).
Check the component in the Catalog UI.
- On the Catalog page, locate the newly created catalog component.
-
Verify that the
backstage.io/template-versionannotation is present in the entity. You can use INSPECT ENTITY and select YAML Raw or JSON Raw view to find the annotation in the component definition.
Only if you have published the catalog component: Check the component file in the repository.
- If VIEW SOURCE is present in your UI: Click VIEW SOURCE to open the stored component file in the repository.
-
Locate the file manually and verify that the
backstage.io/template-versionannotation is present.
4.2. Enabling Software Template version update notifications in Red Hat Developer Hub Copy linkLink copied to clipboard!
As a platform engineer, you can enable notification alerts for template version updates using the @backstage-community/plugin-catalog-backend-module-scaffolder-relation-processor module, an extension to the catalog-backend plugin. When enabled, this module automatically notifies component owners whenever the Software Template used to generate their components is updated to a new version.
This functionality uses the spec.scaffoldedFrom field in catalog entities. This field links Software Templates to the entities they have scaffolded. By tracking this relationship, the module helps teams stay informed and take advantage of the latest improvements or fixes.
The plugin-catalog-backend-module-scaffolder-relation-processor module is disabled by default.
Prerequisites
-
You have installed and configured the Backstage backend notification plugin
@backstage/plugin-notifications-backend. -
You have installed and configured the Backstage frontend plugin
@backstage/plugin-notifications.
Procedure
To enable the notifications, in your
Red Hat Developer Hub app-config.yamlfile, add the following codes:In the
dynamicPlugins:frontendsection:Copy to Clipboard Copied! Toggle word wrap Toggle overflow In a new section:
scaffolder: notifications: templateUpdate: enabled: true # Set to false to disable notificationsscaffolder: notifications: templateUpdate: enabled: true # Set to false to disable notificationsCopy to Clipboard Copied! Toggle word wrap Toggle overflow You can also customize the notification title and description as shown in the following code:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
enabled-
Set to
trueto enable the notification. Default value isfalse. message:title- Enter the notification title.
message:description- Enter the notification description.
Both message:title and message:description support the template variable $ENTITY_DISPLAY_NAME. The system automatically substitutes this variable with the title (or the name, if the title is missing) of the entity scaffolded from the updated template.
Verification
-
In your Red Hat Developer Hub instance, on the left navigation menu, you are able to see
Notifications, or, if configured, the custom title. - When you update the version number in the Software Template, you receive a notification.
4.3. Tracking Component origin and Software Template version Copy linkLink copied to clipboard!
Platform engineers use custom actions within the Software Template scaffolding process to establish and track the dependency link between a generated entity (Component or Resource) and its source template. This relationship is called scaffolding provenance.
Platform administrators use custom actions such as catalog:scaffolded-from and catalog:template:version in the scaffolder backend module to track the template version and the corresponding entity version, which simplifies lifecycle management.
4.3.1. Configuring provenance and Software Template versioning Red Hat Developer Hub Copy linkLink copied to clipboard!
As a platform engineer, you must modify the Software Template YAML definition to ensure the required provenance information is added during the scaffolding process.
Prerequisites
- You have administrator rights to Red Hat Developer Hub.
Procedure
-
Locate the Software Template object YAML file where you want to add the provenance information and add a step that uses the
catalog:scaffolded-fromaction. This action links the resulting catalog entity back to the source template. Optional: To track the template version (for example, v1.0 versus v1.5), include the
catalog:template:versionaction in thestepssection. The following code block is an example to adding versioning action to thestepssection:Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
steps:input:templateVersionReads the version parameter
NoteThe
catalog:template:versionaction reads a version parameter defined in the template and applies it as an annotation to the resulting catalog entity.
In your Red Hat Developer Hub
app-config.yamlfile, configure thecatalog.locationssection to point to the Software Template that you want to add. You might need to addTemplateto the globalcatalog.rules.allowlist or add a granular rule to the location to allow for Software Templates ingestion, as shown in the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow where:
catalog.locations.type-
Enter the
urltype if you are importing templates from a repository, such as GitHub or GitLab. catalog.locations.target- Enter the URL for the template.
catalog.locations.rules.allow-
Enter the
Templaterule to allow new Software Templates to be added to the catalog.
Verification
After creating a component with the updated template, verify the provenance annotations in the resulting Catalog Entity YAML.
- In the Red Hat Developer Hub navigation menu, go to Catalog and locate the newly created catalog component.
- To view the underlying data that links the entity to the template, select the INSPECT ENTITY option.
To verify provenance annotations, complete the following steps:
-
Select the YAML Raw or JSON Raw view and verify the presence of the data item for the
scaffoldedFromlink. Optional: If versioning was included, verify the presence of the
backstage.io/template-versionannotation.NoteIf you publish the catalog component to an external repository (such as Git), the component file in that repository must also contain the
backstage.io/template-versionannotation.
-
Select the YAML Raw or JSON Raw view and verify the presence of the data item for the
4.3.2. Viewing Software Template dependencies Copy linkLink copied to clipboard!
As a developer, you can track which entities were created from a specific Software Template. When a platform engineer configures provenance on a template, you can quickly identify the complete dependency and impact map of that template by viewing all linked components and resources in the Catalog.
Procedure
To view all components created from a specific template, complete the following steps:
- In the Red Hat Developer Hub navigation menu, click Catalog, use the filters to find and select the Software Template you wish to inspect.
- In the Software Template detail page, click the Dependencies tab. This view lists all catalog entities such as components, resources, and systems that reference this template, including any version information if configured.