new config framework in thumbnails
This commit is contained in:
@@ -5,16 +5,16 @@ package command
|
||||
|
||||
import (
|
||||
"github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/version"
|
||||
"github.com/owncloud/ocis/ocis-pkg/shared"
|
||||
"github.com/owncloud/ocis/ocis/pkg/register"
|
||||
"github.com/owncloud/ocis/thumbnails/pkg/command"
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
svcconfig "github.com/owncloud/ocis/thumbnails/pkg/config"
|
||||
)
|
||||
|
||||
// ThumbnailsCommand is the entrypoint for the thumbnails command.
|
||||
func ThumbnailsCommand(cfg *config.Config) *cli.Command {
|
||||
var globalLog shared.Log
|
||||
|
||||
return &cli.Command{
|
||||
Name: "thumbnails",
|
||||
Usage: "Start thumbnails server",
|
||||
@@ -23,31 +23,26 @@ func ThumbnailsCommand(cfg *config.Config) *cli.Command {
|
||||
command.PrintVersion(cfg.Thumbnails),
|
||||
},
|
||||
Before: func(ctx *cli.Context) error {
|
||||
return ParseConfig(ctx, cfg)
|
||||
if err := ParseConfig(ctx, cfg); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
globalLog = cfg.Log
|
||||
|
||||
return nil
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
origCmd := command.Server(configureThumbnails(cfg))
|
||||
// if thumbnails logging is empty in ocis.yaml
|
||||
if (cfg.Thumbnails.Log == shared.Log{}) && (globalLog != shared.Log{}) {
|
||||
// we can safely inherit the global logging values.
|
||||
cfg.Thumbnails.Log = globalLog
|
||||
}
|
||||
origCmd := command.Server(cfg.Thumbnails)
|
||||
return handleOriginalAction(c, origCmd)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func configureThumbnails(cfg *config.Config) *svcconfig.Config {
|
||||
cfg.Thumbnails.Log.Level = cfg.Log.Level
|
||||
cfg.Thumbnails.Log.Pretty = cfg.Log.Pretty
|
||||
cfg.Thumbnails.Log.Color = cfg.Log.Color
|
||||
cfg.Thumbnails.Server.Version = version.String
|
||||
|
||||
if cfg.Tracing.Enabled {
|
||||
cfg.Thumbnails.Tracing.Enabled = cfg.Tracing.Enabled
|
||||
cfg.Thumbnails.Tracing.Type = cfg.Tracing.Type
|
||||
cfg.Thumbnails.Tracing.Endpoint = cfg.Tracing.Endpoint
|
||||
cfg.Thumbnails.Tracing.Collector = cfg.Tracing.Collector
|
||||
}
|
||||
|
||||
return cfg.Thumbnails
|
||||
}
|
||||
|
||||
func init() {
|
||||
register.AddCommand(ThumbnailsCommand)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user