rename ownerName to protectedResourceName (#3513)
#### Does this PR need a docs update or release note? - [x] ✅ Yes, it's included #### Type of change - [x] 🧹 Tech Debt/Cleanup #### Issue(s) * #3478 #### Test Plan - [x] ⚡ Unit test
This commit is contained in:
parent
cd7c63ba6f
commit
6e4f30d892
@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
## [Unreleased] (beta)
|
## [Unreleased] (beta)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
- Added OwnerName to the backup list json output. OwnerName holds either a UPN or a WebURL, depending on the resource type.
|
- Added ProtectedResourceName to the backup list json output. ProtectedResourceName holds either a UPN or a WebURL, depending on the resource type.
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
- Fix Exchange folder cache population error when parent folder isn't found.
|
- Fix Exchange folder cache population error when parent folder isn't found.
|
||||||
|
|||||||
@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
"github.com/alcionai/corso/src/cli/print"
|
"github.com/alcionai/corso/src/cli/print"
|
||||||
"github.com/alcionai/corso/src/internal/common/dttm"
|
"github.com/alcionai/corso/src/internal/common/dttm"
|
||||||
|
"github.com/alcionai/corso/src/internal/common/str"
|
||||||
"github.com/alcionai/corso/src/internal/model"
|
"github.com/alcionai/corso/src/internal/model"
|
||||||
"github.com/alcionai/corso/src/internal/stats"
|
"github.com/alcionai/corso/src/internal/stats"
|
||||||
"github.com/alcionai/corso/src/pkg/fault"
|
"github.com/alcionai/corso/src/pkg/fault"
|
||||||
@ -35,9 +36,10 @@ type Backup struct {
|
|||||||
// Selector used in this operation
|
// Selector used in this operation
|
||||||
Selector selectors.Selector `json:"selectors"`
|
Selector selectors.Selector `json:"selectors"`
|
||||||
|
|
||||||
// ResourceOwner reference
|
// TODO: in process of gaining support, most cases will still use
|
||||||
ResourceOwnerID string `json:"resourceOwnerID"`
|
// ResourceOwner and ResourceOwnerName.
|
||||||
ResourceOwnerName string `json:"resourceOwnerName"`
|
ProtectedResourceID string `json:"protectedResourceID,omitempty"`
|
||||||
|
ProtectedResourceName string `json:"protectedResourceName,omitempty"`
|
||||||
|
|
||||||
// Version represents the version of the backup format
|
// Version represents the version of the backup format
|
||||||
Version int `json:"version"`
|
Version int `json:"version"`
|
||||||
@ -59,6 +61,10 @@ type Backup struct {
|
|||||||
// Reference to the backup details storage location.
|
// Reference to the backup details storage location.
|
||||||
// Used to read backup.Details from the streamstore.
|
// Used to read backup.Details from the streamstore.
|
||||||
DetailsID string `json:"detailsID"`
|
DetailsID string `json:"detailsID"`
|
||||||
|
|
||||||
|
// prefer protectedResource
|
||||||
|
ResourceOwnerID string `json:"resourceOwnerID,omitempty"`
|
||||||
|
ResourceOwnerName string `json:"resourceOwnerName,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// interface compliance checks
|
// interface compliance checks
|
||||||
@ -170,8 +176,9 @@ type Printable struct {
|
|||||||
ID model.StableID `json:"id"`
|
ID model.StableID `json:"id"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
Owner string `json:"owner"`
|
ProtectedResourceID string `json:"protectedResourceID,omitempty"`
|
||||||
OwnerName string `json:"ownerName"`
|
ProtectedResourceName string `json:"protectedResourceName,omitempty"`
|
||||||
|
Owner string `json:"owner,omitempty"`
|
||||||
Stats backupStats `json:"stats"`
|
Stats backupStats `json:"stats"`
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -181,8 +188,9 @@ func (b Backup) ToPrintable() Printable {
|
|||||||
ID: b.ID,
|
ID: b.ID,
|
||||||
Status: b.Status,
|
Status: b.Status,
|
||||||
Version: "0",
|
Version: "0",
|
||||||
|
ProtectedResourceID: b.Selector.DiscreteOwner,
|
||||||
|
ProtectedResourceName: b.Selector.DiscreteOwnerName,
|
||||||
Owner: b.Selector.DiscreteOwner,
|
Owner: b.Selector.DiscreteOwner,
|
||||||
OwnerName: b.Selector.DiscreteOwnerName,
|
|
||||||
Stats: b.toStats(),
|
Stats: b.toStats(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,15 +260,12 @@ func (b Backup) Values() []string {
|
|||||||
status += (")")
|
status += (")")
|
||||||
}
|
}
|
||||||
|
|
||||||
name := b.ResourceOwnerName
|
name := str.First(
|
||||||
|
b.ProtectedResourceName,
|
||||||
if len(name) == 0 {
|
b.ResourceOwnerName,
|
||||||
name = b.ResourceOwnerID
|
b.ProtectedResourceID,
|
||||||
}
|
b.ResourceOwnerID,
|
||||||
|
b.Selector.Name())
|
||||||
if len(name) == 0 {
|
|
||||||
name = b.Selector.DiscreteOwner
|
|
||||||
}
|
|
||||||
|
|
||||||
bs := b.toStats()
|
bs := b.toStats()
|
||||||
|
|
||||||
|
|||||||
@ -40,6 +40,10 @@ func stubBackup(t time.Time, ownerID, ownerName string) backup.Backup {
|
|||||||
CreationTime: t,
|
CreationTime: t,
|
||||||
SnapshotID: "snapshot",
|
SnapshotID: "snapshot",
|
||||||
DetailsID: "details",
|
DetailsID: "details",
|
||||||
|
ProtectedResourceID: ownerID + "-pr",
|
||||||
|
ProtectedResourceName: ownerName + "-pr",
|
||||||
|
ResourceOwnerID: ownerID + "-ro",
|
||||||
|
ResourceOwnerName: ownerName + "-ro",
|
||||||
Status: "status",
|
Status: "status",
|
||||||
Selector: sel.Selector,
|
Selector: sel.Selector,
|
||||||
ErrorCount: 2,
|
ErrorCount: 2,
|
||||||
@ -80,7 +84,7 @@ func (suite *BackupUnitSuite) TestBackup_HeadersValues() {
|
|||||||
nowFmt,
|
nowFmt,
|
||||||
"1m0s",
|
"1m0s",
|
||||||
"status (2 errors, 1 skipped: 1 malware)",
|
"status (2 errors, 1 skipped: 1 malware)",
|
||||||
"test",
|
"name-pr",
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -94,6 +98,42 @@ func (suite *BackupUnitSuite) TestBackup_HeadersValues() {
|
|||||||
assert.Equal(t, expectVs, vs)
|
assert.Equal(t, expectVs, vs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (suite *BackupUnitSuite) TestBackup_HeadersValues_onlyResourceOwners() {
|
||||||
|
var (
|
||||||
|
t = suite.T()
|
||||||
|
now = time.Now()
|
||||||
|
later = now.Add(1 * time.Minute)
|
||||||
|
b = stubBackup(now, "id", "name")
|
||||||
|
expectHs = []string{
|
||||||
|
"ID",
|
||||||
|
"Started At",
|
||||||
|
"Duration",
|
||||||
|
"Status",
|
||||||
|
"Resource Owner",
|
||||||
|
}
|
||||||
|
nowFmt = dttm.FormatToTabularDisplay(now)
|
||||||
|
expectVs = []string{
|
||||||
|
"id",
|
||||||
|
nowFmt,
|
||||||
|
"1m0s",
|
||||||
|
"status (2 errors, 1 skipped: 1 malware)",
|
||||||
|
"name-ro",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
b.ProtectedResourceID = ""
|
||||||
|
b.ProtectedResourceName = ""
|
||||||
|
|
||||||
|
b.StartAndEndTime.CompletedAt = later
|
||||||
|
|
||||||
|
// single skipped malware
|
||||||
|
hs := b.Headers()
|
||||||
|
assert.Equal(t, expectHs, hs)
|
||||||
|
|
||||||
|
vs := b.Values()
|
||||||
|
assert.Equal(t, expectVs, vs)
|
||||||
|
}
|
||||||
|
|
||||||
func (suite *BackupUnitSuite) TestBackup_Values_statusVariations() {
|
func (suite *BackupUnitSuite) TestBackup_Values_statusVariations() {
|
||||||
table := []struct {
|
table := []struct {
|
||||||
name string
|
name string
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user