2020-09-21 10:07:12 +00:00
|
|
|
package container
|
|
|
|
|
|
|
|
import (
|
|
|
|
"errors"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container"
|
|
|
|
cid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/container/id"
|
|
|
|
frostfscrypto "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/crypto"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/eacl"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/session"
|
2020-09-21 10:07:12 +00:00
|
|
|
)
|
|
|
|
|
2023-02-05 15:59:38 +00:00
|
|
|
// Container groups information about the FrostFS container stored in the FrostFS network.
|
2022-06-22 10:55:31 +00:00
|
|
|
type Container struct {
|
|
|
|
// Container structure.
|
2022-06-28 07:01:05 +00:00
|
|
|
Value container.Container
|
2022-06-22 10:55:31 +00:00
|
|
|
|
|
|
|
// Signature of the Value.
|
2022-12-23 17:35:35 +00:00
|
|
|
Signature frostfscrypto.Signature
|
2022-06-22 10:55:31 +00:00
|
|
|
|
|
|
|
// Session within which Value was created. Nil means session absence.
|
|
|
|
Session *session.Container
|
|
|
|
}
|
|
|
|
|
2020-09-21 10:07:12 +00:00
|
|
|
// Source is an interface that wraps
|
|
|
|
// basic container receiving method.
|
|
|
|
type Source interface {
|
2022-04-21 11:28:05 +00:00
|
|
|
// Get reads the container from the storage by its identifier.
|
|
|
|
// It returns the pointer to the requested container and any error encountered.
|
2020-09-21 10:07:12 +00:00
|
|
|
//
|
|
|
|
// Get must return exactly one non-nil value.
|
2022-04-21 11:28:05 +00:00
|
|
|
// Get must return an error of type apistatus.ContainerNotFound if the container is not in the storage.
|
2020-09-21 10:07:12 +00:00
|
|
|
//
|
|
|
|
// Implementations must not retain the container pointer and modify
|
|
|
|
// the container through it.
|
2022-06-22 10:55:31 +00:00
|
|
|
Get(cid.ID) (*Container, error)
|
2020-09-21 10:07:12 +00:00
|
|
|
}
|
|
|
|
|
2022-04-21 11:28:05 +00:00
|
|
|
// IsErrNotFound checks if the error returned by Source.Get corresponds
|
|
|
|
// to the missing container.
|
2022-03-17 08:17:45 +00:00
|
|
|
func IsErrNotFound(err error) bool {
|
|
|
|
return errors.As(err, new(apistatus.ContainerNotFound))
|
|
|
|
}
|
2020-11-24 12:49:02 +00:00
|
|
|
|
2023-02-05 15:59:38 +00:00
|
|
|
// EACL groups information about the FrostFS container's extended ACL stored in
|
|
|
|
// the FrostFS network.
|
2022-06-22 10:55:31 +00:00
|
|
|
type EACL struct {
|
|
|
|
// Extended ACL structure.
|
|
|
|
Value *eacl.Table
|
|
|
|
|
|
|
|
// Signature of the Value.
|
2022-12-23 17:35:35 +00:00
|
|
|
Signature frostfscrypto.Signature
|
2022-06-22 10:55:31 +00:00
|
|
|
|
|
|
|
// Session within which Value was set. Nil means session absence.
|
|
|
|
Session *session.Container
|
|
|
|
}
|
2022-09-08 10:32:25 +00:00
|
|
|
|
|
|
|
// EACLSource is the interface that wraps
|
|
|
|
// basic methods of extended ACL table source.
|
|
|
|
type EACLSource interface {
|
|
|
|
// GetEACL reads the table from the source by identifier.
|
|
|
|
// It returns any error encountered.
|
|
|
|
//
|
|
|
|
// GetEACL must return exactly one non-nil value.
|
|
|
|
//
|
|
|
|
// Must return apistatus.ErrEACLNotFound if requested
|
|
|
|
// eACL table is not in source.
|
|
|
|
GetEACL(cid.ID) (*EACL, error)
|
|
|
|
}
|