mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-05-12 06:21:13 -05:00
remove config docs prototype
This commit is contained in:
@@ -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)
|
||||
// }
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
@@ -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))
|
||||
}
|
||||
Reference in New Issue
Block a user