Skip to main content

Customize repository naming patterns

By default, when you create an application, its repository name is automatically generated based on the technology template you choose.

This page covers two ways you can customize that naming behavior:

  1. Before creating an application: You can define naming patterns in your technology template to control how repository names are generated automatically.
  2. After creating an application: If you rename the repository in your source provider (e.g., GitHub), you can manually update the repository URL in the application to reflect that change and maintain consistency.

Use these options to enforce your organization’s naming conventions and ensure your application metadata stays in sync.

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 to sed 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}-golang-${1}-${2}/g"
    }
    }'

In this example:

  • application_name ensures that the application name matches the pattern transactions-api (ending with -api).
  • repository_path dynamically generates the repository structure, incorporating the namespace (wallet), language (golang), and the application name (transactions).
Check pattern compatibility

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.

Update the name of your repository

If you’ve already created an application and want to change its repository URL, you can do so. You just need to make sure the application stays in sync with the new repository URL to avoid issues.

Follow these steps:

  1. Change the repository in your source provider (e.g., GitHub).
    For example, you might rename:
    https://github.com/acme-corp/accounting-billing-api

    https://github.com/acme-corp/accounting-checking-api

  2. Update the repository URL in your nullplatform application to match the new URL.

np application patch
--id 123
--body '{
"repository_url": "https://github.com/crypto-inc/accounting-checking-api",
}'
tip

Make sure the repository_url value reflects the new repository URL. This ensures the platform can continue tracking and syncing correctly.