2020-12-22 00:25:49 +00:00
|
|
|
package audit
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
2021-11-10 07:08:33 +00:00
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/container"
|
|
|
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
|
|
|
"github.com/nspcc-dev/neofs-sdk-go/netmap"
|
2022-01-26 12:11:13 +00:00
|
|
|
oidSDK "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
2020-12-22 00:25:49 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Task groups groups the container audit parameters.
|
|
|
|
type Task struct {
|
|
|
|
reporter Reporter
|
|
|
|
|
|
|
|
auditContext context.Context
|
|
|
|
|
2021-05-31 11:03:17 +00:00
|
|
|
cid *cid.ID
|
2020-12-22 00:25:49 +00:00
|
|
|
|
|
|
|
cnr *container.Container
|
|
|
|
|
2020-12-23 09:51:37 +00:00
|
|
|
nm *netmap.Netmap
|
|
|
|
|
2020-12-22 00:25:49 +00:00
|
|
|
cnrNodes netmap.ContainerNodes
|
|
|
|
|
2022-03-28 13:15:15 +00:00
|
|
|
sgList []oidSDK.ID
|
2020-12-22 00:25:49 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// WithReporter sets audit report writer.
|
|
|
|
func (t *Task) WithReporter(r Reporter) *Task {
|
|
|
|
if t != nil {
|
|
|
|
t.reporter = r
|
|
|
|
}
|
|
|
|
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reporter returns audit report writer.
|
|
|
|
func (t *Task) Reporter() Reporter {
|
|
|
|
return t.reporter
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithAuditContext sets context of the audit of the current epoch.
|
|
|
|
func (t *Task) WithAuditContext(ctx context.Context) *Task {
|
|
|
|
if t != nil {
|
|
|
|
t.auditContext = ctx
|
|
|
|
}
|
|
|
|
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
|
|
|
// AuditContext returns context of the audit of the current epoch.
|
|
|
|
func (t *Task) AuditContext() context.Context {
|
|
|
|
return t.auditContext
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithContainerID sets identifier of the container under audit.
|
2021-05-31 11:03:17 +00:00
|
|
|
func (t *Task) WithContainerID(cid *cid.ID) *Task {
|
2020-12-22 00:25:49 +00:00
|
|
|
if t != nil {
|
|
|
|
t.cid = cid
|
|
|
|
}
|
|
|
|
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
|
|
|
// ContainerID returns identifier of the container under audit.
|
2021-05-31 11:03:17 +00:00
|
|
|
func (t *Task) ContainerID() *cid.ID {
|
2020-12-22 00:25:49 +00:00
|
|
|
return t.cid
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithContainerStructure sets structure of the container under audit.
|
|
|
|
func (t *Task) WithContainerStructure(cnr *container.Container) *Task {
|
|
|
|
if t != nil {
|
|
|
|
t.cnr = cnr
|
|
|
|
}
|
|
|
|
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
|
|
|
// ContainerStructure returns structure of the container under audit.
|
|
|
|
func (t *Task) ContainerStructure() *container.Container {
|
|
|
|
return t.cnr
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithContainerNodes sets nodes in the container under audit.
|
|
|
|
func (t *Task) WithContainerNodes(cnrNodes netmap.ContainerNodes) *Task {
|
|
|
|
if t != nil {
|
|
|
|
t.cnrNodes = cnrNodes
|
|
|
|
}
|
|
|
|
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
2020-12-23 09:51:37 +00:00
|
|
|
// NetworkMap returns network map of audit epoch.
|
|
|
|
func (t *Task) NetworkMap() *netmap.Netmap {
|
|
|
|
return t.nm
|
|
|
|
}
|
|
|
|
|
|
|
|
// WithNetworkMap sets network map of audit epoch.
|
|
|
|
func (t *Task) WithNetworkMap(nm *netmap.Netmap) *Task {
|
|
|
|
if t != nil {
|
|
|
|
t.nm = nm
|
|
|
|
}
|
|
|
|
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
2020-12-22 00:25:49 +00:00
|
|
|
// ContainerNodes returns nodes in the container under audit.
|
|
|
|
func (t *Task) ContainerNodes() netmap.ContainerNodes {
|
|
|
|
return t.cnrNodes
|
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// WithStorageGroupList sets a list of storage groups from container under audit.
|
2022-03-28 13:15:15 +00:00
|
|
|
func (t *Task) WithStorageGroupList(sgList []oidSDK.ID) *Task {
|
2020-12-22 00:25:49 +00:00
|
|
|
if t != nil {
|
|
|
|
t.sgList = sgList
|
|
|
|
}
|
|
|
|
|
|
|
|
return t
|
|
|
|
}
|
|
|
|
|
|
|
|
// StorageGroupList returns list of storage groups from container under audit.
|
2022-03-28 13:15:15 +00:00
|
|
|
func (t *Task) StorageGroupList() []oidSDK.ID {
|
2020-12-22 00:25:49 +00:00
|
|
|
return t.sgList
|
|
|
|
}
|