Files

76 lines
1.9 KiB
Go
Raw Permalink Normal View History

2022-12-08 11:00:42 +01:00
package defaults
import (
"time"
2022-12-08 11:00:42 +01:00
"github.com/owncloud/ocis/v2/services/postprocessing/pkg/config"
)
2022-12-08 11:06:36 +01:00
// FullDefaultConfig returns a full sanitized config
2022-12-08 11:00:42 +01:00
func FullDefaultConfig() *config.Config {
cfg := DefaultConfig()
EnsureDefaults(cfg)
Sanitize(cfg)
return cfg
}
2022-12-08 11:06:36 +01:00
// DefaultConfig is the default configuration
2022-12-08 11:00:42 +01:00
func DefaultConfig() *config.Config {
return &config.Config{
2023-05-02 16:59:13 +02:00
Debug: config.Debug{
Addr: "127.0.0.1:9255",
Token: "",
Pprof: false,
Zpages: false,
},
2022-12-08 11:00:42 +01:00
Service: config.Service{
Name: "postprocessing",
},
Postprocessing: config.Postprocessing{
Events: config.Events{
Endpoint: "127.0.0.1:9233",
Cluster: "ocis-cluster",
},
2024-10-22 10:21:02 +02:00
Workers: 3,
RetryBackoffDuration: 5 * time.Second,
MaxRetries: 14,
2023-06-21 16:34:04 +02:00
},
Store: config.Store{
2024-04-04 17:02:28 +02:00
Store: "nats-js-kv",
Nodes: []string{"127.0.0.1:9233"},
2023-06-21 16:34:04 +02:00
Database: "postprocessing",
2024-04-04 17:02:28 +02:00
Table: "",
2022-12-08 11:00:42 +01:00
},
}
}
2022-12-08 11:06:36 +01:00
// EnsureDefaults ensures defaults on a config
2022-12-08 11:00:42 +01:00
func EnsureDefaults(cfg *config.Config) {
// provide with defaults for shared logging, since we need a valid destination address for BindEnv.
if cfg.Log == nil && cfg.Commons != nil && cfg.Commons.Log != nil {
cfg.Log = &config.Log{
Level: cfg.Commons.Log.Level,
Pretty: cfg.Commons.Log.Pretty,
Color: cfg.Commons.Log.Color,
File: cfg.Commons.Log.File,
}
} else if cfg.Log == nil {
cfg.Log = &config.Log{}
}
2023-05-02 16:59:13 +02:00
// provide with defaults for shared tracing, since we need a valid destination address for "envdecode".
if cfg.Tracing == nil && cfg.Commons != nil && cfg.Commons.Tracing != nil {
cfg.Tracing = &config.Tracing{
Enabled: cfg.Commons.Tracing.Enabled,
Type: cfg.Commons.Tracing.Type,
Endpoint: cfg.Commons.Tracing.Endpoint,
Collector: cfg.Commons.Tracing.Collector,
}
} else if cfg.Tracing == nil {
cfg.Tracing = &config.Tracing{}
}
2022-12-08 11:00:42 +01:00
}
2022-12-08 11:06:36 +01:00
// Sanitize does nothing atm
2022-12-08 11:00:42 +01:00
func Sanitize(cfg *config.Config) {
}