From dd23c6fd2b579a33a4a81bc6029daf083ca07aa7 Mon Sep 17 00:00:00 2001 From: Airat Arifullin Date: Tue, 28 May 2024 12:05:02 +0300 Subject: [PATCH] [#225] apemanager: Move `apemanager` to `ape` package * Update go.mod; * Fix packages; * Fix client's `apemanager` methods. Signed-off-by: Airat Arifullin --- {apemanager => ape}/chain.go | 14 ++++++------ {apemanager => ape}/chain_target.go | 18 +++++++-------- {apemanager => ape}/chain_target_test.go | 28 ++++++++++++------------ {apemanager => ape}/chain_test.go | 16 +++++++------- client/apemanager_add_chain.go | 20 ++++++++--------- client/apemanager_list_chains.go | 20 ++++++++--------- client/apemanager_remove_chain.go | 18 +++++++-------- go.mod | 2 +- go.sum | 4 ++-- 9 files changed, 70 insertions(+), 70 deletions(-) rename {apemanager => ape}/chain.go (74%) rename {apemanager => ape}/chain_target.go (64%) rename {apemanager => ape}/chain_target_test.go (54%) rename {apemanager => ape}/chain_test.go (68%) diff --git a/apemanager/chain.go b/ape/chain.go similarity index 74% rename from apemanager/chain.go rename to ape/chain.go index 0a4cec4..eae441d 100644 --- a/apemanager/chain.go +++ b/ape/chain.go @@ -1,10 +1,10 @@ -package apemanager +package ape import ( "errors" "fmt" - apemanager_v2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/apemanager" + apeV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/ape" ) var ( @@ -27,11 +27,11 @@ type Chain struct { } // ToV2 converts Chain to v2. -func (c *Chain) ToV2() *apemanager_v2.Chain { - v2ct := new(apemanager_v2.Chain) +func (c *Chain) ToV2() *apeV2.Chain { + v2ct := new(apeV2.Chain) if c.Raw != nil { - v2Raw := new(apemanager_v2.ChainRaw) + v2Raw := new(apeV2.ChainRaw) v2Raw.SetRaw(c.Raw) v2ct.SetKind(v2Raw) } @@ -40,11 +40,11 @@ func (c *Chain) ToV2() *apemanager_v2.Chain { } // ReadFromV2 fills Chain from v2. -func (c *Chain) ReadFromV2(v2ct *apemanager_v2.Chain) error { +func (c *Chain) ReadFromV2(v2ct *apeV2.Chain) error { switch v := v2ct.GetKind().(type) { default: return fmt.Errorf("unsupported chain kind: %T", v) - case *apemanager_v2.ChainRaw: + case *apeV2.ChainRaw: raw := v.GetRaw() c.Raw = raw } diff --git a/apemanager/chain_target.go b/ape/chain_target.go similarity index 64% rename from apemanager/chain_target.go rename to ape/chain_target.go index 70cf9dc..13b7e87 100644 --- a/apemanager/chain_target.go +++ b/ape/chain_target.go @@ -1,11 +1,11 @@ -package apemanager +package ape import ( - apemanager_v2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/apemanager" + apeV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/ape" ) // TargetType is an SDK representation for v2's TargetType. -type TargetType apemanager_v2.TargetType +type TargetType apeV2.TargetType const ( TargetTypeUndefined TargetType = iota @@ -16,12 +16,12 @@ const ( ) // ToV2 converts TargetType to v2. -func (targetType TargetType) ToV2() apemanager_v2.TargetType { - return apemanager_v2.TargetType(targetType) +func (targetType TargetType) ToV2() apeV2.TargetType { + return apeV2.TargetType(targetType) } // FromV2 reads TargetType to v2. -func (targetType *TargetType) FromV2(v2targetType apemanager_v2.TargetType) { +func (targetType *TargetType) FromV2(v2targetType apeV2.TargetType) { *targetType = TargetType(v2targetType) } @@ -37,8 +37,8 @@ type ChainTarget struct { } // ToV2 converts ChainTarget to v2. -func (ct *ChainTarget) ToV2() *apemanager_v2.ChainTarget { - v2ct := new(apemanager_v2.ChainTarget) +func (ct *ChainTarget) ToV2() *apeV2.ChainTarget { + v2ct := new(apeV2.ChainTarget) v2ct.SetTargetType(ct.TargetType.ToV2()) v2ct.SetName(ct.Name) @@ -47,7 +47,7 @@ func (ct *ChainTarget) ToV2() *apemanager_v2.ChainTarget { } // FromV2 reads ChainTarget frpm v2. -func (ct *ChainTarget) FromV2(v2ct *apemanager_v2.ChainTarget) { +func (ct *ChainTarget) FromV2(v2ct *apeV2.ChainTarget) { ct.TargetType.FromV2(v2ct.GetTargetType()) ct.Name = v2ct.GetName() } diff --git a/apemanager/chain_target_test.go b/ape/chain_target_test.go similarity index 54% rename from apemanager/chain_target_test.go rename to ape/chain_target_test.go index a5e5fb7..21a11b7 100644 --- a/apemanager/chain_target_test.go +++ b/ape/chain_target_test.go @@ -1,21 +1,21 @@ -package apemanager_test +package ape_test import ( "testing" - "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apemanager" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/ape" "github.com/stretchr/testify/require" - apemanager_v2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/apemanager" + apeV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/ape" ) var ( - m = map[apemanager.TargetType]apemanager_v2.TargetType{ - apemanager.TargetTypeUndefined: apemanager_v2.TargetTypeUndefined, - apemanager.TargetTypeNamespace: apemanager_v2.TargetTypeNamespace, - apemanager.TargetTypeContainer: apemanager_v2.TargetTypeContainer, - apemanager.TargetTypeUser: apemanager_v2.TargetTypeUser, - apemanager.TargetTypeGroup: apemanager_v2.TargetTypeGroup, + m = map[ape.TargetType]apeV2.TargetType{ + ape.TargetTypeUndefined: apeV2.TargetTypeUndefined, + ape.TargetTypeNamespace: apeV2.TargetTypeNamespace, + ape.TargetTypeContainer: apeV2.TargetTypeContainer, + ape.TargetTypeUser: apeV2.TargetTypeUser, + ape.TargetTypeGroup: apeV2.TargetTypeGroup, } ) @@ -27,7 +27,7 @@ func TestTargetType(t *testing.T) { }) t.Run("from v2 to sdk "+typev2.String(), func(t *testing.T) { - var typ apemanager.TargetType + var typ ape.TargetType typ.FromV2(typev2) require.Equal(t, typesdk, typ) }) @@ -36,12 +36,12 @@ func TestTargetType(t *testing.T) { func TestChainTarget(t *testing.T) { var ( - typ = apemanager.TargetTypeNamespace + typ = ape.TargetTypeNamespace name = "namespaceXXYYZZ" ) t.Run("from sdk to v2", func(t *testing.T) { - ct := apemanager.ChainTarget{ + ct := ape.ChainTarget{ TargetType: typ, Name: name, } @@ -52,11 +52,11 @@ func TestChainTarget(t *testing.T) { }) t.Run("from v2 to sdk", func(t *testing.T) { - v2 := &apemanager_v2.ChainTarget{} + v2 := &apeV2.ChainTarget{} v2.SetTargetType(m[typ]) v2.SetName(name) - var ct apemanager.ChainTarget + var ct ape.ChainTarget ct.FromV2(v2) require.Equal(t, typ, ct.TargetType) diff --git a/apemanager/chain_test.go b/ape/chain_test.go similarity index 68% rename from apemanager/chain_test.go rename to ape/chain_test.go index fbe1818..83991f6 100644 --- a/apemanager/chain_test.go +++ b/ape/chain_test.go @@ -1,12 +1,12 @@ -package apemanager_test +package ape_test import ( "testing" - "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apemanager" + "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/ape" "github.com/stretchr/testify/require" - apemanager_v2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/apemanager" + apeV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/ape" ) const ( @@ -15,12 +15,12 @@ const ( func TestChainData(t *testing.T) { t.Run("raw chain", func(t *testing.T) { - var c apemanager.Chain + var c ape.Chain b := []byte(encoded) c.Raw = b - v2, ok := c.ToV2().GetKind().(*apemanager_v2.ChainRaw) + v2, ok := c.ToV2().GetKind().(*apeV2.ChainRaw) require.True(t, ok) require.Equal(t, b, v2.Raw) }) @@ -29,13 +29,13 @@ func TestChainData(t *testing.T) { func TestChainMessageV2(t *testing.T) { b := []byte(encoded) - v2Raw := &apemanager_v2.ChainRaw{} + v2Raw := &apeV2.ChainRaw{} v2Raw.SetRaw(b) - v2 := &apemanager_v2.Chain{} + v2 := &apeV2.Chain{} v2.SetKind(v2Raw) - var c apemanager.Chain + var c ape.Chain c.ReadFromV2(v2) require.NotNil(t, c.Raw) diff --git a/client/apemanager_add_chain.go b/client/apemanager_add_chain.go index 00fd66d..2581e2a 100644 --- a/client/apemanager_add_chain.go +++ b/client/apemanager_add_chain.go @@ -4,12 +4,12 @@ import ( "context" "fmt" - apemanager_v2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/apemanager" + apemanagerV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/apemanager" rpcapi "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc" "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client" - session_v2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session" + sessionV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session" "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/signature" - apemanager_sdk "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apemanager" + apeSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/ape" apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status" ) @@ -17,25 +17,25 @@ import ( type PrmAPEManagerAddChain struct { XHeaders []string - ChainTarget apemanager_sdk.ChainTarget + ChainTarget apeSDK.ChainTarget - Chain apemanager_sdk.Chain + Chain apeSDK.Chain } -func (prm *PrmAPEManagerAddChain) buildRequest(c *Client) (*apemanager_v2.AddChainRequest, error) { +func (prm *PrmAPEManagerAddChain) buildRequest(c *Client) (*apemanagerV2.AddChainRequest, error) { if len(prm.XHeaders)%2 != 0 { return nil, errorInvalidXHeaders } - req := new(apemanager_v2.AddChainRequest) - reqBody := new(apemanager_v2.AddChainRequestBody) + req := new(apemanagerV2.AddChainRequest) + reqBody := new(apemanagerV2.AddChainRequestBody) reqBody.SetTarget(prm.ChainTarget.ToV2()) reqBody.SetChain(prm.Chain.ToV2()) req.SetBody(reqBody) - var meta session_v2.RequestMetaHeader + var meta sessionV2.RequestMetaHeader writeXHeadersToMeta(prm.XHeaders, &meta) c.prepareRequest(req, &meta) @@ -48,7 +48,7 @@ type ResAPEManagerAddChain struct { // ChainID of set Chain. If Chain does not contain chainID before request, then // ChainID is generated. - ChainID apemanager_sdk.ChainID + ChainID apeSDK.ChainID } // APEManagerAddChain sets Chain for ChainTarget. diff --git a/client/apemanager_list_chains.go b/client/apemanager_list_chains.go index dd5c4dd..a608f1e 100644 --- a/client/apemanager_list_chains.go +++ b/client/apemanager_list_chains.go @@ -4,12 +4,12 @@ import ( "context" "fmt" - apemanager_v2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/apemanager" + apemanagerV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/apemanager" rpcapi "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc" "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client" - session_v2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session" + sessionV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session" "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/signature" - apemanager_sdk "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apemanager" + apeSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/ape" apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status" ) @@ -17,22 +17,22 @@ import ( type PrmAPEManagerListChains struct { XHeaders []string - ChainTarget apemanager_sdk.ChainTarget + ChainTarget apeSDK.ChainTarget } -func (prm *PrmAPEManagerListChains) buildRequest(c *Client) (*apemanager_v2.ListChainsRequest, error) { +func (prm *PrmAPEManagerListChains) buildRequest(c *Client) (*apemanagerV2.ListChainsRequest, error) { if len(prm.XHeaders)%2 != 0 { return nil, errorInvalidXHeaders } - req := new(apemanager_v2.ListChainsRequest) - reqBody := new(apemanager_v2.ListChainsRequestBody) + req := new(apemanagerV2.ListChainsRequest) + reqBody := new(apemanagerV2.ListChainsRequestBody) reqBody.SetTarget(prm.ChainTarget.ToV2()) req.SetBody(reqBody) - var meta session_v2.RequestMetaHeader + var meta sessionV2.RequestMetaHeader writeXHeadersToMeta(prm.XHeaders, &meta) c.prepareRequest(req, &meta) @@ -43,7 +43,7 @@ func (prm *PrmAPEManagerListChains) buildRequest(c *Client) (*apemanager_v2.List type ResAPEManagerListChains struct { statusRes - Chains []apemanager_sdk.Chain + Chains []apeSDK.Chain } // APEManagerListChains lists Chains for ChainTarget. @@ -69,7 +69,7 @@ func (c *Client) APEManagerListChains(ctx context.Context, prm PrmAPEManagerList } for _, ch := range resp.GetBody().GetChains() { - var chSDK apemanager_sdk.Chain + var chSDK apeSDK.Chain if err := chSDK.ReadFromV2(ch); err != nil { return nil, err } diff --git a/client/apemanager_remove_chain.go b/client/apemanager_remove_chain.go index dc10113..a297716 100644 --- a/client/apemanager_remove_chain.go +++ b/client/apemanager_remove_chain.go @@ -4,12 +4,12 @@ import ( "context" "fmt" - apemanager_v2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/apemanager" + apemanagerV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/apemanager" rpcapi "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc" "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client" - session_v2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session" + sessionV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/session" "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/signature" - apemanager_sdk "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apemanager" + apeSDK "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/ape" apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status" ) @@ -17,25 +17,25 @@ import ( type PrmAPEManagerRemoveChain struct { XHeaders []string - ChainTarget apemanager_sdk.ChainTarget + ChainTarget apeSDK.ChainTarget - ChainID apemanager_sdk.ChainID + ChainID apeSDK.ChainID } -func (prm *PrmAPEManagerRemoveChain) buildRequest(c *Client) (*apemanager_v2.RemoveChainRequest, error) { +func (prm *PrmAPEManagerRemoveChain) buildRequest(c *Client) (*apemanagerV2.RemoveChainRequest, error) { if len(prm.XHeaders)%2 != 0 { return nil, errorInvalidXHeaders } - req := new(apemanager_v2.RemoveChainRequest) - reqBody := new(apemanager_v2.RemoveChainRequestBody) + req := new(apemanagerV2.RemoveChainRequest) + reqBody := new(apemanagerV2.RemoveChainRequestBody) reqBody.SetTarget(prm.ChainTarget.ToV2()) reqBody.SetChainID(prm.ChainID) req.SetBody(reqBody) - var meta session_v2.RequestMetaHeader + var meta sessionV2.RequestMetaHeader writeXHeadersToMeta(prm.XHeaders, &meta) c.prepareRequest(req, &meta) diff --git a/go.mod b/go.mod index 31024af..96ef020 100644 --- a/go.mod +++ b/go.mod @@ -3,7 +3,7 @@ module git.frostfs.info/TrueCloudLab/frostfs-sdk-go go 1.20 require ( - git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20240516133103-0803bc6ded00 + git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20240529164544-9e825239ac5f git.frostfs.info/TrueCloudLab/frostfs-contract v0.0.0-20230307110621-19a8ef2d02fb git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0 git.frostfs.info/TrueCloudLab/hrw v1.2.1 diff --git a/go.sum b/go.sum index 4d2a480..6e302d0 100644 --- a/go.sum +++ b/go.sum @@ -31,8 +31,8 @@ cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohl cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= 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.16.1-0.20240516133103-0803bc6ded00 h1:Q3B9WtFh05AXhUFs/2CLvhh9tuFs/Zd/XemWBbuzvg8= -git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20240516133103-0803bc6ded00/go.mod h1:OBDSr+DqV1z4VDouoX3YMleNc4DPBVBWTG3WDT2PK1o= +git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20240529164544-9e825239ac5f h1:/BC1Aq7WcfZ/g9Y3t2UfZ44/w1Z8s367MYrBSzno0cQ= +git.frostfs.info/TrueCloudLab/frostfs-api-go/v2 v2.16.1-0.20240529164544-9e825239ac5f/go.mod h1:OBDSr+DqV1z4VDouoX3YMleNc4DPBVBWTG3WDT2PK1o= 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=