From a0937126cba10cca8529c734cce2cb6752db9ef7 Mon Sep 17 00:00:00 2001 From: Denis Kirillov Date: Wed, 22 Mar 2023 09:53:14 +0300 Subject: [PATCH] [#64] Support new system attributes Signed-off-by: Denis Kirillov --- CHANGELOG.md | 1 + api/layer/locking_test.go | 5 +++-- api/layer/system_object.go | 6 +++--- go.mod | 9 +++------ go.sum | 8 ++++---- internal/frostfs/frostfs.go | 2 +- 6 files changed, 15 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d6b6832b..d5bfd04a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ This document outlines major changes between releases. - Add generated deb builder files to .gitignore, and fix typo (TrueCloudLab#28) - Limit number of objects to delete at one time (TrueCloudLab#37) - CompleteMultipartUpload handler now sends whitespace characters to keep alive client's connection (#60) +- Support new system attributes (#64) ## [0.26.0] - 2022-12-28 diff --git a/api/layer/locking_test.go b/api/layer/locking_test.go index 6cbcd554..d465c1ad 100644 --- a/api/layer/locking_test.go +++ b/api/layer/locking_test.go @@ -4,6 +4,7 @@ import ( "testing" "time" + "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object" "git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/data" "github.com/stretchr/testify/require" ) @@ -43,10 +44,10 @@ func TestObjectLockAttributes(t *testing.T) { expEpoch := false for _, attr := range lockObj.Attributes() { - if attr.Key() == AttributeExpirationEpoch { + if attr.Key() == object.SysAttributeExpEpoch { expEpoch = true } } - require.Truef(t, expEpoch, "system header __NEOFS__EXPIRATION_EPOCH presence") + require.Truef(t, expEpoch, "system header __SYSTEM__EXPIRATION_EPOCH presence") } diff --git a/api/layer/system_object.go b/api/layer/system_object.go index f8bdec73..29e7654a 100644 --- a/api/layer/system_object.go +++ b/api/layer/system_object.go @@ -9,14 +9,14 @@ import ( "strconv" "time" + "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/object" "git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/data" "git.frostfs.info/TrueCloudLab/frostfs-s3-gw/api/errors" oid "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/object/id" ) const ( - AttributeComplianceMode = ".s3-compliance-mode" - AttributeExpirationEpoch = "__NEOFS__EXPIRATION_EPOCH" + AttributeComplianceMode = ".s3-compliance-mode" ) type PutLockInfoParams struct { @@ -246,7 +246,7 @@ func (n *layer) attributesFromLock(ctx context.Context, lock *data.ObjectLock) ( if expEpoch != 0 { result = append(result, [2]string{ - AttributeExpirationEpoch, strconv.FormatUint(expEpoch, 10), + object.SysAttributeExpEpoch, strconv.FormatUint(expEpoch, 10), }) } diff --git a/go.mod b/go.mod index c2169611..c5129e5a 100644 --- a/go.mod +++ b/go.mod @@ -3,9 +3,9 @@ module git.frostfs.info/TrueCloudLab/frostfs-s3-gw go 1.18 require ( - git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.11.2-0.20230307104236-f69d2ad83c51 + git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.11.2-0.20230315095236-9dc375346703 git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0 - git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20230310065834-0ad877288ee4 + git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20230316081442-bec77f280a85 github.com/aws/aws-sdk-go v1.44.6 github.com/bluele/gcache v0.0.2 github.com/google/uuid v1.3.0 @@ -30,10 +30,6 @@ require ( git.frostfs.info/TrueCloudLab/hrw v1.2.0 // indirect git.frostfs.info/TrueCloudLab/rfc6979 v0.4.0 // indirect git.frostfs.info/TrueCloudLab/tzhash v1.8.0 // indirect - github.com/hashicorp/golang-lru/v2 v2.0.1 // indirect -) - -require ( github.com/antlr/antlr4/runtime/Go/antlr/v4 v4.0.0-20221202181307-76fa05c21b12 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/cespare/xxhash/v2 v2.1.2 // indirect @@ -45,6 +41,7 @@ require ( github.com/golang/snappy v0.0.3 // indirect github.com/gorilla/websocket v1.4.2 // indirect github.com/hashicorp/golang-lru v0.6.0 // indirect + github.com/hashicorp/golang-lru/v2 v2.0.1 // indirect github.com/hashicorp/hcl v1.0.0 // indirect github.com/jmespath/go-jmespath v0.4.0 // indirect github.com/magiconair/properties v1.8.7 // indirect diff --git a/go.sum b/go.sum index 8e6d09fc..b9f693d0 100644 --- a/go.sum +++ b/go.sum @@ -36,14 +36,14 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= cloud.google.com/go/storage v1.14.0/go.mod h1:GrKmX003DSIwi9o29oFT7YDnHYwZoctc3fOKtUw0Xmo= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.11.2-0.20230307104236-f69d2ad83c51 h1:l4+K1hN+NuWNtlZZoV8yRRP3Uu7PifL05ukEqKcb0Ks= -git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.11.2-0.20230307104236-f69d2ad83c51/go.mod h1:n0DxKYulu2Ar73R6OcNF34LiL/Xa+iDR7GZuaOChbLE= +git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.11.2-0.20230315095236-9dc375346703 h1:lxe0DtZq/uFZVZu9apx6OcIXCJskQBMd/GVeYGKA3wA= +git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.11.2-0.20230315095236-9dc375346703/go.mod h1:gRd5iE5A84viily6AcNBsSlTx2XgoWrwRDz7z0MayDQ= git.frostfs.info/TrueCloudLab/frostfs-contract v0.0.0-20230307110621-19a8ef2d02fb h1:S/TrbOOu9qEXZRZ9/Ddw7crnxbBUQLo68PSzQWYrc9M= git.frostfs.info/TrueCloudLab/frostfs-contract v0.0.0-20230307110621-19a8ef2d02fb/go.mod h1:nkR5gaGeez3Zv2SE7aceP0YwxG2FzIB5cGKpQO2vV2o= git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0 h1:FxqFDhQYYgpe41qsIHVOcdzSVCB8JNSfPG7Uk4r2oSk= git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0/go.mod h1:RUIKZATQLJ+TaYQa60X2fTDwfuhMfm8Ar60bQ5fr+vU= -git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20230310065834-0ad877288ee4 h1:xxfpDvCjyQif/8QsryG3W9TV/akus2YkHhK/EVRmjP4= -git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20230310065834-0ad877288ee4/go.mod h1:z7zcpGY+puI5puyy5oyFbf20vWp84WtslCxcr6/kv5c= +git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20230316081442-bec77f280a85 h1:TUcJ5A0C1gWi3bAhw4b+V+iVM3E9mbBOdJIWWkAPNxo= +git.frostfs.info/TrueCloudLab/frostfs-sdk-go v0.0.0-20230316081442-bec77f280a85/go.mod h1:23fUGlEv/ImaOi3vck6vZj0v0b4hteOhLLPnVWHSQeA= git.frostfs.info/TrueCloudLab/hrw v1.2.0 h1:KvAES7xIqmQBGd2q8KanNosD9+4BhU/zqD5Kt5KSflk= git.frostfs.info/TrueCloudLab/hrw v1.2.0/go.mod h1:mq2sbvYfO+BB6iFZwYBkgC0yc6mJNx+qZi4jW918m+Y= git.frostfs.info/TrueCloudLab/rfc6979 v0.4.0 h1:M2KR3iBj7WpY3hP10IevfIB9MURr4O9mwVfJ+SjT3HA= diff --git a/internal/frostfs/frostfs.go b/internal/frostfs/frostfs.go index 77db3abd..86d60b7c 100644 --- a/internal/frostfs/frostfs.go +++ b/internal/frostfs/frostfs.go @@ -539,7 +539,7 @@ func (x *AuthmateFrostFS) CreateObject(ctx context.Context, prm tokens.PrmObject Container: prm.Container, Filepath: prm.Filepath, Attributes: [][2]string{ - {"__NEOFS__EXPIRATION_EPOCH", strconv.FormatUint(prm.ExpirationEpoch, 10)}}, + {objectv2.SysAttributeExpEpoch, strconv.FormatUint(prm.ExpirationEpoch, 10)}}, Payload: bytes.NewReader(prm.Payload), }) }