Customize repository naming patterns
When you create an application, its repository name is automatically generated based on the technology template you select.
However, you can customize how those repository names are generated to follow your organization’s conventions.
By defining naming patterns in your technology template, you can enforce consistent repository structures across teams and ensure repository names reflect your organization’s internal standards.
You can customize these patterns before creating applications by editing your technology templates through the API. Once configured, any new applications created from that template will automatically follow your defined naming rules.
How to customize naming patterns
1. Get the template id
To make changes, you’ll need the id of the template you want to update. Send a List all technology templates request and retrieve the id of the template.
Here’s an example request:
curl -L 'https://api.nullplatform.com/template' \
-H 'Accept: application/json'
You'll get a response like this:
{
"paging": {},
"results": [
{
"id": 123456789, // This is the template ID you'll need in the next step
"name": "Golang template",
"status": "active",
"url": "https://example.com/repository-1",
"provider": {
"repository": "technology-templates-golang"
},
"components": [
{ "type": "language", "id": "example-language", "version": "1.0" },
],
"tags": ["golang", "backend"],
"updated_at": "2024-01-01T00:00:00.000Z",
"created_at": "2024-01-01T00:00:00.000Z"
},
{
"id": 987654321,
"name": "Next.JS template",
"status": "active",
"url": "https://example.com/repository-2",
"provider": {
"repository": "example-repository-2"
},
"components": [
{ "type": "language", "id": "example-language-2", "version": "2.0" },
{ "type": "framework", "id": "example-framework", "version": "3.0" }
],
"tags": ["example", "frontend"],
"updated_at": "2024-01-02T00:00:00.000Z",
"created_at": "2024-01-02T00:00:00.000Z"
},
...
]
}
2. Update the technology template
To define custom naming patterns, update the technology template. To do this, send a PATCH request to modify the template.
In the request, you’ll:
- Provide the technology template
id. - Update the
rulesobject to define specific naming patterns for:application_name: A regular expression to validate and enforce the format of application names (e.g., ensure they end with-api).repository_path: A substitution expression (similar tosedsyntax) that defines the custom structure for the repository path, using matched groups from the application name.
Example
Imagine you want to create an application named "transactions-api" under the namespace "wallet", and you want to use a Golang template.
-
Default behavior: Without any customization to the Golang template, the repository name would default to
wallet-transactions-api. -
Custom behavior: To set the repository name to
mygit.com/wallet/api/golang/transactions, you need to define the following custom naming patterns in the template:curl -X PATCH 'https://api.nullplatform.com/template/123456789' \
-H 'Content-Type: application/json' \
-d '{
"rules": {
"application_name": "^(.*)-api$",
"repository_path": "s/^(.*)-(.*)$/${namespace.slug}-golang-${1}-${2}/g"
}
}'
In this example:
application_nameensures that the application name matches the patterntransactions-api(ending with-api).repository_pathdynamically generates the repository structure, incorporating the namespace (wallet), language (golang), and the application name (transactions).
Make sure the structure you define is valid for your specific source repository provider to avoid issues with path resolution or repository creation.
These rules allow you to enforce consistent, meaningful naming conventions across your organization.
3. Create your application
You can now create your application using the updated template. The repository will follow the custom naming pattern you defined.
More resources
If you need to rename the repository in your source provider after creating an application, you can manually update the repository URL in the application to reflect that change and maintain consistency.
See Update the name of your repository for more info.