Previously we were printing a table for a single item which, for one
was unnecessary, but this also make the output of a backup more
compact.
Before:
```
Logging to file: /home/meain/.cache/corso/logs/2023-10-20T10-21-23Z.log
Connecting to M365 done
Connecting to repository 1s done
Backing Up ∙ Teams Testing (meain)
Discovering items to backup 27s done
Libraries (TeamsTestingmeain) done (found 0 items)
Libraries (TeamsTestingmeain-Shared0) done (found 0 items)
Libraries (TeamsTestingmeain-Private2) done (found 0 items)
Messages 7s done (found 6 channels)
Backing up data 7s done
Backup complete ∙ 7b40dd40-f808-4d57-8e39-b4553e48dc5d
ID Bytes Uploaded Items Uploaded Items Skipped Errors
7b40dd40-f808-4d57-8e39-b4553e48dc5d 0 B 0 0 0
Completed Backups:
ID Started At Duration Status Resource Owner
7b40dd40-f808-4d57-8e39-b4553e48dc5d 2023-10-20T10:21:32Z 36.632747912s Completed Teams Testing (meain)
```
After:
```
Connecting to M365 done
Connecting to repository 1s done
Backing Up ∙ Teams Testing (meain)
Discovering items to backup 31s done
Libraries (TeamsTestingmeain) done (found 0 items)
Libraries (TeamsTestingmeain-Shared0) done (found 0 items)
Libraries (TeamsTestingmeain-Private2) done (found 0 items)
Messages 9s done (found 6 channels)
Backing up data 7s done
Backup complete ∙ ffb2f619-1cb7-4a11-b3e2-7300aa513c6a
Bytes Uploaded: 0 B | Items Uploaded: 0 | Items Skipped: 0 | Errors: 0
Completed Backups:
ID ID Started At Duration Status Resource Owner
ffb2f619-1cb7-4a11-b3e2-7300aa513c6a 2023-10-20T10:23:35Z 40.096203016s Completed Teams Testing (meain)
```
---
#### Does this PR need a docs update or release note?
- [x] ✅ Yes, it's included
- [ ] 🕐 Yes, but in a later PR
- [ ] ⛔ No
#### Type of change
<!--- Please check the type of change your PR introduces: --->
- [x] 🌻 Feature
- [ ] 🐛 Bugfix
- [ ] 🗺️ Documentation
- [ ] 🤖 Supportability/Tests
- [ ] 💻 CI/Deployment
- [ ] 🧹 Tech Debt/Cleanup
#### 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
- [x] ⚡ Unit test
- [ ] 💚 E2E
76 lines
1.7 KiB
Go
76 lines
1.7 KiB
Go
package fault
|
|
|
|
import (
|
|
"github.com/alcionai/corso/src/cli/print"
|
|
)
|
|
|
|
const (
|
|
AlertPreviousPathCollision = "previous_path_collision"
|
|
)
|
|
|
|
var _ print.Printable = &Alert{}
|
|
|
|
// Alerts are informational-only notifications. The purpose of alerts is to
|
|
// provide a means of end-user communication about important events without
|
|
// needing to generate runtime failures or recoverable errors. When generating
|
|
// an alert, no other fault feature (failure, recoverable, skip, etc) should
|
|
// be in use. IE: Errors do not also get alerts, since the error itself is a
|
|
// form of end-user communication already.
|
|
type Alert struct {
|
|
Item Item `json:"item"`
|
|
Message string `json:"message"`
|
|
}
|
|
|
|
// String complies with the stringer interface.
|
|
func (a *Alert) String() string {
|
|
msg := "<nil>"
|
|
|
|
if a != nil {
|
|
msg = a.Message
|
|
}
|
|
|
|
if len(msg) == 0 {
|
|
msg = "<missing>"
|
|
}
|
|
|
|
return "Alert: " + msg
|
|
}
|
|
|
|
func (a Alert) MinimumPrintable() any {
|
|
return a
|
|
}
|
|
|
|
// Headers returns the human-readable names of properties of a skipped Item
|
|
// for printing out to a terminal.
|
|
func (a Alert) Headers(bool) []string {
|
|
// NOTE: skipID does not make sense in this context and is skipped
|
|
return []string{"Action", "Message", "Container", "Name", "ID"}
|
|
}
|
|
|
|
// Values populates the printable values matching the Headers list.
|
|
func (a Alert) Values(bool) []string {
|
|
var cn string
|
|
|
|
acn, ok := a.Item.Additional[AddtlContainerName]
|
|
if ok {
|
|
str, ok := acn.(string)
|
|
if ok {
|
|
cn = str
|
|
}
|
|
}
|
|
|
|
return []string{"Alert", a.Message, cn, a.Item.Name, a.Item.ID}
|
|
}
|
|
|
|
func NewAlert(message, namespace, itemID, name string, addtl map[string]any) *Alert {
|
|
return &Alert{
|
|
Message: message,
|
|
Item: Item{
|
|
Namespace: namespace,
|
|
ID: itemID,
|
|
Name: name,
|
|
Additional: addtl,
|
|
},
|
|
}
|
|
}
|