Add progressbar for connecting to repo and add elapsed time to progressbars (#1545)

## Description

This will now show elapsed time along with the spinner.

```
Connecting to repository:  4s done
Connecting to M365:  0s done
Discovering items to backup:  2s done
Discovered 1013 items to backup
Backing up data:4m37s done
  Started At            ID                                    Status                Selectors
  2022-11-17T11:22:35Z  cdbbf625-f925-4f59-9c42-12756108b752  Completed (0 errors)  J...L@redacted.onmicrosoft.com
```

## Type of change

<!--- Please check the type of change your PR introduces: --->
- [x] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Test
- [ ] 💻 CI/Deployment
- [ ] 🐹 Trivial/Minor

## Issue(s)

<!-- Can reference multiple issues. Use one of the following "magic words" - "closes, fixes" to auto-close the Github issue. -->
* #<issue>

## Test Plan

<!-- How will this be tested prior to merging.-->
- [ ] 💪 Manual
- [ ]  Unit test
- [ ] 💚 E2E
This commit is contained in:
Abin Simon 2022-11-18 09:05:19 +05:30 committed by GitHub
parent 07a8d13d1e
commit f114785ebb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -156,6 +156,7 @@ func MessageWithCompletion(message string) (chan<- struct{}, func()) {
mpb.SpinnerStyle(frames...).PositionLeft(),
mpb.PrependDecorators(
decor.Name(message),
decor.Elapsed(decor.ET_STYLE_GO, decor.WC{W: 4}),
),
mpb.BarFillerOnComplete("done"),
)

View File

@ -10,6 +10,7 @@ import (
"github.com/alcionai/corso/src/internal/events"
"github.com/alcionai/corso/src/internal/kopia"
"github.com/alcionai/corso/src/internal/model"
"github.com/alcionai/corso/src/internal/observe"
"github.com/alcionai/corso/src/internal/operations"
"github.com/alcionai/corso/src/pkg/account"
"github.com/alcionai/corso/src/pkg/backup"
@ -133,6 +134,10 @@ func Connect(
s storage.Storage,
opts control.Options,
) (Repository, error) {
complete, closer := observe.MessageWithCompletion("Connecting to repository:")
defer closer()
defer close(complete)
kopiaRef := kopia.NewConn(s)
if err := kopiaRef.Connect(ctx); err != nil {
return nil, err
@ -156,6 +161,8 @@ func Connect(
return nil, err
}
complete <- struct{}{}
// todo: ID and CreatedAt should get retrieved from a stored kopia config.
return &repository{
Version: "v1",