remove config docs prototype

This commit is contained in:
David Christofas
2022-03-01 16:35:08 +01:00
parent 4af7f630b9
commit d9bf920307
4 changed files with 0 additions and 99 deletions
-27
View File
@@ -1,27 +0,0 @@
package main
import (
"io/ioutil"
"log"
"os"
"text/template"
"github.com/owncloud/ocis/accounts/pkg/config"
"github.com/owncloud/ocis/ocis-pkg/docs"
)
func main() {
cfg := config.DefaultConfig()
fields := docs.Display(*cfg)
content, err := ioutil.ReadFile("docs/templates/CONFIGURATION.tmpl")
if err != nil {
log.Fatal(err)
}
tpl := template.Must(template.New("").Parse(string(content)))
tpl.Execute(os.Stdout, fields)
// for _, f := range fields {
// fmt.Printf("%s %s = %v\t%s\n", f.Name, f.Type, f.DefaultValue, f.Description)
// }
}
-38
View File
@@ -1,38 +0,0 @@
package docs
import (
"fmt"
"reflect"
)
type ConfigField struct {
Name string
DefaultValue string
Type string
Description string
}
func Display(s interface{}) []ConfigField {
t := reflect.TypeOf(s)
v := reflect.ValueOf(s)
var fields []ConfigField
for i := 0; i < t.NumField(); i++ {
field := t.Field(i)
value := v.Field(i)
switch value.Kind() {
default:
desc := field.Tag.Get("desc")
env, ok := field.Tag.Lookup("env")
if !ok {
continue
}
v := fmt.Sprintf("%v", value.Interface())
fields = append(fields, ConfigField{Name: env, DefaultValue: v, Description: desc, Type: value.Type().Name()})
case reflect.Struct:
fields = append(fields, Display(value.Interface())...)
}
}
return fields
}
-11
View File
@@ -1,11 +0,0 @@
package main
import (
"github.com/owncloud/ocis/ocis-pkg/docs"
"github.com/owncloud/ocis/thumbnails/pkg/config"
)
func main() {
cfg := config.DefaultConfig()
docs.Display(*cfg)
}
@@ -1,23 +0,0 @@
package main
import (
"fmt"
"github.com/owncloud/ocis/accounts/pkg/config"
"github.com/owncloud/ocis/accounts/pkg/config/parser"
"gopkg.in/yaml.v2"
)
func main() {
cfg := config.DefaultConfig()
parser.EnsureDefaults(cfg)
parser.Sanitize(cfg)
b, err := yaml.Marshal(cfg)
if err != nil {
return
}
fmt.Println(string(b))
}