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 ## Type of change - [x] 🌻 Feature ## Issue(s) https://github.com/alcionai/corso/issues/1762 ## Test Plan - [x] 💪 Manual
This commit is contained in:
parent
8d7c799204
commit
123aec2bd8
@ -183,7 +183,7 @@ func connectS3Cmd(cmd *cobra.Command, args []string) error {
|
|||||||
return Only(ctx, errors.Wrap(err, "Failed to parse m365 account config"))
|
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 {
|
if err != nil {
|
||||||
return Only(ctx, errors.Wrap(err, "Failed to connect to the S3 repository"))
|
return Only(ctx, errors.Wrap(err, "Failed to connect to the S3 repository"))
|
||||||
}
|
}
|
||||||
|
|||||||
@ -216,6 +216,22 @@ func Connect(
|
|||||||
}, nil
|
}, 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 {
|
func (r *repository) Close(ctx context.Context) error {
|
||||||
if err := r.Bus.Close(); err != nil {
|
if err := r.Bus.Close(); err != nil {
|
||||||
logger.Ctx(ctx).With("err", err).Debugw("closing the event bus", clues.In(ctx).Slice()...)
|
logger.Ctx(ctx).With("err", err).Debugw("closing the event bus", clues.In(ctx).Slice()...)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user