Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tweak go-micro behavior #840

Merged
merged 13 commits into from
Nov 12, 2020
7 changes: 3 additions & 4 deletions accounts/pkg/service/v0/permissions.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ package service
import (
"context"

mclient "github.com/micro/go-micro/v2/client"
"github.com/owncloud/ocis/ocis-pkg/service/grpc"

olog "github.com/owncloud/ocis/ocis-pkg/log"
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
ssvc "github.com/owncloud/ocis/settings/pkg/service/v0"
Expand All @@ -26,9 +27,7 @@ const (

// RegisterPermissions registers permissions for account management and group management with the settings service.
func RegisterPermissions(l *olog.Logger) {
// TODO this won't work with a registry other than mdns. Look into Micro's client initialization.
// https://github.com/owncloud/ocis-proxy/issues/38
service := settings.NewBundleService("com.owncloud.api.settings", mclient.DefaultClient)
service := settings.NewBundleService("com.owncloud.api.settings", grpc.DefaultClient)

permissionRequests := generateAccountManagementPermissionsRequests()
for i := range permissionRequests {
Expand Down
7 changes: 3 additions & 4 deletions accounts/pkg/service/v0/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ import (
"strings"
"time"

"github.com/owncloud/ocis/ocis-pkg/service/grpc"

"github.com/owncloud/ocis/accounts/pkg/storage"
"github.com/owncloud/ocis/ocis-pkg/indexer"
idxcfg "github.com/owncloud/ocis/ocis-pkg/indexer/config"
idxerrs "github.com/owncloud/ocis/ocis-pkg/indexer/errors"

mclient "github.com/micro/go-micro/v2/client"
"github.com/owncloud/ocis/accounts/pkg/config"
"github.com/owncloud/ocis/accounts/pkg/proto/v0"
"github.com/owncloud/ocis/ocis-pkg/log"
Expand All @@ -34,9 +35,7 @@ func New(opts ...Option) (s *Service, err error) {

roleService := options.RoleService
if roleService == nil {
// https://github.com/owncloud/ocis-proxy/issues/38
// TODO this won't work with a registry other than mdns. Look into Micro's client initialization.
roleService = settings.NewRoleService("com.owncloud.api.settings", mclient.DefaultClient)
roleService = settings.NewRoleService("com.owncloud.api.settings", grpc.DefaultClient)
}
roleManager := options.RoleManager
if roleManager == nil {
Expand Down
6 changes: 2 additions & 4 deletions accounts/pkg/service/v0/settings.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package service
import (
"context"

mclient "github.com/micro/go-micro/v2/client"
olog "github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
settings "github.com/owncloud/ocis/settings/pkg/proto/v0"
ssvc "github.com/owncloud/ocis/settings/pkg/service/v0"
)
Expand All @@ -15,9 +15,7 @@ const (

// RegisterSettingsBundles pushes the settings bundle definitions for this extension to the ocis-settings service.
func RegisterSettingsBundles(l *olog.Logger) {
// TODO this won't work with a registry other than mdns. Look into Micro's client initialization.
// https://github.com/owncloud/ocis-proxy/issues/38
service := settings.NewBundleService("com.owncloud.api.settings", mclient.DefaultClient)
service := settings.NewBundleService("com.owncloud.api.settings", grpc.DefaultClient)

bundleRequests := []settings.SaveBundleRequest{
generateBundleProfileRequest(),
Expand Down
7 changes: 4 additions & 3 deletions glauth/pkg/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (
"strings"
"time"

"github.com/owncloud/ocis/ocis-pkg/service/grpc"

"github.com/owncloud/ocis/glauth/pkg/metrics"

"github.com/owncloud/ocis/glauth/pkg/crypto"
Expand All @@ -17,7 +19,6 @@ import (
glauthcfg "github.com/glauth/glauth/pkg/config"

"github.com/micro/cli/v2"
"github.com/micro/go-micro/v2/client"
"github.com/oklog/run"
openzipkin "github.com/openzipkin/zipkin-go"
zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http"
Expand Down Expand Up @@ -309,6 +310,6 @@ func Server(cfg *config.Config) *cli.Command {

// getAccountsServices returns an ocis-accounts service
func getAccountsServices() (accounts.AccountsService, accounts.GroupsService) {
return accounts.NewAccountsService("com.owncloud.api.accounts", client.DefaultClient),
accounts.NewGroupsService("com.owncloud.api.accounts", client.DefaultClient)
return accounts.NewAccountsService("com.owncloud.api.accounts", grpc.DefaultClient),
accounts.NewGroupsService("com.owncloud.api.accounts", grpc.DefaultClient)
}
2 changes: 2 additions & 0 deletions ocis-pkg/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -775,6 +775,8 @@ github.com/micro/cli/v2 v2.1.2 h1:43J1lChg/rZCC1rvdqZNFSQDrGT7qfMrtp6/ztpIkEM=
github.com/micro/cli/v2 v2.1.2/go.mod h1:EguNh6DAoWKm9nmk+k/Rg0H3lQnDxqzu5x5srOtGtYg=
github.com/micro/go-micro/v2 v2.9.1 h1:+S9koIrNWARjpP6k2TZ7kt0uC9zUJtNXzIdZTZRms7Q=
github.com/micro/go-micro/v2 v2.9.1/go.mod h1:x55ZM3Puy0FyvvkR3e0ha0xsE9DFwfPSUMWAIbFY0SY=
github.com/micro/go-plugins v1.5.1 h1:swcFD7ynCTUo98APqIEIbPu2XMd6yVGTnI8PqdnCwOQ=
github.com/micro/go-plugins/v2 v2.0.0 h1:QbzQBaOVNtAIhjTgtLoOHtlhcwNFbcJenEsT66IwpkQ=
github.com/micro/go-plugins/wrapper/trace/opencensus/v2 v2.9.1 h1:IaZUsLp0Omb/ozDnRKEvVY56C0UocBdPxxg2S2Pk2j0=
github.com/micro/go-plugins/wrapper/trace/opencensus/v2 v2.9.1/go.mod h1:26UmOLM/I487NqTg3n6zJiBrYmIb684M2Zp4WH98XzU=
github.com/microcosm-cc/bluemonday v1.0.1/go.mod h1:hsXNsILzKxV+sX77C5b8FSuKF00vh2OMYv+xgHpAMF4=
Expand Down
28 changes: 28 additions & 0 deletions ocis-pkg/service/grpc/service.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,41 @@
package grpc

import (
"os"
"strings"
"time"

"github.com/micro/go-micro/v2"
mclient "github.com/micro/go-micro/v2/client"
"github.com/micro/go-micro/v2/client/grpc"

etcdr "github.com/micro/go-micro/v2/registry/etcd"
mdnsr "github.com/micro/go-micro/v2/registry/mdns"

"github.com/micro/go-micro/v2/registry"

"github.com/micro/go-plugins/wrapper/trace/opencensus/v2"
"github.com/owncloud/ocis/ocis-pkg/wrapper/prometheus"
)

var DefaultClient = newGrpcClient()

func newGrpcClient() mclient.Client {
var r registry.Registry
switch os.Getenv("MICRO_REGISTRY") {
case "etcd":
r = etcdr.NewRegistry()
default:
r = mdnsr.NewRegistry()
}

c := grpc.NewClient(
mclient.RequestTimeout(10*time.Second),
mclient.Registry(r),
)
return c
}

// Service simply wraps the go-micro grpc service.
type Service struct {
micro.Service
Expand All @@ -33,6 +60,7 @@ func NewService(opts ...Option) Service {
".",
),
),
micro.Client(DefaultClient),
micro.Version(sopts.Version),
micro.Address(sopts.Address),
micro.WrapHandler(prometheus.NewHandlerWrapper()),
Expand Down
2 changes: 2 additions & 0 deletions ocis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ require (
github.com/go-test/deep v1.0.6 // indirect
github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect
github.com/micro/cli/v2 v2.1.2
github.com/micro/go-micro v1.18.0
github.com/micro/go-micro/v2 v2.9.1
github.com/micro/micro/v2 v2.8.0
github.com/openzipkin/zipkin-go v0.2.5
github.com/owncloud/flaex v0.2.0
Expand Down
8 changes: 8 additions & 0 deletions ocis/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghf
github.com/cespare/xxhash/v2 v2.1.0/go.mod h1:dgIUBU3pDso/gPgZ1osOZ0iQf77oPR28Tjxl5dIMyVM=
github.com/cespare/xxhash/v2 v2.1.1 h1:6MnRN8NT7+YBpUIWxHtefFZOKTAPgGjpQSxqLNn0+qY=
github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
github.com/cheekybits/genny v1.0.0 h1:uGGa4nei+j20rOSeDeP5Of12XVm7TGUd4dJA9RDitfE=
github.com/cheekybits/genny v1.0.0/go.mod h1:+tQajlRqAUrPI7DOSpB0XAqZYtQakVtB7wXkRAgjxjQ=
github.com/cheggaaa/pb v1.0.28/go.mod h1:pQciLPpbU0oxA0h+VJYYLxO+XeDQb5pZijXscXHm81s=
github.com/cheggaaa/pb v1.0.29/go.mod h1:W40334L7FMC5JKWldsTWbdGjLo0RxUKK73K+TuPxX30=
Expand Down Expand Up @@ -351,6 +352,7 @@ github.com/glauth/glauth v1.1.3-0.20201005201919-4d42af8aacbf h1:3ejnL7OvxCJ6XiE
github.com/glauth/glauth v1.1.3-0.20201005201919-4d42af8aacbf/go.mod h1:ygO1z1pcp79iBrjbA6vqrsUxIonStjBncosl2a9/Dx8=
github.com/glauth/glauth v1.1.3-0.20201030130813-4f029234b230 h1:2oT6sD4SUhZ94BXf0NmOaKCwbkzsweBTYRPnyTDP7xY=
github.com/glauth/glauth v1.1.3-0.20201030130813-4f029234b230/go.mod h1:ygO1z1pcp79iBrjbA6vqrsUxIonStjBncosl2a9/Dx8=
github.com/glauth/glauth v1.1.3-0.20201110124627-fd3ac7e4bbdc h1:xbCdy5zNO0CBDIpXQ9l4dfwgnTmjk9B0YyRjJkRndCc=
github.com/glauth/glauth v1.1.3-0.20201110124627-fd3ac7e4bbdc/go.mod h1:ygO1z1pcp79iBrjbA6vqrsUxIonStjBncosl2a9/Dx8=
github.com/gliderlabs/ssh v0.2.2 h1:6zsha5zo/TWhRhwqCD3+EarCAgZ2yN28ipRnGPnwkI0=
github.com/gliderlabs/ssh v0.2.2/go.mod h1:U7qILu1NlMHj9FlMhZLlkCdDnU1DBEAqr0aevW3Awn0=
Expand Down Expand Up @@ -392,6 +394,7 @@ github.com/go-ldap/ldap/v3 v3.1.7/go.mod h1:5Zun81jBTabRaI8lzN7E1JjyEl1g6zI6u9pd
github.com/go-ldap/ldap/v3 v3.2.3/go.mod h1:iYS1MdmrmceOJ1QOTnRXrIs7i3kloqtmGQjRvjKpyMg=
github.com/go-ldap/ldap/v3 v3.2.4 h1:PFavAq2xTgzo/loE8qNXcQaofAaqIpI4WgaLdv+1l3E=
github.com/go-ldap/ldap/v3 v3.2.4/go.mod h1:iYS1MdmrmceOJ1QOTnRXrIs7i3kloqtmGQjRvjKpyMg=
github.com/go-log/log v0.1.0 h1:wudGTNsiGzrD5ZjgIkVZ517ugi2XRe9Q/xRCzwEO4/U=
github.com/go-log/log v0.1.0/go.mod h1:4mBwpdRMFLiuXZDCwU2lKQFsoSCo72j3HqBK9d81N2M=
github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE=
github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk=
Expand Down Expand Up @@ -841,6 +844,7 @@ github.com/longsleep/go-metrics v0.0.0-20191013204616-cddea569b0ea h1:Q5nKuCPF/m
github.com/longsleep/go-metrics v0.0.0-20191013204616-cddea569b0ea/go.mod h1:w6QO1LBkVla70FZrrF6XcB0YN+jTEYugjkn3+6RYTSM=
github.com/lucas-clemente/quic-go v0.12.1/go.mod h1:UXJJPE4RfFef/xPO5wQm0tITK8gNfqwTxjbE7s3Vb8s=
github.com/lucas-clemente/quic-go v0.13.1/go.mod h1:Vn3/Fb0/77b02SGhQk36KzOUmXgVpFfizUfW5WMaqyU=
github.com/lucas-clemente/quic-go v0.14.1 h1:c1aKoBZKOPA+49q96B1wGkibyPP0AxYh45WuAoq+87E=
github.com/lucas-clemente/quic-go v0.14.1/go.mod h1:Vn3/Fb0/77b02SGhQk36KzOUmXgVpFfizUfW5WMaqyU=
github.com/luna-duclos/instrumentedsql v1.1.2/go.mod h1:4LGbEqDnopzNAiyxPPDXhLspyunZxgPTMJBKtC6U0BQ=
github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ=
Expand All @@ -864,9 +868,11 @@ github.com/markbates/safe v1.0.0/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kN
github.com/markbates/safe v1.0.1/go.mod h1:nAqgmRi7cY2nqMc92/bSEeQA+R4OheNU2T1kNSCBdG0=
github.com/markbates/sigtx v1.0.0/go.mod h1:QF1Hv6Ic6Ca6W+T+DL0Y/ypborFKyvUY9HmuCD4VeTc=
github.com/markbates/willie v1.0.9/go.mod h1:fsrFVWl91+gXpx/6dv715j7i11fYPfZ9ZGfH0DQzY7w=
github.com/marten-seemann/chacha20 v0.2.0 h1:f40vqzzx+3GdOmzQoItkLX5WLvHgPgyYqFFIO5Gh4hQ=
github.com/marten-seemann/chacha20 v0.2.0/go.mod h1:HSdjFau7GzYRj+ahFNwsO3ouVJr1HFkWoEwNDb4TMtE=
github.com/marten-seemann/qpack v0.1.0/go.mod h1:LFt1NU/Ptjip0C2CPkhimBz5CGE3WGDAUWqna+CNTrI=
github.com/marten-seemann/qtls v0.3.2/go.mod h1:xzjG7avBwGGbdZ8dTGxlBnLArsVKLvwmjgmPuiQEcYk=
github.com/marten-seemann/qtls v0.4.1 h1:YlT8QP3WCCvvok7MGEZkMldXbyqgr8oFg5/n8Gtbkks=
github.com/marten-seemann/qtls v0.4.1/go.mod h1:pxVXcHHw1pNIt8Qo0pwSYQEoZ8yYOOPXTCZLQQunvRc=
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
Expand Down Expand Up @@ -922,9 +928,11 @@ github.com/micro/go-micro/v2 v2.0.0/go.mod h1:v7QP5UhKRt37ixjJe8DouWmg0/eE6dltr5
github.com/micro/go-micro/v2 v2.8.0/go.mod h1:hSdOM6jb6aGswjBpCeB9wJ0yVH+CugevRm/CX7NlSrQ=
github.com/micro/go-micro/v2 v2.9.1 h1:+S9koIrNWARjpP6k2TZ7kt0uC9zUJtNXzIdZTZRms7Q=
github.com/micro/go-micro/v2 v2.9.1/go.mod h1:x55ZM3Puy0FyvvkR3e0ha0xsE9DFwfPSUMWAIbFY0SY=
github.com/micro/go-plugins v1.5.1 h1:swcFD7ynCTUo98APqIEIbPu2XMd6yVGTnI8PqdnCwOQ=
github.com/micro/go-plugins/wrapper/trace/opencensus/v2 v2.0.1/go.mod h1:QrkcwcDtIs2hIJpIEhozekyf6Rfz5C36kFI8+zzCpX0=
github.com/micro/go-plugins/wrapper/trace/opencensus/v2 v2.9.1 h1:IaZUsLp0Omb/ozDnRKEvVY56C0UocBdPxxg2S2Pk2j0=
github.com/micro/go-plugins/wrapper/trace/opencensus/v2 v2.9.1/go.mod h1:26UmOLM/I487NqTg3n6zJiBrYmIb684M2Zp4WH98XzU=
github.com/micro/mdns v0.3.0 h1:bYycYe+98AXR3s8Nq5qvt6C573uFTDPIYzJemWON0QE=
github.com/micro/mdns v0.3.0/go.mod h1:KJ0dW7KmicXU2BV++qkLlmHYcVv7/hHnbtguSWt9Aoc=
github.com/micro/micro/v2 v2.8.0 h1:AMqpnKsOBnuGHjU0jVmTL17BRdsOx0FbvI/Gkl2uLrA=
github.com/micro/micro/v2 v2.8.0/go.mod h1:VTIGqEBLAMh22q72DnGd95iJSQY/3yvXd9GIIooQ69c=
Expand Down
24 changes: 22 additions & 2 deletions ocis/pkg/command/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ import (
"os"
"strings"

etcdr "github.com/micro/go-micro/v2/registry/etcd"
mdnsr "github.com/micro/go-micro/v2/registry/mdns"

"github.com/micro/go-micro/v2"
"github.com/micro/go-micro/v2/registry"

"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/ocis/pkg/config"
Expand All @@ -14,7 +20,7 @@ import (
"github.com/spf13/viper"
)

// Execute is the entry point for the ocis-ocis command.
// Execute is the entry point for the ocis command.
func Execute() error {
cfg := config.New()

Expand Down Expand Up @@ -44,7 +50,21 @@ func Execute() error {
)
}

runtime.AddMicroPlatform(app)
addresses := strings.Split(os.Getenv("MICRO_REGISTRY_ADDRESS"), ",")

var r registry.Registry
switch os.Getenv("MICRO_REGISTRY") {
case "etcd":
r = etcdr.NewRegistry(registry.Addrs(addresses...))
default:
r = mdnsr.NewRegistry()
}

opts := micro.Options{
Registry: r,
}

runtime.AddMicroPlatform(app, opts)

cli.HelpFlag = &cli.BoolFlag{
Name: "help,h",
Expand Down
2 changes: 1 addition & 1 deletion ocis/pkg/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ func Server(cfg *config.Config) *cli.Command {
return err
}

r := runtime.New()
r := runtime.New(cfg)
return r.Start()
},
}
Expand Down
13 changes: 7 additions & 6 deletions ocis/pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,13 @@ type Tracing struct {

// Config combines all available configuration parts.
type Config struct {
File string
Log Log
Debug Debug
HTTP HTTP
GRPC GRPC
Tracing Tracing
File string
Registry string
Log Log
Debug Debug
HTTP HTTP
GRPC GRPC
Tracing Tracing

Accounts *accounts.Config
Graph *graph.Config
Expand Down
6 changes: 6 additions & 0 deletions ocis/pkg/flagset/flagset.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ func HealthWithConfig(cfg *config.Config) []cli.Flag {
// ServerWithConfig applies cfg to the root flagset
func ServerWithConfig(cfg *config.Config) []cli.Flag {
return []cli.Flag{
&cli.StringFlag{
Name: "registry",
Usage: "Enable sending traces",
EnvVars: []string{"OCIS_REGISTRY"},
Destination: &cfg.Registry,
},
&cli.BoolFlag{
Name: "tracing-enabled",
Usage: "Enable sending traces",
Expand Down
21 changes: 14 additions & 7 deletions ocis/pkg/runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ import (
"os"
"time"

"github.com/micro/go-micro/v2"
"github.com/owncloud/ocis/ocis/pkg/config"

cli "github.com/micro/cli/v2"

"github.com/micro/micro/v2/client/api"
Expand Down Expand Up @@ -63,11 +66,15 @@ var (
)

// Runtime represents an oCIS runtime environment.
type Runtime struct{}
type Runtime struct {
c *config.Config
}

// New creates a new ocis + micro runtime
func New() Runtime {
return Runtime{}
func New(cfg *config.Config) Runtime {
return Runtime{
c: cfg,
}
}

// Start rpc runtime
Expand Down Expand Up @@ -129,12 +136,12 @@ func RunService(client *rpc.Client, service string) int {
}

// AddMicroPlatform adds the micro subcommands to the cli app
func AddMicroPlatform(app *cli.App) {
func AddMicroPlatform(app *cli.App, opts micro.Options) {
setDefaults()

app.Commands = append(app.Commands, api.Commands()...)
app.Commands = append(app.Commands, web.Commands()...)
app.Commands = append(app.Commands, registry.Commands()...)
app.Commands = append(app.Commands, api.Commands(micro.Registry(opts.Registry))...)
app.Commands = append(app.Commands, web.Commands(micro.Registry(opts.Registry))...)
app.Commands = append(app.Commands, registry.Commands(micro.Registry(opts.Registry))...)
}

// provide a config.Config with default values?
Expand Down
6 changes: 2 additions & 4 deletions ocs/pkg/service/v0/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"github.com/go-chi/chi/middleware"
"github.com/go-chi/render"
"github.com/micro/go-micro/v2/client/grpc"
ogrpc "github.com/owncloud/ocis/ocis-pkg/service/grpc"

mclient "github.com/micro/go-micro/v2/client"
accounts "github.com/owncloud/ocis/accounts/pkg/proto/v0"
"github.com/owncloud/ocis/ocis-pkg/account"
"github.com/owncloud/ocis/ocis-pkg/log"
Expand Down Expand Up @@ -39,9 +39,7 @@ func NewService(opts ...Option) Service {

roleService := options.RoleService
if roleService == nil {
// https://github.com/owncloud/ocis-proxy/issues/38
// TODO this won't work with a registry other than mdns. Look into Micro's client initialization.
roleService = settings.NewRoleService("com.owncloud.api.settings", mclient.DefaultClient)
roleService = settings.NewRoleService("com.owncloud.api.settings", ogrpc.DefaultClient)
}
roleManager := options.RoleManager
if roleManager == nil {
Expand Down
8 changes: 3 additions & 5 deletions proxy/pkg/command/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ import (
"github.com/coreos/go-oidc"
"github.com/justinas/alice"
"github.com/micro/cli/v2"
mclient "github.com/micro/go-micro/v2/client"
"github.com/micro/go-micro/v2/client/grpc"
"github.com/oklog/run"
openzipkin "github.com/openzipkin/zipkin-go"
zipkinhttp "github.com/openzipkin/zipkin-go/reporter/http"
acc "github.com/owncloud/ocis/accounts/pkg/proto/v0"
"github.com/owncloud/ocis/ocis-pkg/log"
ogrpc "github.com/owncloud/ocis/ocis-pkg/service/grpc"
"github.com/owncloud/ocis/proxy/pkg/config"
"github.com/owncloud/ocis/proxy/pkg/cs3"
"github.com/owncloud/ocis/proxy/pkg/flagset"
Expand Down Expand Up @@ -252,10 +252,8 @@ func loadMiddlewares(ctx context.Context, l log.Logger, cfg *config.Config) alic
middleware.PreSignedURLConfig(cfg.PreSignedURL),
)

// TODO this won't work with a registry other than mdns. Look into Micro's client initialization.
// https://github.com/owncloud/ocis/proxy/issues/38
accounts := acc.NewAccountsService("com.owncloud.api.accounts", mclient.DefaultClient)
roles := settings.NewRoleService("com.owncloud.api.settings", mclient.DefaultClient)
accounts := acc.NewAccountsService("com.owncloud.api.accounts", ogrpc.DefaultClient)
roles := settings.NewRoleService("com.owncloud.api.settings", ogrpc.DefaultClient)

uuidMW := middleware.AccountUUID(
middleware.Logger(l),
Expand Down