mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 12:19:37 -06:00
add adoc template rendering
Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
committed by
mmattel
parent
3d02f805e3
commit
b88ea444fb
@@ -1,31 +1,31 @@
|
||||
variables:
|
||||
- name: CS3_GATEWAY
|
||||
type: ""
|
||||
default: ""
|
||||
default_value: ""
|
||||
description: ""
|
||||
dependend_services: []
|
||||
do_ignore: false
|
||||
- name: CS3_MACHINE_AUTH_API_KEY
|
||||
type: ""
|
||||
default: ""
|
||||
default_value: ""
|
||||
description: ""
|
||||
dependend_services: []
|
||||
do_ignore: false
|
||||
- name: OCIS_BASE_DATA_PATH
|
||||
type: ""
|
||||
default: ""
|
||||
default_value: ""
|
||||
description: ""
|
||||
dependend_services: []
|
||||
do_ignore: false
|
||||
- name: OCIS_CONFIG_DIR
|
||||
type: ""
|
||||
default: ""
|
||||
default_value: ""
|
||||
description: ""
|
||||
dependend_services: []
|
||||
do_ignore: false
|
||||
- name: MICRO_LOG_LEVEL
|
||||
type: ""
|
||||
default: ""
|
||||
default_value: ""
|
||||
description: ""
|
||||
dependend_services: []
|
||||
do_ignore: false
|
||||
|
||||
@@ -3,4 +3,5 @@ package main
|
||||
func main() {
|
||||
RenderTemplates()
|
||||
GetRogueEnvs()
|
||||
RenderGlobalVarsTemplate()
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ import (
|
||||
"path/filepath"
|
||||
"regexp"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
||||
"gopkg.in/yaml.v2"
|
||||
)
|
||||
@@ -22,7 +23,7 @@ type ConfigVars struct {
|
||||
type Variable struct {
|
||||
Name string `yaml:"name"`
|
||||
Type string `yaml:"type"`
|
||||
Default string `yaml:"default"`
|
||||
DefaultValue string `yaml:"default_value"`
|
||||
Description string `yaml:"description"`
|
||||
DependendServices []Service `yaml:"dependend_services"`
|
||||
DoIgnore bool `yaml:"do_ignore"`
|
||||
@@ -46,7 +47,7 @@ func GetRogueEnvs() {
|
||||
if err == nil {
|
||||
err := yaml.Unmarshal(yfile, &vars)
|
||||
if err != nil {
|
||||
log.Fatalf("could not unmarshall %s", fullYamlPath)
|
||||
log.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -90,3 +91,40 @@ func AddUniqueToStruct(variables *ConfigVars, variable Variable) {
|
||||
}
|
||||
variables.Variables = append(variables.Variables, variable)
|
||||
}
|
||||
|
||||
func RenderGlobalVarsTemplate() {
|
||||
curdir, err := os.Getwd()
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
fullYamlPath := filepath.Join(curdir, yamlSource)
|
||||
|
||||
content, err := ioutil.ReadFile("../../docs/templates/ADOC_global.tmpl")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
targetFolder := "../../docs/services/_includes/adoc/"
|
||||
|
||||
vars := &ConfigVars{}
|
||||
fmt.Printf("Reading existing variable definitions from %s\n", fullYamlPath)
|
||||
yfile, err := ioutil.ReadFile(fullYamlPath)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
err = yaml.Unmarshal(yfile, &vars)
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
targetFile, err := os.Create(filepath.Join(targetFolder, "global_configvars.adoc"))
|
||||
if err != nil {
|
||||
log.Fatalf("Failed to create target file: %s", err)
|
||||
}
|
||||
defer targetFile.Close()
|
||||
|
||||
tpl := template.Must(template.New("").Parse(string(content)))
|
||||
if err = tpl.Execute(targetFile, *vars); err != nil {
|
||||
log.Fatalf("Failed to execute template: %s", err)
|
||||
}
|
||||
}
|
||||
|
||||
23
docs/templates/ADOC_global.tmpl
vendored
Normal file
23
docs/templates/ADOC_global.tmpl
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
// set the attribute to true or leave empty, true without any quotes.
|
||||
|
||||
[caption=]
|
||||
.Global environment Variables
|
||||
[width="100%",cols="~,~,~,~",options="header"]
|
||||
| === |
|
||||
| Name |
|
||||
| Type |
|
||||
| Default Value |
|
||||
| Description |
|
||||
|
||||
{{- range .Variables}}
|
||||
|
||||
a| `{{- .Name }}` +
|
||||
a| [subs=-attributes]
|
||||
++{{ .Type }} ++
|
||||
a| [subs=-attributes]
|
||||
++{{.DefaultValue}} ++
|
||||
a| [subs=-attributes]
|
||||
{{.Description}}
|
||||
|
||||
{{- end }}
|
||||
| === |
|
||||
Reference in New Issue
Block a user