Library that contains all default templates for leto-modelizer.
- Create the metadata of your templates in the index.json:
metadata structure for model template:
{
"key": "terraform_webapp",
"name": "Web application",
"plugin": "terrator-plugin",
"type": "model",
"description": "Schema of web application.",
"url": null,
"files": ["main.tf"]
}metadata structure for component template:
{
"key": "terraform_webapp",
"name": "Web application",
"plugin": "terrator-plugin",
"type": "component",
"description": "Schema of web application.",
"url": null,
"files": ["main.tf"]
}metadata structure for project template:
{
"key": "terraform_webapp",
"name": "Web application",
"plugins": ["terrator-plugin"],
"type": "project",
"description": "Schema of web application.",
"url": null,
"schemas": ["plugin1/model1/schema.svg", "plugin1/model2/schema.svg", "plugin2/model3/schema.svg"],
"files": ["plugin1/model1/main.js", "plugin1/model2/main.js", "plugin2/model3/app.js"]
}keyattribute is the folder name of your template under thetemplatesfolder.nameattribute is the display name used in leto-modelizer.pluginattribute is the plugin name used by the template. Only formodelandcomponenttemplates.pluginsattribute is all plugin names used by the template. Only forprojecttemplates.typeattribute is the template type, eithermodel,componentorproject.descriptionattribute is the description used in leto-modelizer to explain the usage of this template.urlattribute is an url attached to a documentation of this template used in leto-modelizer.schemasattribute is the list of schemas of this project. Same asfiles, only forprojecttemplate.filesattribute is the list of files used in the template.
- Create the folder of your template with the chosen key you provided in the index.json
- Create all the files (you) mentioned in this folder with the code of your template
- (Optional) Provide an icon for your template (only
icon.svgwill be used by leto-modelizer) - (Optional) Provide a schema for your template (only
schema.svgwill be used by leto-modelizer)
If you want to specify the position of the component(s) of your template, you need to do it in the file 'leto-modelizer.config.json'. The content will specify the name of the plugin(s), the component(s) associated and their position attributes.
{
"terrator-plugin": {
"eu-west-3a": {
"x": 154.099609375,
"y": -6.573709487915039,
"width": 110,
"height": 80,
"needsResizing": false,
"needsPositioning": false
}
}
}The content of this file will be added to the project config file like this:
{
"modelName": {
"terrator-plugin": {
"eu-west-3a": {
"x": 154.099609375,
"y": -6.573709487915039,
"width": 110,
"height": 80,
"needsResizing": false,
"needsPositioning": false
}
}
}
}Don't forget to add 'leto-modelizer.config.json' in the attribute 'files' of you template in 'index.json'.
When you create component template, you must use a function to generate id(s).
To do that you can use this in your template:
# app.tf
resource "server" "{{ generateId('resource_')}}" {
(...)
}By default, function generateId generate an id like XXXXXX. You can improve the id with a prefix parameter.
The previous example will generate:
# app.tf
resource "server" "resource_123456" {
(...)
}For more information, see nunjucks.
When you create project template, you need to specify all plugins the template will use. You have to add models with the list of models for your project. If you want to use existing models, you need to copy them in your project template folder.
Example of metadata structure for project template with 2 plugins and 3 models:
{
"key": "example_project",
"name": "Example project",
"plugins": ["terrator-plugin", "githubator-plugin"],
"type": "project",
"description": "Example project with multiple plugins and models.",
"url": null,
"schemas": ["plugin1/model1/schema.svg", "plugin1/model2/schema.svg", "plugin2/model3/schema.svg"],
"files": ["plugin1/model1/main.js", "plugin1/model2/main.js", "plugin2/model3/app.js"]
}- Provide an icon for your template at the root folder (only
icon.svgwill be used by leto-modelizer) - Provide a schema for each of your model (only
schema.svgwill be used by leto-modelizer)