From 123aec2bd8f0acafaee33cdece6740ab692c843c Mon Sep 17 00:00:00 2001 From: neha_gupta Date: Wed, 15 Feb 2023 23:38:19 +0530 Subject: [PATCH] Handle repo connect event on - repo connect command (#2502) ## Description Create a `repo connect` event on CLI's repo connect command ## Does this PR need a docs update or release note? - [ ] :no_entry: No ## Type of change - [x] :sunflower: Feature ## Issue(s) https://github.com/alcionai/corso/issues/1762 ## Test Plan - [x] :muscle: Manual --- src/cli/repo/s3.go | 2 +- src/pkg/repository/repository.go | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/cli/repo/s3.go b/src/cli/repo/s3.go index 2dbf4cb9f..49e1bdac6 100644 --- a/src/cli/repo/s3.go +++ b/src/cli/repo/s3.go @@ -183,7 +183,7 @@ func connectS3Cmd(cmd *cobra.Command, args []string) error { return Only(ctx, errors.Wrap(err, "Failed to parse m365 account config")) } - r, err := repository.Connect(ctx, a, s, options.Control()) + r, err := repository.ConnectAndSendConnectEvent(ctx, a, s, options.Control()) if err != nil { return Only(ctx, errors.Wrap(err, "Failed to connect to the S3 repository")) } diff --git a/src/pkg/repository/repository.go b/src/pkg/repository/repository.go index da715f61e..ab4e05733 100644 --- a/src/pkg/repository/repository.go +++ b/src/pkg/repository/repository.go @@ -216,6 +216,22 @@ func Connect( }, nil } +func ConnectAndSendConnectEvent(ctx context.Context, + acct account.Account, + s storage.Storage, + opts control.Options, +) (Repository, error) { + repo, err := Connect(ctx, acct, s, opts) + + r := repo.(*repository) + + if err == nil { + r.Bus.Event(ctx, events.RepoConnect, nil) + } + + return r, err +} + func (r *repository) Close(ctx context.Context) error { if err := r.Bus.Close(); err != nil { logger.Ctx(ctx).With("err", err).Debugw("closing the event bus", clues.In(ctx).Slice()...)