From 17b7c8242588200163b231d12d521647b7350de4 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Fri, 23 Oct 2020 12:23:33 +0200 Subject: [PATCH] basic wiring --- accounts/pkg/command/rebuild_index.go | 25 +++++++++++++++++++++---- accounts/pkg/command/root.go | 1 + accounts/pkg/service/v0/index.go | 2 +- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/accounts/pkg/command/rebuild_index.go b/accounts/pkg/command/rebuild_index.go index 230a969030..b4df1d55f2 100644 --- a/accounts/pkg/command/rebuild_index.go +++ b/accounts/pkg/command/rebuild_index.go @@ -1,15 +1,32 @@ package command import ( + "context" + "fmt" + "github.com/micro/cli/v2" + "github.com/micro/go-micro/v2/client/grpc" "github.com/owncloud/ocis/accounts/pkg/config" + index "github.com/owncloud/ocis/accounts/pkg/proto/v0" ) +// DeleteIndex rebuilds the entire configured index. func DeleteIndex(cdf *config.Config) *cli.Command { return &cli.Command{ - Name: "add", - Usage: "Create a new account", - Aliases: []string{"create", "a"}, - //Flags: flagset.AddAccountWithConfig(cfg, a), + Name: "rebuildIndex", + Usage: "Rebuilds the service's index", + Aliases: []string{"rebuild", "ri"}, + Action: func(ctx *cli.Context) error { + idxSvcID := "com.owncloud.api.accounts" + idxSvc := index.NewIndexService(idxSvcID, grpc.NewClient()) + + rsp, err := idxSvc.RebuildIndex(context.Background(), &index.RebuildIndexRequest{}) + if err != nil { + return err + } + + fmt.Printf("deleted: %+v", rsp.Indices) + return nil + }, } } diff --git a/accounts/pkg/command/root.go b/accounts/pkg/command/root.go index ad7776bcaa..68c6192f0d 100644 --- a/accounts/pkg/command/root.go +++ b/accounts/pkg/command/root.go @@ -49,6 +49,7 @@ func Execute() error { InspectAccount(cfg), RemoveAccount(cfg), PrintVersion(cfg), + DeleteIndex(cfg), }, } diff --git a/accounts/pkg/service/v0/index.go b/accounts/pkg/service/v0/index.go index cb5d3d704a..94653b41cb 100644 --- a/accounts/pkg/service/v0/index.go +++ b/accounts/pkg/service/v0/index.go @@ -10,6 +10,6 @@ func (s Service) RebuildIndex(ctx context.Context, request *proto.RebuildIndexRe if err := s.index.Reset(); err != nil { return err } - + response.Indices = []string{"foo", "bar"} return nil }