diff --git a/go.mod b/go.mod index 0e2841f0e..e916224b0 100644 --- a/go.mod +++ b/go.mod @@ -12,6 +12,7 @@ require ( github.com/haya14busa/goverage v0.0.0-20180129164344-eec3514a20b5 // indirect github.com/kballard/go-shellquote v0.0.0-20180428030007-95032a82bc51 // indirect github.com/micro/cli v0.2.0 + github.com/micro/cli/v2 v2.1.1 github.com/ogier/pflag v0.0.1 // indirect github.com/oklog/run v1.0.0 github.com/openzipkin/zipkin-go v0.2.2 diff --git a/go.sum b/go.sum index e79f13e5b..72882f099 100644 --- a/go.sum +++ b/go.sum @@ -159,6 +159,7 @@ github.com/coreos/go-systemd v0.0.0-20190719114852-fd7a80b32e1f/go.mod h1:F5haX7 github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f h1:lBNOc5arjvs8E5mO2tbpBpLoyyu8B6e44T7hJy6potg= github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cpu/goacmedns v0.0.1/go.mod h1:sesf/pNnCYwUevQEQfEwY0Y3DydlQWSGZbaMElOWxok= +github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d h1:U+s90UTSYgptZMwQh2aRr3LuazLJIa+Pg3Kc1ylSYVY= github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU= github.com/creack/pty v1.1.7 h1:6pwm8kMQKCmgUg0ZHTm5+/YvRK0s3THD/28+T6/kk4A= github.com/creack/pty v1.1.7/go.mod h1:lj5s0c3V2DBrqTV7llrYr5NG6My20zk30Fl46Y7DoTY= @@ -445,6 +446,8 @@ github.com/mholt/certmagic v0.7.5/go.mod h1:91uJzK5K8IWtYQqTi5R2tsxV1pCde+wdGfaR github.com/mholt/certmagic v0.8.3/go.mod h1:91uJzK5K8IWtYQqTi5R2tsxV1pCde+wdGfaRaOZi6aQ= github.com/micro/cli v0.2.0 h1:ut3rV5JWqZjsXIa2MvGF+qMUP8DAUTvHX9Br5gO4afA= github.com/micro/cli v0.2.0/go.mod h1:jRT9gmfVKWSS6pkKcXQ8YhUyj6bzwxK8Fp5b0Y7qNnk= +github.com/micro/cli/v2 v2.1.1 h1:uFw0SMIKmGuyHIm8lXns/NOn7V62bM5y7DnlxUM+BEQ= +github.com/micro/cli/v2 v2.1.1/go.mod h1:EguNh6DAoWKm9nmk+k/Rg0H3lQnDxqzu5x5srOtGtYg= github.com/micro/go-micro v1.16.0/go.mod h1:A0F58bHLh2m0LAI9QyhvmbN8c1cxhAZo3cM6s+iDsrM= github.com/micro/go-micro v1.17.1 h1:BhwC4Lnwr3hdci9T8kN5MEabKS+CT0QT0YH4hinTdNs= github.com/micro/go-micro v1.17.1/go.mod h1:klwUJL1gkdY1MHFyz+fFJXn52dKcty4hoe95Mp571AA= @@ -603,6 +606,7 @@ github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/rs/xid v1.2.1/go.mod h1:+uKXf+4Djp6Md1KODXJxgGQPKngRmWyn10oCKFzNHOQ= github.com/rs/zerolog v1.17.2 h1:RMRHFw2+wF7LO0QqtELQwo8hqSmqISyCJeFeAAuWcRo= github.com/rs/zerolog v1.17.2/go.mod h1:9nvC1axdVrAHcu/s9taAVfBuIdTZLVQmKQyvrUjF5+I= +github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q= github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/ryanuber/columnize v2.1.0+incompatible/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= @@ -614,6 +618,7 @@ github.com/satori/go.uuid v1.2.0/go.mod h1:dA0hQrYB0VpLJoorglMZABFdXlWrHn1NEOzdh github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= github.com/serenize/snaker v0.0.0-20171204205717-a683aaf2d516/go.mod h1:Yow6lPLSAXx2ifx470yD/nUe22Dv5vBvxK/UK9UUTVs= github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo= +github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo= github.com/shurcooL/sanitized_anchor_name v1.0.0/go.mod h1:1NzhyTcUVG4SuEtjjoZeVRXNmyL/1OwPU0+IJeTBvfc= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= diff --git a/pkg/command/health.go b/pkg/command/health.go index 549dfbdfe..1f6d23cb0 100644 --- a/pkg/command/health.go +++ b/pkg/command/health.go @@ -4,14 +4,14 @@ import ( "fmt" "net/http" - "github.com/micro/cli" + "github.com/micro/cli/v2" "github.com/owncloud/ocis-phoenix/pkg/config" "github.com/owncloud/ocis-phoenix/pkg/flagset" ) // Health is the entrypoint for the health command. -func Health(cfg *config.Config) cli.Command { - return cli.Command{ +func Health(cfg *config.Config) *cli.Command { + return &cli.Command{ Name: "health", Usage: "Check health status", Flags: flagset.HealthWithConfig(cfg), diff --git a/pkg/command/root.go b/pkg/command/root.go index 2bb057bd7..ccf44db3c 100644 --- a/pkg/command/root.go +++ b/pkg/command/root.go @@ -4,7 +4,7 @@ import ( "os" "strings" - "github.com/micro/cli" + "github.com/micro/cli/v2" "github.com/owncloud/ocis-phoenix/pkg/config" "github.com/owncloud/ocis-phoenix/pkg/flagset" "github.com/owncloud/ocis-phoenix/pkg/version" @@ -22,7 +22,7 @@ func Execute() error { Usage: "Serve Phoenix for oCIS", Compiled: version.Compiled(), - Authors: []cli.Author{ + Authors: []*cli.Author{ { Name: "ownCloud GmbH", Email: "support@owncloud.com", @@ -73,7 +73,7 @@ func Execute() error { return nil }, - Commands: []cli.Command{ + Commands: []*cli.Command{ Server(cfg), Health(cfg), }, diff --git a/pkg/command/server.go b/pkg/command/server.go index acba2b584..2e941d450 100644 --- a/pkg/command/server.go +++ b/pkg/command/server.go @@ -10,7 +10,7 @@ import ( "contrib.go.opencensus.io/exporter/jaeger" "contrib.go.opencensus.io/exporter/ocagent" "contrib.go.opencensus.io/exporter/zipkin" - "github.com/micro/cli" + "github.com/micro/cli/v2" "github.com/oklog/run" openzipkin "github.com/openzipkin/zipkin-go" zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http" @@ -19,14 +19,13 @@ import ( "github.com/owncloud/ocis-phoenix/pkg/metrics" "github.com/owncloud/ocis-phoenix/pkg/server/debug" "github.com/owncloud/ocis-phoenix/pkg/server/http" - "github.com/owncloud/ocis-pkg/conversions" "go.opencensus.io/stats/view" "go.opencensus.io/trace" ) // Server is the entrypoint for the server command. -func Server(cfg *config.Config) cli.Command { - return cli.Command{ +func Server(cfg *config.Config) *cli.Command { + return &cli.Command{ Name: "server", Usage: "Start integrated server", Flags: flagset.ServerWithConfig(cfg), @@ -35,15 +34,13 @@ func Server(cfg *config.Config) cli.Command { cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/") } + cfg.Phoenix.Config.Apps = c.StringSlice("web-config-apps") + return nil }, Action: func(c *cli.Context) error { logger := NewLogger(cfg) - if c.String("web-config-apps") != "" { - cfg.Phoenix.Config.Apps = conversions.StringToSliceString(c.String("web-config-apps"), ",") - } - if cfg.Tracing.Enabled { switch t := cfg.Tracing.Type; t { case "agent": diff --git a/pkg/flagset/flagset.go b/pkg/flagset/flagset.go index 4c66a460b..c09be2194 100644 --- a/pkg/flagset/flagset.go +++ b/pkg/flagset/flagset.go @@ -1,7 +1,7 @@ package flagset import ( - "github.com/micro/cli" + "github.com/micro/cli/v2" "github.com/owncloud/ocis-phoenix/pkg/config" ) @@ -12,26 +12,28 @@ func RootWithConfig(cfg *config.Config) []cli.Flag { Name: "config-file", Value: "", Usage: "Path to config file", - EnvVar: "PHOENIX_CONFIG_FILE", + EnvVars: []string{"PHOENIX_CONFIG_FILE"}, Destination: &cfg.File, }, &cli.StringFlag{ Name: "log-level", Value: "info", Usage: "Set logging level", - EnvVar: "PHOENIX_LOG_LEVEL", + EnvVars: []string{"PHOENIX_LOG_LEVEL"}, Destination: &cfg.Log.Level, }, - &cli.BoolTFlag{ + &cli.BoolFlag{ Name: "log-pretty", + Value: true, Usage: "Enable pretty logging", - EnvVar: "PHOENIX_LOG_PRETTY", + EnvVars: []string{"PHOENIX_LOG_PRETTY"}, Destination: &cfg.Log.Pretty, }, - &cli.BoolTFlag{ + &cli.BoolFlag{ Name: "log-color", + Value: true, Usage: "Enable colored logging", - EnvVar: "PHOENIX_LOG_COLOR", + EnvVars: []string{"PHOENIX_LOG_COLOR"}, Destination: &cfg.Log.Color, }, } @@ -44,7 +46,7 @@ func HealthWithConfig(cfg *config.Config) []cli.Flag { Name: "debug-addr", Value: "0.0.0.0:9104", Usage: "Address to debug endpoint", - EnvVar: "PHOENIX_DEBUG_ADDR", + EnvVars: []string{"PHOENIX_DEBUG_ADDR"}, Destination: &cfg.Debug.Addr, }, } @@ -56,159 +58,158 @@ func ServerWithConfig(cfg *config.Config) []cli.Flag { &cli.BoolFlag{ Name: "tracing-enabled", Usage: "Enable sending traces", - EnvVar: "PHOENIX_TRACING_ENABLED", + EnvVars: []string{"PHOENIX_TRACING_ENABLED"}, Destination: &cfg.Tracing.Enabled, }, &cli.StringFlag{ Name: "tracing-type", Value: "jaeger", Usage: "Tracing backend type", - EnvVar: "PHOENIX_TRACING_TYPE", + EnvVars: []string{"PHOENIX_TRACING_TYPE"}, Destination: &cfg.Tracing.Type, }, &cli.StringFlag{ Name: "tracing-endpoint", Value: "", Usage: "Endpoint for the agent", - EnvVar: "PHOENIX_TRACING_ENDPOINT", + EnvVars: []string{"PHOENIX_TRACING_ENDPOINT"}, Destination: &cfg.Tracing.Endpoint, }, &cli.StringFlag{ Name: "tracing-collector", Value: "", Usage: "Endpoint for the collector", - EnvVar: "PHOENIX_TRACING_COLLECTOR", + EnvVars: []string{"PHOENIX_TRACING_COLLECTOR"}, Destination: &cfg.Tracing.Collector, }, &cli.StringFlag{ Name: "tracing-service", Value: "phoenix", Usage: "Service name for tracing", - EnvVar: "PHOENIX_TRACING_SERVICE", + EnvVars: []string{"PHOENIX_TRACING_SERVICE"}, Destination: &cfg.Tracing.Service, }, &cli.StringFlag{ Name: "debug-addr", Value: "0.0.0.0:9104", Usage: "Address to bind debug server", - EnvVar: "PHOENIX_DEBUG_ADDR", + EnvVars: []string{"PHOENIX_DEBUG_ADDR"}, Destination: &cfg.Debug.Addr, }, &cli.StringFlag{ Name: "debug-token", Value: "", Usage: "Token to grant metrics access", - EnvVar: "PHOENIX_DEBUG_TOKEN", + EnvVars: []string{"PHOENIX_DEBUG_TOKEN"}, Destination: &cfg.Debug.Token, }, &cli.BoolFlag{ Name: "debug-pprof", Usage: "Enable pprof debugging", - EnvVar: "PHOENIX_DEBUG_PPROF", + EnvVars: []string{"PHOENIX_DEBUG_PPROF"}, Destination: &cfg.Debug.Pprof, }, &cli.BoolFlag{ Name: "debug-zpages", Usage: "Enable zpages debugging", - EnvVar: "PHOENIX_DEBUG_ZPAGES", + EnvVars: []string{"PHOENIX_DEBUG_ZPAGES"}, Destination: &cfg.Debug.Zpages, }, &cli.StringFlag{ Name: "http-addr", Value: "0.0.0.0:9100", Usage: "Address to bind http server", - EnvVar: "PHOENIX_HTTP_ADDR", + EnvVars: []string{"PHOENIX_HTTP_ADDR"}, Destination: &cfg.HTTP.Addr, }, &cli.StringFlag{ Name: "http-root", Value: "/", Usage: "Root path of http server", - EnvVar: "PHOENIX_HTTP_ROOT", + EnvVars: []string{"PHOENIX_HTTP_ROOT"}, Destination: &cfg.HTTP.Root, }, &cli.StringFlag{ Name: "http-namespace", Value: "com.owncloud.web", Usage: "Set the base namespace for the http namespace", - EnvVar: "PHOENIX_NAMESPACE", + EnvVars: []string{"PHOENIX_NAMESPACE"}, Destination: &cfg.HTTP.Namespace, }, &cli.StringFlag{ Name: "asset-path", Value: "", Usage: "Path to custom assets", - EnvVar: "PHOENIX_ASSET_PATH", + EnvVars: []string{"PHOENIX_ASSET_PATH"}, Destination: &cfg.Asset.Path, }, &cli.StringFlag{ Name: "web-config", Value: "", Usage: "Path to phoenix config", - EnvVar: "PHOENIX_WEB_CONFIG", + EnvVars: []string{"PHOENIX_WEB_CONFIG"}, Destination: &cfg.Phoenix.Path, }, &cli.StringFlag{ Name: "web-config-server", Value: "http://localhost:9140", Usage: "Server URL", - EnvVar: "PHOENIX_WEB_CONFIG_SERVER", + EnvVars: []string{"PHOENIX_WEB_CONFIG_SERVER"}, Destination: &cfg.Phoenix.Config.Server, }, &cli.StringFlag{ Name: "web-config-theme", Value: "owncloud", Usage: "Theme", - EnvVar: "PHOENIX_WEB_CONFIG_THEME", + EnvVars: []string{"PHOENIX_WEB_CONFIG_THEME"}, Destination: &cfg.Phoenix.Config.Theme, }, &cli.StringFlag{ Name: "web-config-version", Value: "0.1.0", Usage: "Version", - EnvVar: "PHOENIX_WEB_CONFIG_VERSION", + EnvVars: []string{"PHOENIX_WEB_CONFIG_VERSION"}, Destination: &cfg.Phoenix.Config.Version, }, - &cli.StringFlag{ - Name: "web-config-apps", - Value: "files,draw-io,pdf-viewer,markdown-editor,media-viewer", - Usage: `String with comma separated values. --web-config-apps "pdf-viewer, files, draw-io"`, - EnvVar: "PHOENIX_WEB_CONFIG_APPS", + &cli.StringSliceFlag{ + Name: "web-config-apps", + Value: cli.NewStringSlice("files", "draw-io", "pdf-viewer", "markdown-editor", "media-viewer"), + Usage: `--web-config-apps files [--web-config-apps draw-io]`, + EnvVars: []string{"PHOENIX_WEB_CONFIG_APPS"}, }, - // TODO EXTERNAL APPS? &cli.StringFlag{ Name: "oidc-metadata-url", Value: "http://localhost:9140/.well-known/openid-configuration", Usage: "OpenID Connect metadata URL", - EnvVar: "PHOENIX_OIDC_METADATA_URL", + EnvVars: []string{"PHOENIX_OIDC_METADATA_URL"}, Destination: &cfg.Phoenix.Config.OpenIDConnect.MetadataURL, }, &cli.StringFlag{ Name: "oidc-authority", Value: "http://localhost:9140", Usage: "OpenID Connect authority", // TODO rename to Issuer - EnvVar: "PHOENIX_OIDC_AUTHORITY", + EnvVars: []string{"PHOENIX_OIDC_AUTHORITY"}, Destination: &cfg.Phoenix.Config.OpenIDConnect.Authority, }, &cli.StringFlag{ Name: "oidc-client-id", Value: "phoenix", Usage: "OpenID Connect client ID", - EnvVar: "PHOENIX_OIDC_CLIENT_ID", + EnvVars: []string{"PHOENIX_OIDC_CLIENT_ID"}, Destination: &cfg.Phoenix.Config.OpenIDConnect.ClientID, }, &cli.StringFlag{ Name: "oidc-response-type", Value: "code", Usage: "OpenID Connect response type", - EnvVar: "PHOENIX_OIDC_RESPONSE_TYPE", + EnvVars: []string{"PHOENIX_OIDC_RESPONSE_TYPE"}, Destination: &cfg.Phoenix.Config.OpenIDConnect.ResponseType, }, &cli.StringFlag{ Name: "oidc-scope", Value: "openid profile email", Usage: "OpenID Connect scope", - EnvVar: "PHOENIX_OIDC_SCOPE", + EnvVars: []string{"PHOENIX_OIDC_SCOPE"}, Destination: &cfg.Phoenix.Config.OpenIDConnect.Scope, }, }