Initial QSfera import
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
package defaults
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/qsfera/server/pkg/shared"
|
||||
"github.com/qsfera/server/pkg/structs"
|
||||
"github.com/qsfera/server/services/collaboration/pkg/config"
|
||||
)
|
||||
|
||||
// FullDefaultConfig returns a fully initialized default configuration
|
||||
func FullDefaultConfig() *config.Config {
|
||||
cfg := DefaultConfig()
|
||||
EnsureDefaults(cfg)
|
||||
Sanitize(cfg)
|
||||
return cfg
|
||||
}
|
||||
|
||||
// DefaultConfig returns a basic default configuration
|
||||
func DefaultConfig() *config.Config {
|
||||
return &config.Config{
|
||||
Service: config.Service{
|
||||
Name: "collaboration",
|
||||
},
|
||||
App: config.App{
|
||||
Name: "Collabora",
|
||||
Description: "Open office documents with Collabora",
|
||||
Icon: "image-edit",
|
||||
Addr: "https://127.0.0.1:9980",
|
||||
Insecure: false,
|
||||
ProofKeys: config.ProofKeys{
|
||||
// they'll be enabled by default
|
||||
Duration: "12h",
|
||||
},
|
||||
},
|
||||
Store: config.Store{
|
||||
Store: "nats-js-kv",
|
||||
Nodes: []string{"127.0.0.1:9233"},
|
||||
Database: "collaboration",
|
||||
Table: "",
|
||||
TTL: 30 * time.Minute,
|
||||
},
|
||||
GRPC: config.GRPC{
|
||||
Addr: "127.0.0.1:9301",
|
||||
Protocol: "tcp",
|
||||
Namespace: "qsfera.api",
|
||||
},
|
||||
HTTP: config.HTTP{
|
||||
Addr: "127.0.0.1:9300",
|
||||
Namespace: "qsfera.web",
|
||||
},
|
||||
Debug: config.Debug{
|
||||
Addr: "127.0.0.1:9304",
|
||||
Token: "",
|
||||
Pprof: false,
|
||||
Zpages: false,
|
||||
},
|
||||
Wopi: config.Wopi{
|
||||
WopiSrc: "https://localhost:9300",
|
||||
},
|
||||
CS3Api: config.CS3Api{
|
||||
Gateway: config.Gateway{
|
||||
Name: shared.DefaultRevaConfig().Address,
|
||||
},
|
||||
DataGateway: config.DataGateway{
|
||||
Insecure: false,
|
||||
},
|
||||
APPRegistrationInterval: 30 * time.Second,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// EnsureDefaults adds default values to the configuration if they are not set yet
|
||||
func EnsureDefaults(cfg *config.Config) {
|
||||
if cfg.LogLevel == "" {
|
||||
cfg.LogLevel = "error"
|
||||
}
|
||||
|
||||
if cfg.TokenManager == nil && cfg.Commons != nil && cfg.Commons.TokenManager != nil {
|
||||
cfg.TokenManager = &config.TokenManager{
|
||||
JWTSecret: cfg.Commons.TokenManager.JWTSecret,
|
||||
}
|
||||
} else if cfg.TokenManager == nil {
|
||||
cfg.TokenManager = &config.TokenManager{}
|
||||
}
|
||||
if cfg.CS3Api.GRPCClientTLS == nil && cfg.Commons != nil {
|
||||
cfg.CS3Api.GRPCClientTLS = structs.CopyOrZeroValue(cfg.Commons.GRPCClientTLS)
|
||||
}
|
||||
}
|
||||
|
||||
// Sanitize sanitized the configuration
|
||||
func Sanitize(cfg *config.Config) {
|
||||
// sanitize config
|
||||
}
|
||||
Reference in New Issue
Block a user