Merge pull request #4 from refs/fix/cmd-flags

cmd flags as a dependency
This commit is contained in:
Thomas Boerger
2019-12-12 14:16:59 +01:00
committed by GitHub
3 changed files with 13 additions and 5 deletions
+2
View File
@@ -137,6 +137,8 @@ func Server(cfg *config.Config) cli.Command {
http.Context(ctx), http.Context(ctx),
http.Config(cfg), http.Config(cfg),
http.Metrics(metrics), http.Metrics(metrics),
http.Flags(flagset.RootWithConfig(cfg)),
http.Flags(flagset.ServerWithConfig(cfg)),
) )
if err != nil { if err != nil {
+9
View File
@@ -3,6 +3,7 @@ package http
import ( import (
"context" "context"
"github.com/micro/cli"
"github.com/owncloud/ocis-konnectd/pkg/config" "github.com/owncloud/ocis-konnectd/pkg/config"
"github.com/owncloud/ocis-konnectd/pkg/metrics" "github.com/owncloud/ocis-konnectd/pkg/metrics"
"github.com/owncloud/ocis-pkg/log" "github.com/owncloud/ocis-pkg/log"
@@ -17,6 +18,7 @@ type Options struct {
Context context.Context Context context.Context
Config *config.Config Config *config.Config
Metrics *metrics.Metrics Metrics *metrics.Metrics
Flags []cli.Flag
} }
// newOptions initializes the available default options. // newOptions initializes the available default options.
@@ -57,3 +59,10 @@ func Metrics(val *metrics.Metrics) Option {
o.Metrics = val 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...)
}
}
+2 -5
View File
@@ -1,9 +1,7 @@
package http package http
import ( import (
"github.com/owncloud/ocis-konnectd/pkg/config" svc "github.com/owncloud/ocis-konnectd/pkg/service/v0"
"github.com/owncloud/ocis-konnectd/pkg/flagset"
"github.com/owncloud/ocis-konnectd/pkg/service/v0"
"github.com/owncloud/ocis-konnectd/pkg/version" "github.com/owncloud/ocis-konnectd/pkg/version"
"github.com/owncloud/ocis-pkg/middleware" "github.com/owncloud/ocis-pkg/middleware"
"github.com/owncloud/ocis-pkg/service/http" "github.com/owncloud/ocis-pkg/service/http"
@@ -20,8 +18,7 @@ func Server(opts ...Option) (http.Service, error) {
http.Version(version.String), http.Version(version.String),
http.Address(options.Config.HTTP.Addr), http.Address(options.Config.HTTP.Addr),
http.Context(options.Context), http.Context(options.Context),
http.Flags(flagset.RootWithConfig(config.New())...), http.Flags(options.Flags...),
http.Flags(flagset.ServerWithConfig(config.New())...),
) )
handle := svc.NewService( handle := svc.NewService(