Files
opencloud/store/pkg/config/config.go
T
2021-11-08 12:22:56 +01:00

97 lines
1.9 KiB
Go

package config
import (
"context"
"path"
"github.com/owncloud/ocis/ocis-pkg/config/defaults"
"github.com/owncloud/ocis/ocis-pkg/shared"
)
// Debug defines the available debug configuration.
type Debug struct {
Addr string
Token string
Pprof bool
Zpages bool
}
// GRPC defines the available grpc configuration.
type GRPC struct {
Addr string
Root string
}
// Service defines the available service configuration.
type Service struct {
Name string
Namespace string
Version string
}
// Tracing defines the available tracing configuration.
type Tracing struct {
Enabled bool
Type string
Endpoint string
Collector string
Service string
}
// Config combines all available configuration parts.
type Config struct {
File string
Log shared.Log
Debug Debug
GRPC GRPC
Tracing Tracing
Datapath string
Service Service
Context context.Context
Supervised bool
}
// New initializes a new configuration with or without defaults.
func New() *Config {
return &Config{}
}
func DefaultConfig() *Config {
return &Config{
Log: shared.Log{},
Debug: Debug{
Addr: "127.0.0.1:9464",
Token: "",
Pprof: false,
Zpages: false,
},
GRPC: GRPC{
Addr: "127.0.0.1:9460",
},
Tracing: Tracing{
Enabled: false,
Type: "jaeger",
Endpoint: "",
Collector: "",
Service: "store",
},
Datapath: path.Join(defaults.BaseDataPath(), "store"),
Service: Service{
Name: "store",
Namespace: "com.owncloud.api",
},
}
}
// GetEnv fetches a list of known env variables for this extension. It is to be used by gookit, as it provides a list
// with all the environment variables an extension supports.
func GetEnv() []string {
var r = make([]string, len(structMappings(&Config{})))
for i := range structMappings(&Config{}) {
r = append(r, structMappings(&Config{})[i].EnvVars...)
}
return r
}