Customize repository naming patterns
When we create a repository for your new application, the name is based on the technology template you choose. If you’d like more control over how the repository name is generated, you can update the technology template before creating your application.
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
rules
object 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 tosed
syntax) 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}/api/golang/${1}/g"
}
}'
In this example:
application_name
ensures that the application name matches the patterntransactions-api
(ending with-api
).repository_path
dynamically generates the repository structure, incorporating the namespace (wallet), language (golang), and the application name (transactions).
These rules ensure consistent and customized repository naming.
3. Create your application
You can now create your application using the updated template. The repository will follow the custom naming pattern you defined.