Overview of the issue
Today, NubesGen has a set of runtimes (eg. Spring) and the idea is to have new ones (eg. Quarkus, Micronaut). To make it easy to add new runtimes, the Mustache templates should rely on a default runtime when none is specified.
Motivation for or Use Case
See discussion: #115 (comment)
The way the Mustache templates are structured makes it difficult to add a new runtime. For example, take the src/main/resources/nubesgen/terraform/modules/app-service/main.tf.mustache
template. If the runtime is Spring, then we have a SPRING_DATASOURCE_URL
property, if not, we have a DATABASE_URL
:
{{#runtimeSpring}}
"SPRING_PROFILES_ACTIVE" = "prod,azure"
{{#databaseTypeSqlServer}}
"SPRING_DATASOURCE_URL" = "jdbc:sqlserver://${var.database_url}"
{{/databaseTypeSqlServer}}
...
{{/runtimeSpring}}
{{^runtimeSpring}}
{{#databaseTypeSqlServer}}
"DATABASE_URL" = var.database_url
{{/databaseTypeSqlServer}}
...
{{/runtimeSpring}}
If we keep the same structure and add a new runtime, then we have duplicates. In the following template, if we add a Quarkus runtime, then, we have a QUARKUS_DATASOURCE_JDBC_URL
property.... but because it's not a Spring runtime, the default DATABASE_URL
property is also added
{{#runtimeQuarkus}}
"QUARKUS_HTTP_PORT" = 80
"QUARKUS_PROFILE" = "prod"
{{#databaseTypeSqlServer}}
"QUARKUS_DATASOURCE_JDBC_URL" = "jdbc:sqlserver://${var.database_url}"
{{/databaseTypeSqlServer}}
...
{{#runtimeQuarkus}}
{{#runtimeSpring}}
"SPRING_PROFILES_ACTIVE" = "prod,azure"
{{#databaseTypeSqlServer}}
"SPRING_DATASOURCE_URL" = "jdbc:sqlserver://${var.database_url}"
{{/databaseTypeSqlServer}}
...
{{/runtimeSpring}}
{{^runtimeSpring}}
{{#databaseTypeSqlServer}}
"DATABASE_URL" = var.database_url
{{/databaseTypeSqlServer}}
...
{{/runtimeSpring}}
Mustache does not allow to have several inverted section. So it would be better to have a default runtime if none is specified. We could have something like:
{{#runtimeQuarkus}}
...
{{#runtimeQuarkus}}
{{#runtimeSpring}}
...
{{/runtimeSpring}}
{{#runtimeMicronaut}}
...
{{/runtimeMicronaut}}
{{#runtimeDefault}}
...
{{/runtimeDefault}}
NubesGen Version(s)
0.1.1
Browsers and Operating System
MacOSX and Chrome