Template configuration

The Dev-console is able to generate new services starting from a from a git project or from an existing docker image.

To make sure that the Dev-console can create new services starting from a template it is necessary to create the template on Gitlab and to register it in the configuration of the Dev-console.

The templates must be registered in the CRUD, in the services collection, indicating a label that will display the user and the path to the git repository.

Template string replaced by dev console during service creation

The Dev-console will create a repository in which it will copy the template files replacing all occurrences of the following strings between %:

  • % CUSTOM_PLUGIN_IMAGE_NAME% -> name of the nexus image entered by the user
  • % CUSTOM_PLUGIN_PROJECT_NAME% -> name (label) of the dev-console project
  • % CUSTOM_PLUGIN_PROJECT_NAMESPACE% -> namespace of the dev-console project
  • % CUSTOM_PLUGIN_SERVICE_NAME% -> service name chosen by the user
  • % CUSTOM_PLUGIN_SERVICE_DESCRIPTION% -> description of the service chosen by the user
  • % CUSTOM_PLUGIN_CREATOR_USERNAME% -> username of the user who created the service
  • % CUSTOM_PLUGIN_PROJECT_FULL_PATH% -> full Gitlab path
  • % GITLAB_PROJECT% -> name of the Gitlab project entered by the user
  • % GITLAB_GROUP% -> name of the user-entered Gitlab group
  • % GITLAB_BASE_URL% -> URL base of Gitlab
  • % NEXUS_HOSTNAME% -> Nexus hostname

Example of template upload

Below is an example of the body of a template:

  "name": "Node Template",
  "archiveUrl": "https://git.tools.mia-platform.eu/api/v4/projects/238/repository/archive.tar.gz",
  "description": "This is the best template to start creating a service in node integrated inside the platform",
  "type": "template",
  "supportedBy": "mia-platform",
  "image": [
      "_id": "5db0105743875a0011618815",
      "name": "36e6b6b4-36e1-4737-b65f-d1fb62bb3647.png",
      "file": "f2ca3f95-1556-446f-a098-dbc1ff219dc8.png",
      "size": 1532,
      "location": "/v2/files/download/f2ca3f95-1556-446f-a098-dbc1ff219dc8.png",
      "type": "image/png"
  "supportedByImage": [
      "_id": "5db0106143875a0011618816",
      "name": "e7c7ced2-e40e-465b-9e79-7d5c710badb2.png",
      "file": "e5ee5be6-e16d-4404-99a6-2f3ed2f91b64.png",
      "size": 139694,
      "location": "/v2/files/download/e5ee5be6-e16d-4404-99a6-2f3ed2f91b64.png",
      "type": "image/png"

and the example curl to create the template:

curl -d '{"name":"NodeTemplate","archiveUrl":"https://git.tools.mia-platform.eu/api/v4/projects/238/repository/archive.tar.gz","description":"Thisisthebesttemplatetostartcreatingaserviceinnodeintegratedinsidetheplatform","type":"template","supportedBy":"mia-platform","image":[{"_id":"5db0105743875a0011618815","name":"36e6b6b4-36e1-4737-b65f-d1fb62bb3647.png","file":"f2ca3f95-1556-446f-a098-dbc1ff219dc8.png","size":1532,"location":"/v2/files/download/f2ca3f95-1556-446f-a098-dbc1ff219dc8.png","type":"image/png"}],"supportedByImage":[{"_id":"5db0106143875a0011618816","name":"e7c7ced2-e40e-465b-9e79-7d5c710badb2.png","file":"e5ee5be6-e16d-4404-99a6-2f3ed2f91b64.png","size":139694,"location":"/v2/files/download/e5ee5be6-e16d-4404-99a6-2f3ed2f91b64.png","type":"image/png"}]}' 'https://console.cloud.mia-platform.eu/v2/api/services/' -H 'cookie: <your cookie session here>' -H 'secret: <the secret goes here>' -H'content-type: application/json'

The archiveUrl field must be a URL to the tar.gz version of the git project; below is an example for project hosted on gitlab:


Note that you can now specify an image and a supportedByImage for the template; both fields are array of objects that cointain the image file data; the result will be as the following:


Upload service template image

If you have an image to upload, you should upload to dev console using, for example:

  curl -F "image=@/path/to/image" "https://console.cloud.mia-platform.eu/v2/files/" -H 'cookie: <your cookie session here>' -H 'secret: <the secret goes here>'

Example response for this call:

  "_id": "5d8a44205c34c8001240bdaa",
  "name": "magic.gif",
  "file": "65d15696-8724-4103-b672-e29518a55135.gif",
  "size": 1458668,
  "location": "/v2/files/download/65d15696-8724-4103-b672-e29518a55135.gif"

So, as imageUrl params in template body, you should use: https://console.cloud.mia-platform.eu/v2/files/download/65d15696-8724-4103-b672-e29518a55135.gif.

You can directly use the response body as image file object of your custom template, as described in the Example of template upload paragraph.

Change a custom template

To change a custom template, you can use the postman collection below to modify the project.

First, fill with your cookie sid to authenticate. Once authenticated, get the template to modify using Get templates collection to find the correct id. With the correct template id, Change existing template with the id, remove the unchanged fields and modify the correct one.

Postman collection

Download this collection and import into postman.