Merge pull request #16 from owncloud/fix/cmd-flags

cmd flags as a dependency
This commit is contained in:
Thomas Boerger
2019-12-12 14:16:11 +01:00
committed by GitHub
3 changed files with 13 additions and 5 deletions

View File

@@ -137,6 +137,8 @@ func Server(cfg *config.Config) cli.Command {
http.Context(ctx),
http.Config(cfg),
http.Metrics(metrics),
http.Flags(flagset.RootWithConfig(cfg)),
http.Flags(flagset.ServerWithConfig(cfg)),
)
if err != nil {

View File

@@ -3,6 +3,7 @@ package http
import (
"context"
"github.com/micro/cli"
"github.com/owncloud/ocis-phoenix/pkg/config"
"github.com/owncloud/ocis-phoenix/pkg/metrics"
"github.com/owncloud/ocis-pkg/log"
@@ -17,6 +18,7 @@ type Options struct {
Context context.Context
Config *config.Config
Metrics *metrics.Metrics
Flags []cli.Flag
}
// newOptions initializes the available default options.
@@ -57,3 +59,10 @@ func Metrics(val *metrics.Metrics) Option {
o.Metrics = val
}
}
// Flags provides a function to set the flags option.
func Flags(val []cli.Flag) Option {
return func(o *Options) {
o.Flags = append(o.Flags, val...)
}
}

View File

@@ -1,9 +1,7 @@
package http
import (
"github.com/owncloud/ocis-phoenix/pkg/config"
"github.com/owncloud/ocis-phoenix/pkg/flagset"
"github.com/owncloud/ocis-phoenix/pkg/service/v0"
svc "github.com/owncloud/ocis-phoenix/pkg/service/v0"
"github.com/owncloud/ocis-phoenix/pkg/version"
"github.com/owncloud/ocis-pkg/middleware"
"github.com/owncloud/ocis-pkg/service/http"
@@ -20,8 +18,7 @@ func Server(opts ...Option) (http.Service, error) {
http.Version(version.String),
http.Address(options.Config.HTTP.Addr),
http.Context(options.Context),
http.Flags(flagset.RootWithConfig(config.New())...),
http.Flags(flagset.ServerWithConfig(config.New())...),
http.Flags(options.Flags...),
)
handle := svc.NewService(