show data category in backup list (#5023)
Adds the backup's data category to the cli output. before: ``` ID Started At Duration Status Resource Owner 09e8d1e3-92d4-426d-9ca1-3cd063ce8bb9 2024-01-12T17:54:33Z 16.103569s Completed rfinders@10rqc2.onmicrosoft.com 893ef934-9403-4775-b667-09f77cd26e83 2024-01-12T17:55:22Z 5.66253s Completed rfinders@10rqc2.onmicrosoft.com ``` after: ``` ID Started at Duration Status Protected resource Data 09e8d1e3-92d4-426d-9ca1-3cd063ce8bb9 2024-01-12T17:54:33Z 16.103569s Completed rfinders@10rqc2.onmicrosoft.com Contacts,Emails,Events 893ef934-9403-4775-b667-09f77cd26e83 2024-01-12T17:55:22Z 5.66253s Completed rfinders@10rqc2.onmicrosoft.com Emails ``` --- #### Does this PR need a docs update or release note? - [x] ⛔ No #### Type of change - [x] 🌻 Feature #### Issue(s) * #3748 #### Test Plan - [x] 💪 Manual - [x] ⚡ Unit test
This commit is contained in:
parent
214d8a6030
commit
e1457c23bf
@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
- When running `backup details` on an empty backup returns a more helpful error message.
|
- When running `backup details` on an empty backup returns a more helpful error message.
|
||||||
|
- Backup List additionally shows the data category for each backup.
|
||||||
|
|
||||||
### Known issues
|
### Known issues
|
||||||
- Backing up a group mailbox item may fail if it has a very large number of attachments (500+).
|
- Backing up a group mailbox item may fail if it has a very large number of attachments (500+).
|
||||||
|
|||||||
@ -3,6 +3,7 @@ package backup
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -16,6 +17,7 @@ import (
|
|||||||
"github.com/alcionai/corso/src/internal/version"
|
"github.com/alcionai/corso/src/internal/version"
|
||||||
"github.com/alcionai/corso/src/pkg/dttm"
|
"github.com/alcionai/corso/src/pkg/dttm"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
|
"github.com/alcionai/corso/src/pkg/logger"
|
||||||
"github.com/alcionai/corso/src/pkg/selectors"
|
"github.com/alcionai/corso/src/pkg/selectors"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -226,17 +228,19 @@ func (b Backup) MinimumPrintable() any {
|
|||||||
// for printing out to a terminal in a columnar display.
|
// for printing out to a terminal in a columnar display.
|
||||||
func (b Backup) Headers(skipID bool) []string {
|
func (b Backup) Headers(skipID bool) []string {
|
||||||
headers := []string{
|
headers := []string{
|
||||||
"Started At",
|
"ID",
|
||||||
|
"Started at",
|
||||||
"Duration",
|
"Duration",
|
||||||
"Status",
|
"Status",
|
||||||
"Resource Owner",
|
"Protected resource",
|
||||||
|
"Data",
|
||||||
}
|
}
|
||||||
|
|
||||||
if skipID {
|
if skipID {
|
||||||
return headers
|
headers = headers[1:]
|
||||||
}
|
}
|
||||||
|
|
||||||
return append([]string{"ID"}, headers...)
|
return headers
|
||||||
}
|
}
|
||||||
|
|
||||||
// Values returns the values matching the Headers list for printing
|
// Values returns the values matching the Headers list for printing
|
||||||
@ -292,18 +296,33 @@ func (b Backup) Values(skipID bool) []string {
|
|||||||
|
|
||||||
bs := b.toStats()
|
bs := b.toStats()
|
||||||
|
|
||||||
|
reasons, err := b.Selector.Reasons("doesnt-matter", false)
|
||||||
|
if err != nil {
|
||||||
|
logger.CtxErr(context.Background(), err).Error("getting reasons from selector")
|
||||||
|
}
|
||||||
|
|
||||||
|
reasonCats := []string{}
|
||||||
|
|
||||||
|
for _, r := range reasons {
|
||||||
|
reasonCats = append(reasonCats, r.Category().HumanString())
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Strings(reasonCats)
|
||||||
|
|
||||||
values := []string{
|
values := []string{
|
||||||
|
string(b.ID),
|
||||||
dttm.FormatToTabularDisplay(b.StartedAt),
|
dttm.FormatToTabularDisplay(b.StartedAt),
|
||||||
bs.EndedAt.Sub(bs.StartedAt).String(),
|
bs.EndedAt.Sub(bs.StartedAt).String(),
|
||||||
status,
|
status,
|
||||||
name,
|
name,
|
||||||
|
strings.Join(reasonCats, ","),
|
||||||
}
|
}
|
||||||
|
|
||||||
if skipID {
|
if skipID {
|
||||||
return values
|
values = values[1:]
|
||||||
}
|
}
|
||||||
|
|
||||||
return append([]string{string(b.ID)}, values...)
|
return values
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----- print backup stats
|
// ----- print backup stats
|
||||||
|
|||||||
@ -155,10 +155,11 @@ func (suite *BackupUnitSuite) TestBackup_HeadersValues() {
|
|||||||
b = stubBackup(now, "id", "name")
|
b = stubBackup(now, "id", "name")
|
||||||
expectHs = []string{
|
expectHs = []string{
|
||||||
"ID",
|
"ID",
|
||||||
"Started At",
|
"Started at",
|
||||||
"Duration",
|
"Duration",
|
||||||
"Status",
|
"Status",
|
||||||
"Resource Owner",
|
"Protected resource",
|
||||||
|
"Data",
|
||||||
}
|
}
|
||||||
nowFmt = dttm.FormatToTabularDisplay(now)
|
nowFmt = dttm.FormatToTabularDisplay(now)
|
||||||
expectVs = []string{
|
expectVs = []string{
|
||||||
@ -167,6 +168,7 @@ func (suite *BackupUnitSuite) TestBackup_HeadersValues() {
|
|||||||
"1m0s",
|
"1m0s",
|
||||||
"status (2 errors, 1 skipped: 1 malware)",
|
"status (2 errors, 1 skipped: 1 malware)",
|
||||||
"name-pr",
|
"name-pr",
|
||||||
|
"Contacts,Emails,Events",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -194,10 +196,11 @@ func (suite *BackupUnitSuite) TestBackup_HeadersValues_onlyResourceOwners() {
|
|||||||
b = stubBackup(now, "id", "name")
|
b = stubBackup(now, "id", "name")
|
||||||
expectHs = []string{
|
expectHs = []string{
|
||||||
"ID",
|
"ID",
|
||||||
"Started At",
|
"Started at",
|
||||||
"Duration",
|
"Duration",
|
||||||
"Status",
|
"Status",
|
||||||
"Resource Owner",
|
"Protected resource",
|
||||||
|
"Data",
|
||||||
}
|
}
|
||||||
nowFmt = dttm.FormatToTabularDisplay(now)
|
nowFmt = dttm.FormatToTabularDisplay(now)
|
||||||
expectVs = []string{
|
expectVs = []string{
|
||||||
@ -206,6 +209,7 @@ func (suite *BackupUnitSuite) TestBackup_HeadersValues_onlyResourceOwners() {
|
|||||||
"1m0s",
|
"1m0s",
|
||||||
"status (2 errors, 1 skipped: 1 malware)",
|
"status (2 errors, 1 skipped: 1 malware)",
|
||||||
"name-ro",
|
"name-ro",
|
||||||
|
"Contacts,Emails,Events",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user