3
0

Add support for .env.example generator

This commit is contained in:
Denis Arh
2022-02-06 16:13:42 +01:00
parent d09b037e84
commit 80d9b466ac
3 changed files with 1263 additions and 97 deletions
@@ -0,0 +1,38 @@
###############################################################################
###############################################################################
#
# This file is auto-generated.
#
# Copy it to .env and uncomment set or adjust any options you need.
#
# There are three ways how this options are loaded when Corteza starts:
# 1. Environmental variables are always loaded and can not be overrided
# by alternative sources (below) (*)
# 2. If one or more --env-file flag is provided corteza looks in the provided
# locations (either file or directory containing .env)
# 3. Directory where the corteza binary is located is scanned for .env file)
#
# (*) You can use mechanisms from docker or docker-compose to set or load
# environmental variables as well
{{- range .groups }}
###############################################################################
###############################################################################
{{ .title }}
#
{{- if .intro }}
{{ .intro }}
#
{{ end -}}
{{ range .options }}
###############################################################################
{{- if .description }}
{{ .description }}
{{- end }}
# Type: {{ .type }}
# Default: {{ .defaultValue }}
# {{ .env }}={{ .defaultValue }}
{{- end }}
{{- end }}
+46 -1
View File
@@ -1,6 +1,7 @@
package codegen
import (
"strings"
"github.com/cortezaproject/corteza-server/app"
"github.com/cortezaproject/corteza-server/codegen/schema"
)
@@ -50,4 +51,48 @@ options:
]
}
},
]
]+
[
{
template: "docs/.env.example.tpl"
output: ".env.example"
syntax: ".env"
payload: {
groups: [
for g in app.corteza.options {
title: "# " + strings.Join(strings.Split(g.title, "\n"), "\n# ")
if (g.intro != _|_) {
intro: "# " + strings.Join(strings.Split(g.intro, "\n"), "\n# ")
}
options: [
for o in g.options {
handle: o.handle
env: o.env
type: o.type
defaultGoExpr?: string
if (o.defaultGoExpr != _|_) {
defaultGoExpr: o.defaultGoExpr
}
defaultValue?: string
if (o.defaultValue != _|_) {
defaultValue: o.defaultValue
}
if (o.description != _|_) {
description: "# " + strings.Join(strings.Split(o.description, "\n"), "\n# ")
}
},
]
},
]
}
},
]+
// placeholder
[]