Add output to configenvextractor

This commit is contained in:
Christian Richter
2022-03-02 15:12:55 +01:00
parent 63818e0fa4
commit 4f18908016
2 changed files with 8 additions and 1 deletions

View File

@@ -12,6 +12,7 @@ import (
)
func main() {
fmt.Println("Getting relevant packages")
paths, err := filepath.Glob("../../*/pkg/config/defaultconfig.go")
if err != nil {
log.Fatal(err)
@@ -27,6 +28,7 @@ func main() {
if err != nil {
log.Fatal(err)
}
fmt.Println("Generating intermediate go code")
tpl := template.Must(template.New("").Parse(string(content)))
os.Mkdir("output", 0700)
runner, err := os.Create("output/runner.go")
@@ -34,13 +36,15 @@ func main() {
log.Fatal(err)
}
tpl.Execute(runner, paths)
fmt.Println("Running intermediate go code")
os.Chdir("output")
os.Setenv("OCIS_BASE_DATA_PATH", "~/.ocis")
out, err := exec.Command("go", "run", "runner.go").Output()
if err != nil {
log.Fatal(err)
}
fmt.Println(string(out))
fmt.Println("Cleaning up")
os.Chdir("../")
os.RemoveAll("output")
fmt.Println(string(out))
}

View File

@@ -22,6 +22,7 @@ type ConfigField struct {
}
func main() {
fmt.Println("Generating documentation for environment variables:")
content, err := ioutil.ReadFile("../../../docs/templates/CONFIGURATION.tmpl")
if err != nil {
log.Fatal(err)
@@ -44,6 +45,7 @@ m := map[string]interface{}{
for pkg, conf := range m {
fields = GetAnnotatedVariables(conf)
if len(fields) > 0 {
fmt.Printf("... %s\n", pkg)
targetFile, err = os.Create(filepath.Join(targetFolder, replacer.Replace(pkg) + "_configvars.md"))
if err != nil {
log.Fatalf("Failed to create target file: %s", err)
@@ -54,6 +56,7 @@ m := map[string]interface{}{
}
}
}
fmt.Println("done")
}
func GetAnnotatedVariables(s interface{}) []ConfigField {