mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-26 03:57:27 -05:00
remove extensions/storage leftovers
This commit is contained in:
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/extensions/appprovider/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/appprovider/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/extensions/appprovider/pkg/server/debug"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
@@ -63,13 +63,9 @@ func AppProvider(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
debug.Name(c.Command.Name+"-debug"),
|
||||
debug.Addr(cfg.Debug.Addr),
|
||||
debug.Logger(logger),
|
||||
debug.Context(ctx),
|
||||
debug.Pprof(cfg.Debug.Pprof),
|
||||
debug.Zpages(cfg.Debug.Zpages),
|
||||
debug.Token(cfg.Debug.Token),
|
||||
debug.Config(cfg),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
50
extensions/appprovider/pkg/server/debug/option.go
Normal file
50
extensions/appprovider/pkg/server/debug/option.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/appprovider/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
o.Logger = val
|
||||
}
|
||||
}
|
||||
|
||||
// Context provides a function to set the context option.
|
||||
func Context(val context.Context) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = val
|
||||
}
|
||||
}
|
||||
|
||||
// Config provides a function to set the config option.
|
||||
func Config(val *config.Config) Option {
|
||||
return func(o *Options) {
|
||||
o.Config = val
|
||||
}
|
||||
}
|
||||
63
extensions/appprovider/pkg/server/debug/server.go
Normal file
63
extensions/appprovider/pkg/server/debug/server.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/appprovider/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/debug"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
)
|
||||
|
||||
// Server initializes the debug service and server.
|
||||
func Server(opts ...Option) (*http.Server, error) {
|
||||
options := newOptions(opts...)
|
||||
|
||||
return debug.NewService(
|
||||
debug.Logger(options.Logger),
|
||||
debug.Name(options.Config.Service.Name),
|
||||
debug.Version(version.String),
|
||||
debug.Address(options.Config.Debug.Addr),
|
||||
debug.Token(options.Config.Debug.Token),
|
||||
debug.Pprof(options.Config.Debug.Pprof),
|
||||
debug.Zpages(options.Config.Debug.Zpages),
|
||||
debug.Health(health(options.Config)),
|
||||
debug.Ready(ready(options.Config)),
|
||||
//debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
|
||||
//debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
|
||||
//debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),
|
||||
//debug.CorsAllowCredentials(options.Config.HTTP.CORS.AllowCredentials),
|
||||
), nil
|
||||
}
|
||||
|
||||
// health implements the health check.
|
||||
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ready implements the ready check.
|
||||
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/extensions/auth-basic/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/auth-basic/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/extensions/auth-basic/pkg/server/debug"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/ldap"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
@@ -85,13 +85,9 @@ func AuthBasic(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
debug.Name(c.Command.Name+"-debug"),
|
||||
debug.Addr(cfg.Debug.Addr),
|
||||
debug.Logger(logger),
|
||||
debug.Context(ctx),
|
||||
debug.Pprof(cfg.Debug.Pprof),
|
||||
debug.Zpages(cfg.Debug.Zpages),
|
||||
debug.Token(cfg.Debug.Token),
|
||||
debug.Config(cfg),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
50
extensions/auth-basic/pkg/server/debug/option.go
Normal file
50
extensions/auth-basic/pkg/server/debug/option.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/auth-basic/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
o.Logger = val
|
||||
}
|
||||
}
|
||||
|
||||
// Context provides a function to set the context option.
|
||||
func Context(val context.Context) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = val
|
||||
}
|
||||
}
|
||||
|
||||
// Config provides a function to set the config option.
|
||||
func Config(val *config.Config) Option {
|
||||
return func(o *Options) {
|
||||
o.Config = val
|
||||
}
|
||||
}
|
||||
63
extensions/auth-basic/pkg/server/debug/server.go
Normal file
63
extensions/auth-basic/pkg/server/debug/server.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/auth-basic/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/debug"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
)
|
||||
|
||||
// Server initializes the debug service and server.
|
||||
func Server(opts ...Option) (*http.Server, error) {
|
||||
options := newOptions(opts...)
|
||||
|
||||
return debug.NewService(
|
||||
debug.Logger(options.Logger),
|
||||
debug.Name(options.Config.Service.Name),
|
||||
debug.Version(version.String),
|
||||
debug.Address(options.Config.Debug.Addr),
|
||||
debug.Token(options.Config.Debug.Token),
|
||||
debug.Pprof(options.Config.Debug.Pprof),
|
||||
debug.Zpages(options.Config.Debug.Zpages),
|
||||
debug.Health(health(options.Config)),
|
||||
debug.Ready(ready(options.Config)),
|
||||
//debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
|
||||
//debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
|
||||
//debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),
|
||||
//debug.CorsAllowCredentials(options.Config.HTTP.CORS.AllowCredentials),
|
||||
), nil
|
||||
}
|
||||
|
||||
// health implements the health check.
|
||||
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ready implements the ready check.
|
||||
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/extensions/auth-bearer/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/auth-bearer/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/extensions/auth-bearer/pkg/server/debug"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
@@ -66,13 +66,9 @@ func AuthBearer(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
debug.Name(c.Command.Name+"-debug"),
|
||||
debug.Addr(cfg.Debug.Addr),
|
||||
debug.Logger(logger),
|
||||
debug.Context(ctx),
|
||||
debug.Pprof(cfg.Debug.Pprof),
|
||||
debug.Zpages(cfg.Debug.Zpages),
|
||||
debug.Token(cfg.Debug.Token),
|
||||
debug.Config(cfg),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
50
extensions/auth-bearer/pkg/server/debug/option.go
Normal file
50
extensions/auth-bearer/pkg/server/debug/option.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/auth-bearer/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
o.Logger = val
|
||||
}
|
||||
}
|
||||
|
||||
// Context provides a function to set the context option.
|
||||
func Context(val context.Context) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = val
|
||||
}
|
||||
}
|
||||
|
||||
// Config provides a function to set the config option.
|
||||
func Config(val *config.Config) Option {
|
||||
return func(o *Options) {
|
||||
o.Config = val
|
||||
}
|
||||
}
|
||||
63
extensions/auth-bearer/pkg/server/debug/server.go
Normal file
63
extensions/auth-bearer/pkg/server/debug/server.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/auth-bearer/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/debug"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
)
|
||||
|
||||
// Server initializes the debug service and server.
|
||||
func Server(opts ...Option) (*http.Server, error) {
|
||||
options := newOptions(opts...)
|
||||
|
||||
return debug.NewService(
|
||||
debug.Logger(options.Logger),
|
||||
debug.Name(options.Config.Service.Name),
|
||||
debug.Version(version.String),
|
||||
debug.Address(options.Config.Debug.Addr),
|
||||
debug.Token(options.Config.Debug.Token),
|
||||
debug.Pprof(options.Config.Debug.Pprof),
|
||||
debug.Zpages(options.Config.Debug.Zpages),
|
||||
debug.Health(health(options.Config)),
|
||||
debug.Ready(ready(options.Config)),
|
||||
//debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
|
||||
//debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
|
||||
//debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),
|
||||
//debug.CorsAllowCredentials(options.Config.HTTP.CORS.AllowCredentials),
|
||||
), nil
|
||||
}
|
||||
|
||||
// health implements the health check.
|
||||
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ready implements the ready check.
|
||||
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/extensions/auth-machine/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/auth-machine/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/extensions/auth-machine/pkg/server/debug"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
@@ -66,13 +66,9 @@ func AuthMachine(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
debug.Name(c.Command.Name+"-debug"),
|
||||
debug.Addr(cfg.Debug.Addr),
|
||||
debug.Logger(logger),
|
||||
debug.Context(ctx),
|
||||
debug.Pprof(cfg.Debug.Pprof),
|
||||
debug.Zpages(cfg.Debug.Zpages),
|
||||
debug.Token(cfg.Debug.Token),
|
||||
debug.Config(cfg),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
50
extensions/auth-machine/pkg/server/debug/option.go
Normal file
50
extensions/auth-machine/pkg/server/debug/option.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/auth-machine/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
o.Logger = val
|
||||
}
|
||||
}
|
||||
|
||||
// Context provides a function to set the context option.
|
||||
func Context(val context.Context) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = val
|
||||
}
|
||||
}
|
||||
|
||||
// Config provides a function to set the config option.
|
||||
func Config(val *config.Config) Option {
|
||||
return func(o *Options) {
|
||||
o.Config = val
|
||||
}
|
||||
}
|
||||
63
extensions/auth-machine/pkg/server/debug/server.go
Normal file
63
extensions/auth-machine/pkg/server/debug/server.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/auth-machine/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/debug"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
)
|
||||
|
||||
// Server initializes the debug service and server.
|
||||
func Server(opts ...Option) (*http.Server, error) {
|
||||
options := newOptions(opts...)
|
||||
|
||||
return debug.NewService(
|
||||
debug.Logger(options.Logger),
|
||||
debug.Name(options.Config.Service.Name),
|
||||
debug.Version(version.String),
|
||||
debug.Address(options.Config.Debug.Addr),
|
||||
debug.Token(options.Config.Debug.Token),
|
||||
debug.Pprof(options.Config.Debug.Pprof),
|
||||
debug.Zpages(options.Config.Debug.Zpages),
|
||||
debug.Health(health(options.Config)),
|
||||
debug.Ready(ready(options.Config)),
|
||||
//debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
|
||||
//debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
|
||||
//debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),
|
||||
//debug.CorsAllowCredentials(options.Config.HTTP.CORS.AllowCredentials),
|
||||
), nil
|
||||
}
|
||||
|
||||
// health implements the health check.
|
||||
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ready implements the ready check.
|
||||
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/extensions/frontend/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/frontend/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/extensions/frontend/pkg/server/debug"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
@@ -107,13 +107,9 @@ func Frontend(cfg *config.Config) *cli.Command {
|
||||
|
||||
{
|
||||
server, err := debug.Server(
|
||||
debug.Name(c.Command.Name+"-debug"),
|
||||
debug.Addr(cfg.Debug.Addr),
|
||||
debug.Logger(logger),
|
||||
debug.Context(ctx),
|
||||
debug.Pprof(cfg.Debug.Pprof),
|
||||
debug.Zpages(cfg.Debug.Zpages),
|
||||
debug.Token(cfg.Debug.Token),
|
||||
debug.Config(cfg),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
50
extensions/frontend/pkg/server/debug/option.go
Normal file
50
extensions/frontend/pkg/server/debug/option.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/frontend/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
o.Logger = val
|
||||
}
|
||||
}
|
||||
|
||||
// Context provides a function to set the context option.
|
||||
func Context(val context.Context) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = val
|
||||
}
|
||||
}
|
||||
|
||||
// Config provides a function to set the config option.
|
||||
func Config(val *config.Config) Option {
|
||||
return func(o *Options) {
|
||||
o.Config = val
|
||||
}
|
||||
}
|
||||
63
extensions/frontend/pkg/server/debug/server.go
Normal file
63
extensions/frontend/pkg/server/debug/server.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/frontend/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/debug"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
)
|
||||
|
||||
// Server initializes the debug service and server.
|
||||
func Server(opts ...Option) (*http.Server, error) {
|
||||
options := newOptions(opts...)
|
||||
|
||||
return debug.NewService(
|
||||
debug.Logger(options.Logger),
|
||||
debug.Name(options.Config.Service.Name),
|
||||
debug.Version(version.String),
|
||||
debug.Address(options.Config.Debug.Addr),
|
||||
debug.Token(options.Config.Debug.Token),
|
||||
debug.Pprof(options.Config.Debug.Pprof),
|
||||
debug.Zpages(options.Config.Debug.Zpages),
|
||||
debug.Health(health(options.Config)),
|
||||
debug.Ready(ready(options.Config)),
|
||||
//debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
|
||||
//debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
|
||||
//debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),
|
||||
//debug.CorsAllowCredentials(options.Config.HTTP.CORS.AllowCredentials),
|
||||
), nil
|
||||
}
|
||||
|
||||
// health implements the health check.
|
||||
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ready implements the ready check.
|
||||
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,10 +17,10 @@ import (
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/extensions/gateway/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/gateway/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/service/external"
|
||||
"github.com/owncloud/ocis/extensions/gateway/pkg/server/debug"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/external"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
"github.com/owncloud/ocis/ocis-pkg/tracing"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
@@ -90,13 +90,9 @@ func Gateway(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
debug.Name(c.Command.Name+"-debug"),
|
||||
debug.Addr(cfg.Debug.Addr),
|
||||
debug.Logger(logger),
|
||||
debug.Context(ctx),
|
||||
debug.Pprof(cfg.Debug.Pprof),
|
||||
debug.Zpages(cfg.Debug.Zpages),
|
||||
debug.Token(cfg.Debug.Token),
|
||||
debug.Config(cfg),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
50
extensions/gateway/pkg/server/debug/option.go
Normal file
50
extensions/gateway/pkg/server/debug/option.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/gateway/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
o.Logger = val
|
||||
}
|
||||
}
|
||||
|
||||
// Context provides a function to set the context option.
|
||||
func Context(val context.Context) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = val
|
||||
}
|
||||
}
|
||||
|
||||
// Config provides a function to set the config option.
|
||||
func Config(val *config.Config) Option {
|
||||
return func(o *Options) {
|
||||
o.Config = val
|
||||
}
|
||||
}
|
||||
63
extensions/gateway/pkg/server/debug/server.go
Normal file
63
extensions/gateway/pkg/server/debug/server.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/gateway/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/debug"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
)
|
||||
|
||||
// Server initializes the debug service and server.
|
||||
func Server(opts ...Option) (*http.Server, error) {
|
||||
options := newOptions(opts...)
|
||||
|
||||
return debug.NewService(
|
||||
debug.Logger(options.Logger),
|
||||
debug.Name(options.Config.Service.Name),
|
||||
debug.Version(version.String),
|
||||
debug.Address(options.Config.Debug.Addr),
|
||||
debug.Token(options.Config.Debug.Token),
|
||||
debug.Pprof(options.Config.Debug.Pprof),
|
||||
debug.Zpages(options.Config.Debug.Zpages),
|
||||
debug.Health(health(options.Config)),
|
||||
debug.Ready(ready(options.Config)),
|
||||
//debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
|
||||
//debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
|
||||
//debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),
|
||||
//debug.CorsAllowCredentials(options.Config.HTTP.CORS.AllowCredentials),
|
||||
), nil
|
||||
}
|
||||
|
||||
// health implements the health check.
|
||||
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ready implements the ready check.
|
||||
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/extensions/group/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/group/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/extensions/group/pkg/server/debug"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/ldap"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
@@ -83,13 +83,9 @@ func Groups(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
debug.Name(c.Command.Name+"-debug"),
|
||||
debug.Addr(cfg.Debug.Addr),
|
||||
debug.Logger(logger),
|
||||
debug.Context(ctx),
|
||||
debug.Pprof(cfg.Debug.Pprof),
|
||||
debug.Zpages(cfg.Debug.Zpages),
|
||||
debug.Token(cfg.Debug.Token),
|
||||
debug.Config(cfg),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
50
extensions/group/pkg/server/debug/option.go
Normal file
50
extensions/group/pkg/server/debug/option.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/group/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
o.Logger = val
|
||||
}
|
||||
}
|
||||
|
||||
// Context provides a function to set the context option.
|
||||
func Context(val context.Context) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = val
|
||||
}
|
||||
}
|
||||
|
||||
// Config provides a function to set the config option.
|
||||
func Config(val *config.Config) Option {
|
||||
return func(o *Options) {
|
||||
o.Config = val
|
||||
}
|
||||
}
|
||||
63
extensions/group/pkg/server/debug/server.go
Normal file
63
extensions/group/pkg/server/debug/server.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/group/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/debug"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
)
|
||||
|
||||
// Server initializes the debug service and server.
|
||||
func Server(opts ...Option) (*http.Server, error) {
|
||||
options := newOptions(opts...)
|
||||
|
||||
return debug.NewService(
|
||||
debug.Logger(options.Logger),
|
||||
debug.Name(options.Config.Service.Name),
|
||||
debug.Version(version.String),
|
||||
debug.Address(options.Config.Debug.Addr),
|
||||
debug.Token(options.Config.Debug.Token),
|
||||
debug.Pprof(options.Config.Debug.Pprof),
|
||||
debug.Zpages(options.Config.Debug.Zpages),
|
||||
debug.Health(health(options.Config)),
|
||||
debug.Ready(ready(options.Config)),
|
||||
//debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
|
||||
//debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
|
||||
//debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),
|
||||
//debug.CorsAllowCredentials(options.Config.HTTP.CORS.AllowCredentials),
|
||||
), nil
|
||||
}
|
||||
|
||||
// health implements the health check.
|
||||
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ready implements the ready check.
|
||||
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/extensions/ocdav/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/ocdav/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/extensions/ocdav/pkg/server/debug"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
@@ -77,13 +77,9 @@ func OCDav(cfg *config.Config) *cli.Command {
|
||||
|
||||
{
|
||||
server, err := debug.Server(
|
||||
debug.Name(c.Command.Name+"-debug"),
|
||||
debug.Addr(cfg.Debug.Addr),
|
||||
debug.Logger(logger),
|
||||
debug.Context(ctx),
|
||||
debug.Pprof(cfg.Debug.Pprof),
|
||||
debug.Zpages(cfg.Debug.Zpages),
|
||||
debug.Token(cfg.Debug.Token),
|
||||
debug.Config(cfg),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
50
extensions/ocdav/pkg/server/debug/option.go
Normal file
50
extensions/ocdav/pkg/server/debug/option.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/ocdav/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
o.Logger = val
|
||||
}
|
||||
}
|
||||
|
||||
// Context provides a function to set the context option.
|
||||
func Context(val context.Context) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = val
|
||||
}
|
||||
}
|
||||
|
||||
// Config provides a function to set the config option.
|
||||
func Config(val *config.Config) Option {
|
||||
return func(o *Options) {
|
||||
o.Config = val
|
||||
}
|
||||
}
|
||||
63
extensions/ocdav/pkg/server/debug/server.go
Normal file
63
extensions/ocdav/pkg/server/debug/server.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/ocdav/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/debug"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
)
|
||||
|
||||
// Server initializes the debug service and server.
|
||||
func Server(opts ...Option) (*http.Server, error) {
|
||||
options := newOptions(opts...)
|
||||
|
||||
return debug.NewService(
|
||||
debug.Logger(options.Logger),
|
||||
debug.Name(options.Config.Service.Name),
|
||||
debug.Version(version.String),
|
||||
debug.Address(options.Config.Debug.Addr),
|
||||
debug.Token(options.Config.Debug.Token),
|
||||
debug.Pprof(options.Config.Debug.Pprof),
|
||||
debug.Zpages(options.Config.Debug.Zpages),
|
||||
debug.Health(health(options.Config)),
|
||||
debug.Ready(ready(options.Config)),
|
||||
//debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
|
||||
//debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
|
||||
//debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),
|
||||
//debug.CorsAllowCredentials(options.Config.HTTP.CORS.AllowCredentials),
|
||||
), nil
|
||||
}
|
||||
|
||||
// health implements the health check.
|
||||
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ready implements the ready check.
|
||||
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/extensions/sharing/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/sharing/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/extensions/sharing/pkg/server/debug"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/thejerf/suture/v4"
|
||||
"github.com/urfave/cli/v2"
|
||||
@@ -81,13 +81,9 @@ func Sharing(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
|
||||
debug, err := debug.Server(
|
||||
debug.Name(c.Command.Name+"-debug"),
|
||||
debug.Addr(cfg.Debug.Addr),
|
||||
debug.Logger(logger),
|
||||
debug.Context(ctx),
|
||||
debug.Pprof(cfg.Debug.Pprof),
|
||||
debug.Zpages(cfg.Debug.Zpages),
|
||||
debug.Token(cfg.Debug.Token),
|
||||
debug.Config(cfg),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
50
extensions/sharing/pkg/server/debug/option.go
Normal file
50
extensions/sharing/pkg/server/debug/option.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/sharing/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
o.Logger = val
|
||||
}
|
||||
}
|
||||
|
||||
// Context provides a function to set the context option.
|
||||
func Context(val context.Context) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = val
|
||||
}
|
||||
}
|
||||
|
||||
// Config provides a function to set the config option.
|
||||
func Config(val *config.Config) Option {
|
||||
return func(o *Options) {
|
||||
o.Config = val
|
||||
}
|
||||
}
|
||||
63
extensions/sharing/pkg/server/debug/server.go
Normal file
63
extensions/sharing/pkg/server/debug/server.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/sharing/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/debug"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
)
|
||||
|
||||
// Server initializes the debug service and server.
|
||||
func Server(opts ...Option) (*http.Server, error) {
|
||||
options := newOptions(opts...)
|
||||
|
||||
return debug.NewService(
|
||||
debug.Logger(options.Logger),
|
||||
debug.Name(options.Config.Service.Name),
|
||||
debug.Version(version.String),
|
||||
debug.Address(options.Config.Debug.Addr),
|
||||
debug.Token(options.Config.Debug.Token),
|
||||
debug.Pprof(options.Config.Debug.Pprof),
|
||||
debug.Zpages(options.Config.Debug.Zpages),
|
||||
debug.Health(health(options.Config)),
|
||||
debug.Ready(ready(options.Config)),
|
||||
//debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
|
||||
//debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
|
||||
//debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),
|
||||
//debug.CorsAllowCredentials(options.Config.HTTP.CORS.AllowCredentials),
|
||||
), nil
|
||||
}
|
||||
|
||||
// health implements the health check.
|
||||
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ready implements the ready check.
|
||||
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -13,10 +13,10 @@ import (
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/extensions/storage-metadata/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/storage-metadata/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/service/external"
|
||||
"github.com/owncloud/ocis/extensions/storage-metadata/pkg/server/debug"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/external"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
"github.com/owncloud/ocis/ocis-pkg/tracing"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
@@ -78,13 +78,9 @@ func StorageMetadata(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
debug.Name(c.Command.Name+"-debug"),
|
||||
debug.Addr(cfg.Debug.Addr),
|
||||
debug.Logger(logger),
|
||||
debug.Context(ctx),
|
||||
debug.Pprof(cfg.Debug.Pprof),
|
||||
debug.Zpages(cfg.Debug.Zpages),
|
||||
debug.Token(cfg.Debug.Token),
|
||||
debug.Config(cfg),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
50
extensions/storage-metadata/pkg/server/debug/option.go
Normal file
50
extensions/storage-metadata/pkg/server/debug/option.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/storage-metadata/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
o.Logger = val
|
||||
}
|
||||
}
|
||||
|
||||
// Context provides a function to set the context option.
|
||||
func Context(val context.Context) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = val
|
||||
}
|
||||
}
|
||||
|
||||
// Config provides a function to set the config option.
|
||||
func Config(val *config.Config) Option {
|
||||
return func(o *Options) {
|
||||
o.Config = val
|
||||
}
|
||||
}
|
||||
63
extensions/storage-metadata/pkg/server/debug/server.go
Normal file
63
extensions/storage-metadata/pkg/server/debug/server.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/storage-metadata/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/debug"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
)
|
||||
|
||||
// Server initializes the debug service and server.
|
||||
func Server(opts ...Option) (*http.Server, error) {
|
||||
options := newOptions(opts...)
|
||||
|
||||
return debug.NewService(
|
||||
debug.Logger(options.Logger),
|
||||
debug.Name(options.Config.Service.Name),
|
||||
debug.Version(version.String),
|
||||
debug.Address(options.Config.Debug.Addr),
|
||||
debug.Token(options.Config.Debug.Token),
|
||||
debug.Pprof(options.Config.Debug.Pprof),
|
||||
debug.Zpages(options.Config.Debug.Zpages),
|
||||
debug.Health(health(options.Config)),
|
||||
debug.Ready(ready(options.Config)),
|
||||
//debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
|
||||
//debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
|
||||
//debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),
|
||||
//debug.CorsAllowCredentials(options.Config.HTTP.CORS.AllowCredentials),
|
||||
), nil
|
||||
}
|
||||
|
||||
// health implements the health check.
|
||||
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ready implements the ready check.
|
||||
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/extensions/storage-publiclink/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/storage-publiclink/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/extensions/storage-publiclink/pkg/server/debug"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
@@ -66,13 +66,9 @@ func StoragePublicLink(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
debug.Name(c.Command.Name+"-debug"),
|
||||
debug.Addr(cfg.Debug.Addr),
|
||||
debug.Logger(logger),
|
||||
debug.Context(ctx),
|
||||
debug.Pprof(cfg.Debug.Pprof),
|
||||
debug.Zpages(cfg.Debug.Zpages),
|
||||
debug.Token(cfg.Debug.Token),
|
||||
debug.Config(cfg),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
50
extensions/storage-publiclink/pkg/server/debug/option.go
Normal file
50
extensions/storage-publiclink/pkg/server/debug/option.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/storage-publiclink/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
o.Logger = val
|
||||
}
|
||||
}
|
||||
|
||||
// Context provides a function to set the context option.
|
||||
func Context(val context.Context) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = val
|
||||
}
|
||||
}
|
||||
|
||||
// Config provides a function to set the config option.
|
||||
func Config(val *config.Config) Option {
|
||||
return func(o *Options) {
|
||||
o.Config = val
|
||||
}
|
||||
}
|
||||
63
extensions/storage-publiclink/pkg/server/debug/server.go
Normal file
63
extensions/storage-publiclink/pkg/server/debug/server.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/storage-publiclink/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/debug"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
)
|
||||
|
||||
// Server initializes the debug service and server.
|
||||
func Server(opts ...Option) (*http.Server, error) {
|
||||
options := newOptions(opts...)
|
||||
|
||||
return debug.NewService(
|
||||
debug.Logger(options.Logger),
|
||||
debug.Name(options.Config.Service.Name),
|
||||
debug.Version(version.String),
|
||||
debug.Address(options.Config.Debug.Addr),
|
||||
debug.Token(options.Config.Debug.Token),
|
||||
debug.Pprof(options.Config.Debug.Pprof),
|
||||
debug.Zpages(options.Config.Debug.Zpages),
|
||||
debug.Health(health(options.Config)),
|
||||
debug.Ready(ready(options.Config)),
|
||||
//debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
|
||||
//debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
|
||||
//debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),
|
||||
//debug.CorsAllowCredentials(options.Config.HTTP.CORS.AllowCredentials),
|
||||
), nil
|
||||
}
|
||||
|
||||
// health implements the health check.
|
||||
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ready implements the ready check.
|
||||
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/extensions/storage-shares/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/storage-shares/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/extensions/storage-shares/pkg/server/debug"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/thejerf/suture/v4"
|
||||
"github.com/urfave/cli/v2"
|
||||
@@ -68,13 +68,9 @@ func StorageShares(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
debug.Name(c.Command.Name+"-debug"),
|
||||
debug.Addr(cfg.Debug.Addr),
|
||||
debug.Logger(logger),
|
||||
debug.Context(ctx),
|
||||
debug.Pprof(cfg.Debug.Pprof),
|
||||
debug.Zpages(cfg.Debug.Zpages),
|
||||
debug.Token(cfg.Debug.Token),
|
||||
debug.Config(cfg),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -3,7 +3,7 @@ package debug
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/storage-shares/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
@@ -12,14 +12,9 @@ type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Name string
|
||||
Addr string
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
Pprof bool
|
||||
Zpages bool
|
||||
Token string
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
@@ -33,20 +28,6 @@ func newOptions(opts ...Option) Options {
|
||||
return opt
|
||||
}
|
||||
|
||||
// Name provides a function to set the name option.
|
||||
func Name(val string) Option {
|
||||
return func(o *Options) {
|
||||
o.Name = val
|
||||
}
|
||||
}
|
||||
|
||||
// Addr provides a function to set the addr option.
|
||||
func Addr(val string) Option {
|
||||
return func(o *Options) {
|
||||
o.Addr = val
|
||||
}
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
@@ -67,24 +48,3 @@ func Config(val *config.Config) Option {
|
||||
o.Config = val
|
||||
}
|
||||
}
|
||||
|
||||
// Pprof provides a function to set the pprof option.
|
||||
func Pprof(val bool) Option {
|
||||
return func(o *Options) {
|
||||
o.Pprof = val
|
||||
}
|
||||
}
|
||||
|
||||
// Zpages provides a function to set the zpages option.
|
||||
func Zpages(val bool) Option {
|
||||
return func(o *Options) {
|
||||
o.Zpages = val
|
||||
}
|
||||
}
|
||||
|
||||
// Token provides a function to set the token option.
|
||||
func Token(val string) Option {
|
||||
return func(o *Options) {
|
||||
o.Token = val
|
||||
}
|
||||
}
|
||||
63
extensions/storage-shares/pkg/server/debug/server.go
Normal file
63
extensions/storage-shares/pkg/server/debug/server.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/storage-shares/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/debug"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
)
|
||||
|
||||
// Server initializes the debug service and server.
|
||||
func Server(opts ...Option) (*http.Server, error) {
|
||||
options := newOptions(opts...)
|
||||
|
||||
return debug.NewService(
|
||||
debug.Logger(options.Logger),
|
||||
debug.Name(options.Config.Service.Name),
|
||||
debug.Version(version.String),
|
||||
debug.Address(options.Config.Debug.Addr),
|
||||
debug.Token(options.Config.Debug.Token),
|
||||
debug.Pprof(options.Config.Debug.Pprof),
|
||||
debug.Zpages(options.Config.Debug.Zpages),
|
||||
debug.Health(health(options.Config)),
|
||||
debug.Ready(ready(options.Config)),
|
||||
//debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
|
||||
//debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
|
||||
//debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),
|
||||
//debug.CorsAllowCredentials(options.Config.HTTP.CORS.AllowCredentials),
|
||||
), nil
|
||||
}
|
||||
|
||||
// health implements the health check.
|
||||
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ready implements the ready check.
|
||||
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/extensions/storage-users/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/storage-users/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/extensions/storage-users/pkg/server/debug"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
@@ -67,13 +67,9 @@ func StorageUsers(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
debug.Name(c.Command.Name+"-debug"),
|
||||
debug.Addr(cfg.Debug.Addr),
|
||||
debug.Logger(logger),
|
||||
debug.Context(ctx),
|
||||
debug.Pprof(cfg.Debug.Pprof),
|
||||
debug.Zpages(cfg.Debug.Zpages),
|
||||
debug.Token(cfg.Debug.Token),
|
||||
debug.Config(cfg),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
50
extensions/storage-users/pkg/server/debug/option.go
Normal file
50
extensions/storage-users/pkg/server/debug/option.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/storage-users/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
o.Logger = val
|
||||
}
|
||||
}
|
||||
|
||||
// Context provides a function to set the context option.
|
||||
func Context(val context.Context) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = val
|
||||
}
|
||||
}
|
||||
|
||||
// Config provides a function to set the config option.
|
||||
func Config(val *config.Config) Option {
|
||||
return func(o *Options) {
|
||||
o.Config = val
|
||||
}
|
||||
}
|
||||
63
extensions/storage-users/pkg/server/debug/server.go
Normal file
63
extensions/storage-users/pkg/server/debug/server.go
Normal file
@@ -0,0 +1,63 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/storage-users/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/debug"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
)
|
||||
|
||||
// Server initializes the debug service and server.
|
||||
func Server(opts ...Option) (*http.Server, error) {
|
||||
options := newOptions(opts...)
|
||||
|
||||
return debug.NewService(
|
||||
debug.Logger(options.Logger),
|
||||
debug.Name(options.Config.Service.Name),
|
||||
debug.Version(version.String),
|
||||
debug.Address(options.Config.Debug.Addr),
|
||||
debug.Token(options.Config.Debug.Token),
|
||||
debug.Pprof(options.Config.Debug.Pprof),
|
||||
debug.Zpages(options.Config.Debug.Zpages),
|
||||
debug.Health(health(options.Config)),
|
||||
debug.Ready(ready(options.Config)),
|
||||
//debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
|
||||
//debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
|
||||
//debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),
|
||||
//debug.CorsAllowCredentials(options.Config.HTTP.CORS.AllowCredentials),
|
||||
), nil
|
||||
}
|
||||
|
||||
// health implements the health check.
|
||||
func health(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ready implements the ready check.
|
||||
func ready(cfg *config.Config) func(http.ResponseWriter, *http.Request) {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Set("Content-Type", "text/plain")
|
||||
w.WriteHeader(http.StatusOK)
|
||||
|
||||
// TODO: check if services are up and running
|
||||
|
||||
_, err := io.WriteString(w, http.StatusText(http.StatusOK))
|
||||
// io.WriteString should not fail but if it does we want to know.
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,2 +0,0 @@
|
||||
*
|
||||
!bin/
|
||||
@@ -1,37 +0,0 @@
|
||||
SHELL := bash
|
||||
NAME := storage
|
||||
|
||||
include ../../.make/recursion.mk
|
||||
|
||||
############ tooling ############
|
||||
ifneq (, $(shell which go 2> /dev/null)) # suppress `command not found warnings` for non go targets in CI
|
||||
include ../../.bingo/Variables.mk
|
||||
endif
|
||||
|
||||
############ go tooling ############
|
||||
include ../../.make/go.mk
|
||||
|
||||
############ release #########
|
||||
include ../../.make/release.mk
|
||||
|
||||
############ docs generate ############
|
||||
include ../../.make/docs.mk
|
||||
|
||||
.PHONY: docs-generate
|
||||
docs-generate: config-docs-generate
|
||||
|
||||
############ generate ############
|
||||
include ../../.make/generate.mk
|
||||
|
||||
.PHONY: ci-go-generate
|
||||
ci-go-generate: # CI runs ci-node-generate automatically before this target
|
||||
|
||||
.PHONY: ci-node-generate
|
||||
ci-node-generate:
|
||||
|
||||
############ licenses ############
|
||||
.PHONY: ci-node-check-licenses
|
||||
ci-node-check-licenses:
|
||||
|
||||
.PHONY: ci-node-save-licenses
|
||||
ci-node-save-licenses:
|
||||
@@ -1,14 +0,0 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/command"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
FROM amd64/alpine:latest
|
||||
|
||||
RUN apk update && \
|
||||
apk upgrade && \
|
||||
apk add ca-certificates mailcap && \
|
||||
rm -rf /var/cache/apk/* && \
|
||||
echo 'hosts: files dns' >| /etc/nsswitch.conf
|
||||
|
||||
LABEL maintainer="ownCloud GmbH <devops@owncloud.com>" \
|
||||
org.label-schema.name="oCIS Reva" \
|
||||
org.label-schema.vendor="ownCloud GmbH" \
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
EXPOSE 9140 9141 9142 9143
|
||||
|
||||
ENTRYPOINT ["/usr/bin/ocis-reva"]
|
||||
CMD ["server"]
|
||||
|
||||
COPY bin/ocis-reva /usr/bin/ocis-reva
|
||||
@@ -1,19 +0,0 @@
|
||||
FROM arm32v6/alpine:latest
|
||||
|
||||
RUN apk update && \
|
||||
apk upgrade && \
|
||||
apk add ca-certificates mailcap && \
|
||||
rm -rf /var/cache/apk/* && \
|
||||
echo 'hosts: files dns' >| /etc/nsswitch.conf
|
||||
|
||||
LABEL maintainer="ownCloud GmbH <devops@owncloud.com>" \
|
||||
org.label-schema.name="oCIS Reva" \
|
||||
org.label-schema.vendor="ownCloud GmbH" \
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
EXPOSE 9140 9141 9142 9143
|
||||
|
||||
ENTRYPOINT ["/usr/bin/ocis-reva"]
|
||||
CMD ["server"]
|
||||
|
||||
COPY bin/ocis-reva /usr/bin/ocis-reva
|
||||
@@ -1,19 +0,0 @@
|
||||
FROM arm64v8/alpine:latest
|
||||
|
||||
RUN apk update && \
|
||||
apk upgrade && \
|
||||
apk add ca-certificates mailcap && \
|
||||
rm -rf /var/cache/apk/* && \
|
||||
echo 'hosts: files dns' >| /etc/nsswitch.conf
|
||||
|
||||
LABEL maintainer="ownCloud GmbH <devops@owncloud.com>" \
|
||||
org.label-schema.name="oCIS Reva" \
|
||||
org.label-schema.vendor="ownCloud GmbH" \
|
||||
org.label-schema.schema-version="1.0"
|
||||
|
||||
EXPOSE 9140 9141 9142 9143
|
||||
|
||||
ENTRYPOINT ["/usr/bin/ocis-reva"]
|
||||
CMD ["server"]
|
||||
|
||||
COPY bin/ocis-reva /usr/bin/ocis-reva
|
||||
@@ -1,22 +0,0 @@
|
||||
image: owncloud/ocis-reva:{{#if build.tag}}{{trimPrefix "v" build.tag}}{{else}}latest{{/if}}
|
||||
{{#if build.tags}}
|
||||
tags:
|
||||
{{#each build.tags}}
|
||||
- {{this}}
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
manifests:
|
||||
- image: owncloud/ocis-reva:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-amd64
|
||||
platform:
|
||||
architecture: amd64
|
||||
os: linux
|
||||
- image: owncloud/ocis-reva:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm64
|
||||
platform:
|
||||
architecture: arm64
|
||||
variant: v8
|
||||
os: linux
|
||||
- image: owncloud/ocis-reva:{{#if build.tag}}{{trimPrefix "v" build.tag}}-{{/if}}linux-arm
|
||||
platform:
|
||||
architecture: arm
|
||||
variant: v6
|
||||
os: linux
|
||||
@@ -1,48 +0,0 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/config"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// Health is the entrypoint for the health command.
|
||||
func Health(cfg *config.Config) *cli.Command {
|
||||
return &cli.Command{
|
||||
Name: "health",
|
||||
Usage: "check health status",
|
||||
Category: "info",
|
||||
Action: func(c *cli.Context) error {
|
||||
logger := NewLogger(cfg)
|
||||
|
||||
resp, err := http.Get(
|
||||
fmt.Sprintf(
|
||||
"http://%s/healthz",
|
||||
cfg.Debug.Addr,
|
||||
),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
logger.Fatal().
|
||||
Err(err).
|
||||
Msg("Failed to request health check")
|
||||
}
|
||||
|
||||
defer resp.Body.Close()
|
||||
|
||||
if resp.StatusCode != http.StatusOK {
|
||||
logger.Fatal().
|
||||
Int("code", resp.StatusCode).
|
||||
Msg("Health seems to be in bad state")
|
||||
}
|
||||
|
||||
logger.Debug().
|
||||
Int("code", resp.StatusCode).
|
||||
Msg("Health got a good state")
|
||||
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/clihelper"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// GetCommands provides all commands for this service
|
||||
func GetCommands(cfg *config.Config) cli.Commands {
|
||||
return []*cli.Command{
|
||||
Health(cfg),
|
||||
}
|
||||
}
|
||||
|
||||
// Execute is the entry point for the storage command.
|
||||
func Execute(cfg *config.Config) error {
|
||||
app := clihelper.DefaultApp(&cli.App{
|
||||
Name: "storage",
|
||||
Usage: "Storage service for oCIS",
|
||||
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
cli.HelpFlag = &cli.BoolFlag{
|
||||
Name: "help,h",
|
||||
Usage: "Show the help",
|
||||
}
|
||||
|
||||
return app.Run(os.Args)
|
||||
}
|
||||
|
||||
// NewLogger initializes a service-specific logger instance.
|
||||
func NewLogger(cfg *config.Config) log.Logger {
|
||||
return log.NewLogger(
|
||||
log.Name("storage"),
|
||||
log.Level(cfg.Log.Level),
|
||||
log.Pretty(cfg.Log.Pretty),
|
||||
log.Color(cfg.Log.Color),
|
||||
log.File(cfg.Log.File),
|
||||
)
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,459 +0,0 @@
|
||||
package defaults
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/config/defaults"
|
||||
)
|
||||
|
||||
const (
|
||||
defaultPublicURL = "https://localhost:9200"
|
||||
defaultShareFolder = "/Shares"
|
||||
defaultStorageNamespace = "/users/{{.Id.OpaqueId}}"
|
||||
defaultGatewayAddr = "127.0.0.1:9142"
|
||||
defaultUserLayout = "{{.Id.OpaqueId}}"
|
||||
defaultPersonalSpaceAliasTemplate = "{{.SpaceType}}/{{.User.Username | lower}}"
|
||||
defaultGeneralSpaceAliasTemplate = "{{.SpaceType}}/{{.SpaceName | replace \" \" \"-\" | lower}}"
|
||||
)
|
||||
|
||||
func FullDefaultConfig() *config.Config {
|
||||
cfg := DefaultConfig()
|
||||
EnsureDefaults(cfg)
|
||||
Sanitize(cfg)
|
||||
return cfg
|
||||
}
|
||||
|
||||
func DefaultConfig() *config.Config {
|
||||
return &config.Config{
|
||||
// log is inherited
|
||||
Debug: config.Debug{
|
||||
Addr: "127.0.0.1:9109",
|
||||
},
|
||||
Reva: config.Reva{
|
||||
SkipUserGroupsInToken: false,
|
||||
TransferExpires: 24 * 60 * 60,
|
||||
OIDC: config.OIDC{
|
||||
Issuer: defaultPublicURL,
|
||||
Insecure: false,
|
||||
IDClaim: "preferred_username",
|
||||
},
|
||||
LDAP: config.LDAP{
|
||||
URI: "ldaps://localhost:9235",
|
||||
CACert: path.Join(defaults.BaseDataPath(), "idm", "ldap.crt"),
|
||||
Insecure: false,
|
||||
UserBaseDN: "ou=users,o=libregraph-idm",
|
||||
GroupBaseDN: "ou=groups,o=libregraph-idm",
|
||||
UserScope: "sub",
|
||||
GroupScope: "sub",
|
||||
LoginAttributes: []string{"uid", "mail"},
|
||||
UserFilter: "",
|
||||
GroupFilter: "",
|
||||
UserObjectClass: "inetOrgPerson",
|
||||
GroupObjectClass: "groupOfNames",
|
||||
BindDN: "uid=reva,ou=sysusers,o=libregraph-idm",
|
||||
IDP: defaultPublicURL,
|
||||
UserSchema: config.LDAPUserSchema{
|
||||
ID: "ownclouduuid",
|
||||
Mail: "mail",
|
||||
DisplayName: "displayname",
|
||||
Username: "uid",
|
||||
UIDNumber: "uidnumber",
|
||||
GIDNumber: "gidnumber",
|
||||
},
|
||||
GroupSchema: config.LDAPGroupSchema{
|
||||
ID: "ownclouduuid",
|
||||
Mail: "mail",
|
||||
DisplayName: "cn",
|
||||
Groupname: "cn",
|
||||
Member: "member",
|
||||
GIDNumber: "gidnumber",
|
||||
},
|
||||
},
|
||||
UserGroupRest: config.UserGroupRest{
|
||||
RedisAddress: "localhost:6379",
|
||||
},
|
||||
UserOwnCloudSQL: config.UserOwnCloudSQL{
|
||||
DBUsername: "owncloud",
|
||||
DBHost: "mysql",
|
||||
DBPort: 3306,
|
||||
DBName: "owncloud",
|
||||
Idp: defaultPublicURL,
|
||||
Nobody: 90,
|
||||
JoinUsername: false,
|
||||
JoinOwnCloudUUID: false,
|
||||
EnableMedialSearch: false,
|
||||
},
|
||||
Archiver: config.Archiver{
|
||||
MaxNumFiles: 10000,
|
||||
MaxSize: 1073741824,
|
||||
ArchiverURL: "/archiver",
|
||||
},
|
||||
UserStorage: config.StorageConfig{
|
||||
EOS: config.DriverEOS{
|
||||
DriverCommon: config.DriverCommon{
|
||||
Root: "/eos/dockertest/reva",
|
||||
ShareFolder: defaultShareFolder,
|
||||
UserLayout: "{{substr 0 1 .Username}}/{{.Username}}",
|
||||
},
|
||||
ShadowNamespace: "", // Defaults to path.Join(c.Namespace, ".shadow")
|
||||
UploadsNamespace: "", // Defaults to path.Join(c.Namespace, ".uploads")
|
||||
EosBinary: "/usr/bin/eos",
|
||||
XrdcopyBinary: "/usr/bin/xrdcopy",
|
||||
MasterURL: "root://eos-mgm1.eoscluster.cern.ch:1094",
|
||||
SlaveURL: "root://eos-mgm1.eoscluster.cern.ch:1094",
|
||||
CacheDirectory: os.TempDir(),
|
||||
GatewaySVC: defaultGatewayAddr,
|
||||
},
|
||||
Local: config.DriverCommon{
|
||||
Root: path.Join(defaults.BaseDataPath(), "storage", "local", "users"),
|
||||
ShareFolder: defaultShareFolder,
|
||||
UserLayout: "{{.Username}}",
|
||||
EnableHome: false,
|
||||
},
|
||||
OwnCloudSQL: config.DriverOwnCloudSQL{
|
||||
DriverCommon: config.DriverCommon{
|
||||
Root: path.Join(defaults.BaseDataPath(), "storage", "owncloud"),
|
||||
ShareFolder: defaultShareFolder,
|
||||
UserLayout: "{{.Username}}",
|
||||
EnableHome: false,
|
||||
},
|
||||
UploadInfoDir: path.Join(defaults.BaseDataPath(), "storage", "uploadinfo"),
|
||||
DBUsername: "owncloud",
|
||||
DBPassword: "owncloud",
|
||||
DBHost: "",
|
||||
DBPort: 3306,
|
||||
DBName: "owncloud",
|
||||
},
|
||||
S3: config.DriverS3{
|
||||
DriverCommon: config.DriverCommon{},
|
||||
Region: "default",
|
||||
AccessKey: "",
|
||||
SecretKey: "",
|
||||
Endpoint: "",
|
||||
Bucket: "",
|
||||
},
|
||||
S3NG: config.DriverS3NG{
|
||||
DriverCommon: config.DriverCommon{
|
||||
Root: path.Join(defaults.BaseDataPath(), "storage", "users"),
|
||||
ShareFolder: defaultShareFolder,
|
||||
UserLayout: defaultUserLayout,
|
||||
PersonalSpaceAliasTemplate: defaultPersonalSpaceAliasTemplate,
|
||||
GeneralSpaceAliasTemplate: defaultGeneralSpaceAliasTemplate,
|
||||
EnableHome: false,
|
||||
},
|
||||
Region: "default",
|
||||
AccessKey: "",
|
||||
SecretKey: "",
|
||||
Endpoint: "",
|
||||
Bucket: "",
|
||||
},
|
||||
OCIS: config.DriverOCIS{
|
||||
DriverCommon: config.DriverCommon{
|
||||
Root: path.Join(defaults.BaseDataPath(), "storage", "users"),
|
||||
ShareFolder: defaultShareFolder,
|
||||
UserLayout: defaultUserLayout,
|
||||
PersonalSpaceAliasTemplate: defaultPersonalSpaceAliasTemplate,
|
||||
GeneralSpaceAliasTemplate: defaultGeneralSpaceAliasTemplate,
|
||||
},
|
||||
},
|
||||
},
|
||||
MetadataStorage: config.StorageConfig{
|
||||
EOS: config.DriverEOS{
|
||||
DriverCommon: config.DriverCommon{
|
||||
Root: "/eos/dockertest/reva",
|
||||
ShareFolder: defaultShareFolder,
|
||||
UserLayout: "{{substr 0 1 .Username}}/{{.Username}}",
|
||||
EnableHome: false,
|
||||
},
|
||||
ShadowNamespace: "",
|
||||
UploadsNamespace: "",
|
||||
EosBinary: "/usr/bin/eos",
|
||||
XrdcopyBinary: "/usr/bin/xrdcopy",
|
||||
MasterURL: "root://eos-mgm1.eoscluster.cern.ch:1094",
|
||||
GrpcURI: "",
|
||||
SlaveURL: "root://eos-mgm1.eoscluster.cern.ch:1094",
|
||||
CacheDirectory: os.TempDir(),
|
||||
EnableLogging: false,
|
||||
ShowHiddenSysFiles: false,
|
||||
ForceSingleUserMode: false,
|
||||
UseKeytab: false,
|
||||
SecProtocol: "",
|
||||
Keytab: "",
|
||||
SingleUsername: "",
|
||||
GatewaySVC: defaultGatewayAddr,
|
||||
},
|
||||
Local: config.DriverCommon{
|
||||
Root: path.Join(defaults.BaseDataPath(), "storage", "local", "metadata"),
|
||||
},
|
||||
OwnCloudSQL: config.DriverOwnCloudSQL{},
|
||||
S3: config.DriverS3{
|
||||
DriverCommon: config.DriverCommon{},
|
||||
Region: "default",
|
||||
},
|
||||
S3NG: config.DriverS3NG{
|
||||
DriverCommon: config.DriverCommon{
|
||||
Root: path.Join(defaults.BaseDataPath(), "storage", "metadata"),
|
||||
ShareFolder: "",
|
||||
UserLayout: defaultUserLayout,
|
||||
EnableHome: false,
|
||||
},
|
||||
Region: "default",
|
||||
AccessKey: "",
|
||||
SecretKey: "",
|
||||
Endpoint: "",
|
||||
Bucket: "",
|
||||
},
|
||||
OCIS: config.DriverOCIS{
|
||||
DriverCommon: config.DriverCommon{
|
||||
Root: path.Join(defaults.BaseDataPath(), "storage", "metadata"),
|
||||
ShareFolder: "",
|
||||
UserLayout: defaultUserLayout,
|
||||
EnableHome: false,
|
||||
},
|
||||
},
|
||||
},
|
||||
Frontend: config.FrontendPort{
|
||||
Port: config.Port{
|
||||
MaxCPUs: "",
|
||||
LogLevel: "",
|
||||
GRPCNetwork: "",
|
||||
GRPCAddr: "",
|
||||
HTTPNetwork: "tcp",
|
||||
HTTPAddr: "127.0.0.1:9140",
|
||||
Protocol: "",
|
||||
Endpoint: "",
|
||||
DebugAddr: "127.0.0.1:9141",
|
||||
Services: []string{"datagateway", "ocs", "appprovider"},
|
||||
Config: nil,
|
||||
Context: nil,
|
||||
Supervised: false,
|
||||
},
|
||||
AppProviderInsecure: false,
|
||||
AppProviderPrefix: "",
|
||||
ArchiverInsecure: false,
|
||||
ArchiverPrefix: "archiver",
|
||||
DatagatewayPrefix: "data",
|
||||
Favorites: false,
|
||||
ProjectSpaces: true,
|
||||
OCSPrefix: "ocs",
|
||||
OCSSharePrefix: defaultShareFolder,
|
||||
OCSHomeNamespace: defaultStorageNamespace,
|
||||
PublicURL: defaultPublicURL,
|
||||
OCSCacheWarmupDriver: "",
|
||||
OCSAdditionalInfoAttribute: "{{.Mail}}",
|
||||
OCSResourceInfoCacheTTL: 0,
|
||||
Middleware: config.Middleware{},
|
||||
},
|
||||
DataGateway: config.DataGatewayPort{
|
||||
Port: config.Port{},
|
||||
PublicURL: "",
|
||||
},
|
||||
Gateway: config.Gateway{
|
||||
Port: config.Port{
|
||||
Endpoint: defaultGatewayAddr,
|
||||
DebugAddr: "127.0.0.1:9143",
|
||||
GRPCNetwork: "tcp",
|
||||
GRPCAddr: defaultGatewayAddr,
|
||||
},
|
||||
CommitShareToStorageGrant: true,
|
||||
CommitShareToStorageRef: true,
|
||||
DisableHomeCreationOnLogin: true,
|
||||
ShareFolder: "Shares",
|
||||
LinkGrants: "",
|
||||
HomeMapping: "",
|
||||
EtagCacheTTL: 0,
|
||||
},
|
||||
StorageRegistry: config.StorageRegistry{
|
||||
Driver: "spaces",
|
||||
HomeProvider: "/home", // unused for spaces, static currently not supported
|
||||
JSON: "",
|
||||
},
|
||||
AppRegistry: config.AppRegistry{
|
||||
Driver: "static",
|
||||
MimetypesJSON: "",
|
||||
},
|
||||
Users: config.Users{
|
||||
Port: config.Port{
|
||||
Endpoint: "localhost:9144",
|
||||
DebugAddr: "127.0.0.1:9145",
|
||||
GRPCNetwork: "tcp",
|
||||
GRPCAddr: "127.0.0.1:9144",
|
||||
Services: []string{"userprovider"},
|
||||
},
|
||||
Driver: "ldap",
|
||||
UserGroupsCacheExpiration: 5,
|
||||
},
|
||||
Groups: config.Groups{
|
||||
Port: config.Port{
|
||||
Endpoint: "localhost:9160",
|
||||
DebugAddr: "127.0.0.1:9161",
|
||||
GRPCNetwork: "tcp",
|
||||
GRPCAddr: "127.0.0.1:9160",
|
||||
Services: []string{"groupprovider"},
|
||||
},
|
||||
Driver: "ldap",
|
||||
GroupMembersCacheExpiration: 5,
|
||||
},
|
||||
AuthProvider: config.Users{
|
||||
Port: config.Port{},
|
||||
Driver: "ldap",
|
||||
UserGroupsCacheExpiration: 0,
|
||||
},
|
||||
AuthBasic: config.Port{
|
||||
GRPCNetwork: "tcp",
|
||||
GRPCAddr: "127.0.0.1:9146",
|
||||
DebugAddr: "127.0.0.1:9147",
|
||||
Services: []string{"authprovider"},
|
||||
Endpoint: "localhost:9146",
|
||||
},
|
||||
AuthBearer: config.Port{
|
||||
GRPCNetwork: "tcp",
|
||||
GRPCAddr: "127.0.0.1:9148",
|
||||
DebugAddr: "127.0.0.1:9149",
|
||||
Services: []string{"authprovider"},
|
||||
Endpoint: "localhost:9148",
|
||||
},
|
||||
AuthMachine: config.Port{
|
||||
GRPCNetwork: "tcp",
|
||||
GRPCAddr: "127.0.0.1:9166",
|
||||
DebugAddr: "127.0.0.1:9167",
|
||||
Services: []string{"authprovider"},
|
||||
Endpoint: "localhost:9166",
|
||||
},
|
||||
AuthMachineConfig: config.AuthMachineConfig{},
|
||||
Sharing: config.Sharing{
|
||||
Port: config.Port{
|
||||
Endpoint: "localhost:9150",
|
||||
DebugAddr: "127.0.0.1:9151",
|
||||
GRPCNetwork: "tcp",
|
||||
GRPCAddr: "127.0.0.1:9150",
|
||||
Services: []string{"usershareprovider", "publicshareprovider"},
|
||||
},
|
||||
CS3ProviderAddr: "127.0.0.1:9215", // metadata storage
|
||||
CS3ServiceUser: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad",
|
||||
CS3ServiceUserIdp: "internal",
|
||||
UserDriver: "json",
|
||||
UserJSONFile: path.Join(defaults.BaseDataPath(), "storage", "shares.json"),
|
||||
UserSQLUsername: "",
|
||||
UserSQLPassword: "",
|
||||
UserSQLHost: "",
|
||||
UserSQLPort: 1433,
|
||||
UserSQLName: "",
|
||||
PublicDriver: "json",
|
||||
PublicJSONFile: path.Join(defaults.BaseDataPath(), "storage", "publicshares.json"),
|
||||
PublicPasswordHashCost: 11,
|
||||
PublicEnableExpiredSharesCleanup: true,
|
||||
PublicJanitorRunInterval: 60,
|
||||
UserStorageMountID: "",
|
||||
Events: config.Events{
|
||||
Address: "127.0.0.1:9233",
|
||||
ClusterID: "ocis-cluster",
|
||||
},
|
||||
},
|
||||
StorageShares: config.StoragePort{
|
||||
Port: config.Port{
|
||||
Endpoint: "localhost:9154",
|
||||
DebugAddr: "127.0.0.1:9156",
|
||||
GRPCNetwork: "tcp",
|
||||
GRPCAddr: "127.0.0.1:9154",
|
||||
HTTPNetwork: "tcp",
|
||||
HTTPAddr: "127.0.0.1:9155",
|
||||
},
|
||||
ReadOnly: false,
|
||||
AlternativeID: "1284d238-aa92-42ce-bdc4-0b0000009154",
|
||||
MountID: "1284d238-aa92-42ce-bdc4-0b0000009157",
|
||||
},
|
||||
StorageUsers: config.StoragePort{
|
||||
Port: config.Port{
|
||||
Endpoint: "localhost:9157",
|
||||
DebugAddr: "127.0.0.1:9159",
|
||||
GRPCNetwork: "tcp",
|
||||
GRPCAddr: "127.0.0.1:9157",
|
||||
HTTPNetwork: "tcp",
|
||||
HTTPAddr: "127.0.0.1:9158",
|
||||
},
|
||||
MountID: "1284d238-aa92-42ce-bdc4-0b0000009157",
|
||||
Driver: "ocis",
|
||||
DataServerURL: "http://localhost:9158/data",
|
||||
HTTPPrefix: "data",
|
||||
TempFolder: path.Join(defaults.BaseDataPath(), "tmp", "users"),
|
||||
},
|
||||
StoragePublicLink: config.PublicStorage{
|
||||
StoragePort: config.StoragePort{
|
||||
Port: config.Port{
|
||||
Endpoint: "localhost:9178",
|
||||
DebugAddr: "127.0.0.1:9179",
|
||||
GRPCNetwork: "tcp",
|
||||
GRPCAddr: "127.0.0.1:9178",
|
||||
},
|
||||
MountID: "7993447f-687f-490d-875c-ac95e89a62a4",
|
||||
},
|
||||
PublicShareProviderAddr: "",
|
||||
UserProviderAddr: "",
|
||||
},
|
||||
StorageMetadata: config.StoragePort{
|
||||
Port: config.Port{
|
||||
GRPCNetwork: "tcp",
|
||||
GRPCAddr: "127.0.0.1:9215",
|
||||
HTTPNetwork: "tcp",
|
||||
HTTPAddr: "127.0.0.1:9216",
|
||||
DebugAddr: "127.0.0.1:9217",
|
||||
},
|
||||
Driver: "ocis",
|
||||
ExposeDataServer: false,
|
||||
DataServerURL: "http://localhost:9216/data",
|
||||
TempFolder: path.Join(defaults.BaseDataPath(), "tmp", "metadata"),
|
||||
DataProvider: config.DataProvider{},
|
||||
},
|
||||
AppProvider: config.AppProvider{
|
||||
Port: config.Port{
|
||||
GRPCNetwork: "tcp",
|
||||
GRPCAddr: "127.0.0.1:9164",
|
||||
DebugAddr: "127.0.0.1:9165",
|
||||
Endpoint: "localhost:9164",
|
||||
Services: []string{"appprovider"},
|
||||
},
|
||||
ExternalAddr: "127.0.0.1:9164",
|
||||
WopiDriver: config.WopiDriver{},
|
||||
AppsURL: "/app/list",
|
||||
OpenURL: "/app/open",
|
||||
NewURL: "/app/new",
|
||||
},
|
||||
Permissions: config.Port{
|
||||
Endpoint: "localhost:9191",
|
||||
},
|
||||
Configs: nil,
|
||||
UploadMaxChunkSize: 1e+8,
|
||||
UploadHTTPMethodOverride: "",
|
||||
ChecksumSupportedTypes: []string{"sha1", "md5", "adler32"},
|
||||
ChecksumPreferredUploadType: "",
|
||||
DefaultUploadProtocol: "tus",
|
||||
},
|
||||
// TODO move ocdav config to a separate service
|
||||
OCDav: config.OCDav{
|
||||
Addr: "127.0.0.1:0", // :0 to pick any local free port
|
||||
DebugAddr: "127.0.0.1:9163",
|
||||
WebdavNamespace: defaultStorageNamespace,
|
||||
FilesNamespace: defaultStorageNamespace,
|
||||
SharesNamespace: defaultShareFolder,
|
||||
PublicURL: defaultPublicURL,
|
||||
Prefix: "",
|
||||
GatewaySVC: defaultGatewayAddr,
|
||||
Insecure: false, // true?
|
||||
Timeout: 84300,
|
||||
},
|
||||
Tracing: config.Tracing{
|
||||
Service: "storage",
|
||||
Type: "jaeger",
|
||||
},
|
||||
Asset: config.Asset{},
|
||||
}
|
||||
}
|
||||
|
||||
func EnsureDefaults(cfg *config.Config) {
|
||||
}
|
||||
|
||||
func Sanitize(cfg *config.Config) {
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
package parser
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/storage-metadata/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/storage-metadata/pkg/config/defaults"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
|
||||
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
|
||||
)
|
||||
|
||||
// ParseConfig loads configuration from known paths.
|
||||
func ParseConfig(cfg *config.Config) error {
|
||||
_, err := ociscfg.BindSourcesToStructs(cfg.Service.Name, cfg)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
defaults.EnsureDefaults(cfg)
|
||||
|
||||
// load all env variables relevant to the config in the current context.
|
||||
if err := envdecode.Decode(cfg); err != nil {
|
||||
// no environment variable set for this config is an expected "error"
|
||||
if !errors.Is(err, envdecode.ErrNoTargetFieldsAreSet) {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
defaults.Sanitize(cfg)
|
||||
|
||||
return Validate(cfg)
|
||||
}
|
||||
|
||||
func Validate(cfg *config.Config) error {
|
||||
return nil
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
package tracing
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Configure for Reva serves only as informational / instructive log messages. Tracing config will be delegated directly
|
||||
// to Reva services.
|
||||
func Configure(cfg *config.Config, logger log.Logger) {
|
||||
if cfg.Tracing.Enabled {
|
||||
switch cfg.Tracing.Type {
|
||||
case "agent":
|
||||
logger.Error().
|
||||
Str("type", cfg.Tracing.Type).
|
||||
Msg("Reva only supports the jaeger tracing backend")
|
||||
|
||||
case "jaeger":
|
||||
logger.Info().
|
||||
Str("type", cfg.Tracing.Type).
|
||||
Msg("configuring storage to use the jaeger tracing backend")
|
||||
|
||||
case "zipkin":
|
||||
logger.Error().
|
||||
Str("type", cfg.Tracing.Type).
|
||||
Msg("Reva only supports the jaeger tracing backend")
|
||||
|
||||
default:
|
||||
logger.Warn().
|
||||
Str("type", cfg.Tracing.Type).
|
||||
Msg("Unknown tracing backend")
|
||||
}
|
||||
|
||||
} else {
|
||||
logger.Debug().
|
||||
Msg("Tracing is not enabled")
|
||||
}
|
||||
}
|
||||
@@ -1,5 +0,0 @@
|
||||
# backend
|
||||
-r '^(cmd|pkg)/.*\.go$' -R '^node_modules/' -s -- sh -c 'make bin/ocis-reva-debug && bin/ocis-reva-debug --log-level debug server --debug-pprof --debug-zpages --asset-path assets/'
|
||||
|
||||
# frontend
|
||||
-r '^ui/.*\.(vue|js)$' -R '^node_modules/' -- sh -c 'yarn build'
|
||||
@@ -11,9 +11,9 @@ import (
|
||||
"github.com/cs3org/reva/v2/cmd/revad/runtime"
|
||||
"github.com/gofrs/uuid"
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/extensions/user/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/user/pkg/config/parser"
|
||||
"github.com/owncloud/ocis/extensions/user/pkg/server/debug"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/ldap"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
@@ -88,13 +88,9 @@ func User(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
debug.Name(c.Command.Name+"-debug"),
|
||||
debug.Addr(cfg.Debug.Addr),
|
||||
debug.Logger(logger),
|
||||
debug.Context(ctx),
|
||||
debug.Pprof(cfg.Debug.Pprof),
|
||||
debug.Zpages(cfg.Debug.Zpages),
|
||||
debug.Token(cfg.Debug.Token),
|
||||
debug.Config(cfg),
|
||||
)
|
||||
|
||||
if err != nil {
|
||||
|
||||
50
extensions/user/pkg/server/debug/option.go
Normal file
50
extensions/user/pkg/server/debug/option.go
Normal file
@@ -0,0 +1,50 @@
|
||||
package debug
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/user/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
)
|
||||
|
||||
// Option defines a single option function.
|
||||
type Option func(o *Options)
|
||||
|
||||
// Options defines the available options for this package.
|
||||
type Options struct {
|
||||
Logger log.Logger
|
||||
Context context.Context
|
||||
Config *config.Config
|
||||
}
|
||||
|
||||
// newOptions initializes the available default options.
|
||||
func newOptions(opts ...Option) Options {
|
||||
opt := Options{}
|
||||
|
||||
for _, o := range opts {
|
||||
o(&opt)
|
||||
}
|
||||
|
||||
return opt
|
||||
}
|
||||
|
||||
// Logger provides a function to set the logger option.
|
||||
func Logger(val log.Logger) Option {
|
||||
return func(o *Options) {
|
||||
o.Logger = val
|
||||
}
|
||||
}
|
||||
|
||||
// Context provides a function to set the context option.
|
||||
func Context(val context.Context) Option {
|
||||
return func(o *Options) {
|
||||
o.Context = val
|
||||
}
|
||||
}
|
||||
|
||||
// Config provides a function to set the config option.
|
||||
func Config(val *config.Config) Option {
|
||||
return func(o *Options) {
|
||||
o.Config = val
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import (
|
||||
"io"
|
||||
"net/http"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/storage/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/user/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/debug"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
)
|
||||
@@ -15,14 +15,18 @@ func Server(opts ...Option) (*http.Server, error) {
|
||||
|
||||
return debug.NewService(
|
||||
debug.Logger(options.Logger),
|
||||
debug.Name(options.Name),
|
||||
debug.Name(options.Config.Service.Name),
|
||||
debug.Version(version.String),
|
||||
debug.Address(options.Addr),
|
||||
debug.Token(options.Token),
|
||||
debug.Pprof(options.Pprof),
|
||||
debug.Zpages(options.Zpages),
|
||||
debug.Address(options.Config.Debug.Addr),
|
||||
debug.Token(options.Config.Debug.Token),
|
||||
debug.Pprof(options.Config.Debug.Pprof),
|
||||
debug.Zpages(options.Config.Debug.Zpages),
|
||||
debug.Health(health(options.Config)),
|
||||
debug.Ready(ready(options.Config)),
|
||||
//debug.CorsAllowedOrigins(options.Config.HTTP.CORS.AllowedOrigins),
|
||||
//debug.CorsAllowedMethods(options.Config.HTTP.CORS.AllowedMethods),
|
||||
//debug.CorsAllowedHeaders(options.Config.HTTP.CORS.AllowedHeaders),
|
||||
//debug.CorsAllowCredentials(options.Config.HTTP.CORS.AllowCredentials),
|
||||
), nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user