forked from TrueCloudLab/frostfs-api-go
[#146] sdk/object: Move well-known header const to object type
Extended ACL filters and object search filters use strings to specify well-known object headers, such as owner id, object id, etc. To unify these constant they've been moved into object package, because they specifying object related headers. This should be noted in nspcc-dev/neofs-spec#12 Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
2a7e91fa13
commit
f60069ec9f
4 changed files with 35 additions and 28 deletions
|
@ -59,32 +59,6 @@ const (
|
||||||
HeaderFromObject
|
HeaderFromObject
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
|
||||||
// ReservedHeaderNamePrefix used in filter names to specify well known
|
|
||||||
// headers such as container id, object id, owner id, etc.
|
|
||||||
// All names without this prefix used to lookup through user defined headers
|
|
||||||
// in object or x-headers in request.
|
|
||||||
ReservedHeaderNamePrefix = "_"
|
|
||||||
|
|
||||||
// HdrObjSysNameID is a name of ID field in system header of object.
|
|
||||||
HdrObjSysNameID = ReservedHeaderNamePrefix + "ID"
|
|
||||||
|
|
||||||
// HdrObjSysNameCID is a name of cid field in system header of object.
|
|
||||||
HdrObjSysNameCID = ReservedHeaderNamePrefix + "CID"
|
|
||||||
|
|
||||||
// HdrObjSysNameOwnerID is a name of OwnerID field in system header of object.
|
|
||||||
HdrObjSysNameOwnerID = ReservedHeaderNamePrefix + "OWNER_ID"
|
|
||||||
|
|
||||||
// HdrObjSysNameVersion is a name of version field in system header of object.
|
|
||||||
HdrObjSysNameVersion = ReservedHeaderNamePrefix + "VERSION"
|
|
||||||
|
|
||||||
// HdrObjSysNamePayloadLength is a name of PayloadLength field in system header of object.
|
|
||||||
HdrObjSysNamePayloadLength = ReservedHeaderNamePrefix + "PAYLOAD_LENGTH"
|
|
||||||
|
|
||||||
// HdrObjSysNameCreatedEpoch is a name of CreatedAt.Epoch field in system header of object.
|
|
||||||
HdrObjSysNameCreatedEpoch = ReservedHeaderNamePrefix + "CREATED_EPOCH"
|
|
||||||
)
|
|
||||||
|
|
||||||
func (a Action) ToV2() v2acl.Action {
|
func (a Action) ToV2() v2acl.Action {
|
||||||
switch a {
|
switch a {
|
||||||
case ActionAllow:
|
case ActionAllow:
|
||||||
|
|
|
@ -3,6 +3,7 @@ package eacl
|
||||||
import (
|
import (
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
v2acl "github.com/nspcc-dev/neofs-api-go/v2/acl"
|
v2acl "github.com/nspcc-dev/neofs-api-go/v2/acl"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
@ -10,7 +11,7 @@ import (
|
||||||
func TestFilter(t *testing.T) {
|
func TestFilter(t *testing.T) {
|
||||||
filter := &Filter{
|
filter := &Filter{
|
||||||
from: HeaderFromObject,
|
from: HeaderFromObject,
|
||||||
name: HdrObjSysNamePayloadLength,
|
name: object.HdrSysNamePayloadLength,
|
||||||
matcher: MatchStringEqual,
|
matcher: MatchStringEqual,
|
||||||
value: "200",
|
value: "200",
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,6 +4,7 @@ import (
|
||||||
"crypto/ecdsa"
|
"crypto/ecdsa"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
v2acl "github.com/nspcc-dev/neofs-api-go/v2/acl"
|
v2acl "github.com/nspcc-dev/neofs-api-go/v2/acl"
|
||||||
"github.com/nspcc-dev/neofs-crypto/test"
|
"github.com/nspcc-dev/neofs-crypto/test"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -62,7 +63,7 @@ func TestRecord_AddFilter(t *testing.T) {
|
||||||
filters := []Filter{
|
filters := []Filter{
|
||||||
{
|
{
|
||||||
from: HeaderFromObject,
|
from: HeaderFromObject,
|
||||||
name: HdrObjSysNameCID,
|
name: object.HdrSysNameCID,
|
||||||
matcher: MatchStringEqual,
|
matcher: MatchStringEqual,
|
||||||
value: "ContainerID",
|
value: "ContainerID",
|
||||||
},
|
},
|
||||||
|
|
31
pkg/object/wellknown_headers.go
Normal file
31
pkg/object/wellknown_headers.go
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
package object
|
||||||
|
|
||||||
|
// This file contains well-known header names for eACL filters and search
|
||||||
|
// request filters. Both of them encode header type as string. There are
|
||||||
|
// constant strings for well-known object headers.
|
||||||
|
|
||||||
|
const (
|
||||||
|
// ReservedHeaderNamePrefix used in filter names to specify well known
|
||||||
|
// headers such as container id, object id, owner id, etc.
|
||||||
|
// All names without this prefix used to lookup through user defined headers
|
||||||
|
// in object or x-headers in request.
|
||||||
|
ReservedHeaderNamePrefix = "_"
|
||||||
|
|
||||||
|
// HdrSysNameID is a name of ID field in system header of object.
|
||||||
|
HdrSysNameID = ReservedHeaderNamePrefix + "ID"
|
||||||
|
|
||||||
|
// HdrSysNameCID is a name of cid field in system header of object.
|
||||||
|
HdrSysNameCID = ReservedHeaderNamePrefix + "CID"
|
||||||
|
|
||||||
|
// HdrSysNameOwnerID is a name of OwnerID field in system header of object.
|
||||||
|
HdrSysNameOwnerID = ReservedHeaderNamePrefix + "OWNER_ID"
|
||||||
|
|
||||||
|
// HdrSysNameVersion is a name of version field in system header of object.
|
||||||
|
HdrSysNameVersion = ReservedHeaderNamePrefix + "VERSION"
|
||||||
|
|
||||||
|
// HdrSysNamePayloadLength is a name of PayloadLength field in system header of object.
|
||||||
|
HdrSysNamePayloadLength = ReservedHeaderNamePrefix + "PAYLOAD_LENGTH"
|
||||||
|
|
||||||
|
// HdrSysNameCreatedEpoch is a name of CreatedAt.Epoch field in system header of object.
|
||||||
|
HdrSysNameCreatedEpoch = ReservedHeaderNamePrefix + "CREATED_EPOCH"
|
||||||
|
)
|
Loading…
Reference in a new issue