add ocis.yaml

This commit is contained in:
A.Unger
2021-11-04 10:53:40 +01:00
parent 3d46e27aae
commit 4194da4e88
6 changed files with 89 additions and 123 deletions
@@ -1,4 +0,0 @@
log:
pretty: true
color: true
level: info
+9 -13
View File
@@ -3,15 +3,12 @@ package command
import (
"os"
gofig "github.com/gookit/config/v2"
gooyaml "github.com/gookit/config/v2/yaml"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/urfave/cli/v2"
"github.com/owncloud/ocis/ocis-pkg/config"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/ocis-pkg/version"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/urfave/cli/v2"
)
// Execute is the entry point for the ocis command.
@@ -24,7 +21,7 @@ func Execute() error {
Usage: "ownCloud Infinite Scale Stack",
Compiled: version.Compiled(),
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg)
return ParseConfig(cfg)
},
Authors: []*cli.Author{
{
@@ -66,16 +63,15 @@ func NewLogger(cfg *config.Config) log.Logger {
}
// ParseConfig loads ocis configuration from known paths.
func ParseConfig(c *cli.Context, cfg *config.Config) error {
cnf := gofig.NewWithOptions("ocis", gofig.ParseEnv)
cnf.AddDriver(gooyaml.Driver)
err := cnf.LoadFiles("/Users/aunger/code/owncloud/ocis/ocis/pkg/command/ocis_example_config.yaml")
func ParseConfig(cfg *config.Config) error {
conf, err := ociscfg.BindSourcesToStructs("ocis", cfg)
if err != nil {
return err
}
err = cnf.BindStruct("", cfg)
if err != nil {
conf.LoadOSEnv(config.GetEnv(), false)
if err = cfg.UnmapEnv(conf); err != nil {
return err
}
-103
View File
@@ -1,104 +1 @@
package config
import (
accounts "github.com/owncloud/ocis/accounts/pkg/config"
glauth "github.com/owncloud/ocis/glauth/pkg/config"
graphExplorer "github.com/owncloud/ocis/graph-explorer/pkg/config"
graph "github.com/owncloud/ocis/graph/pkg/config"
idp "github.com/owncloud/ocis/idp/pkg/config"
pman "github.com/owncloud/ocis/ocis/pkg/runtime/config"
ocs "github.com/owncloud/ocis/ocs/pkg/config"
proxy "github.com/owncloud/ocis/proxy/pkg/config"
settings "github.com/owncloud/ocis/settings/pkg/config"
storage "github.com/owncloud/ocis/storage/pkg/config"
store "github.com/owncloud/ocis/store/pkg/config"
thumbnails "github.com/owncloud/ocis/thumbnails/pkg/config"
web "github.com/owncloud/ocis/web/pkg/config"
webdav "github.com/owncloud/ocis/webdav/pkg/config"
)
// Log defines the available logging configuration.
type Log struct {
Level string
Pretty bool
Color bool
}
// Debug defines the available debug configuration.
type Debug struct {
Addr string
Token string
Pprof bool
Zpages bool
}
// HTTP defines the available http configuration.
type HTTP struct {
Addr string
Root string
}
// GRPC defines the available grpc configuration.
type GRPC struct {
Addr string
}
// Tracing defines the available tracing configuration.
type Tracing struct {
Enabled bool
Type string
Endpoint string
Collector string
Service string
}
// TokenManager is the config for using the reva token manager
type TokenManager struct {
JWTSecret string
}
// Config combines all available configuration parts.
type Config struct {
Registry string
Log Log
Debug Debug
HTTP HTTP
GRPC GRPC
Tracing Tracing
TokenManager TokenManager
Accounts *accounts.Config
GLAuth *glauth.Config
Graph *graph.Config
GraphExplorer *graphExplorer.Config
IDP *idp.Config
OCS *ocs.Config
Web *web.Config
Proxy *proxy.Config
Settings *settings.Config
Storage *storage.Config
Store *store.Config
Thumbnails *thumbnails.Config
WebDAV *webdav.Config
Runtime *pman.Config
}
// New initializes a new configuration with or without defaults.
func New() *Config {
return &Config{
Accounts: accounts.DefaultConfig(),
GLAuth: glauth.New(),
Graph: graph.New(),
GraphExplorer: graphExplorer.New(),
IDP: idp.New(),
OCS: ocs.New(),
Web: web.New(),
Proxy: proxy.DefaultConfig(),
Settings: settings.New(),
Storage: storage.New(),
Store: store.New(),
Thumbnails: thumbnails.New(),
WebDAV: webdav.New(),
Runtime: pman.NewConfig(),
}
}