[#225] apemanager: Move apemanager to ape package

* Update go.mod;
* Fix packages;
* Fix client's `apemanager` methods.

Signed-off-by: Airat Arifullin <a.arifullin@yadro.com>
This commit is contained in:
Airat Arifullin 2024-05-28 12:05:02 +03:00
parent c5c6272029
commit 513c2b07c3
9 changed files with 68 additions and 68 deletions

View file

@ -1,10 +1,10 @@
package apemanager package ape
import ( import (
"errors" "errors"
"fmt" "fmt"
apemanager_v2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/apemanager" apeV2 "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/ape"
) )
var ( var (
@ -27,11 +27,11 @@ type Chain struct {
} }
// ToV2 converts Chain to v2. // ToV2 converts Chain to v2.
func (c *Chain) ToV2() *apemanager_v2.Chain { func (c *Chain) ToV2() *apeV2.Chain {
v2ct := new(apemanager_v2.Chain) v2ct := new(apeV2.Chain)
if c.Raw != nil { if c.Raw != nil {
v2Raw := new(apemanager_v2.ChainRaw) v2Raw := new(apeV2.ChainRaw)
v2Raw.SetRaw(c.Raw) v2Raw.SetRaw(c.Raw)
v2ct.SetKind(v2Raw) v2ct.SetKind(v2Raw)
} }
@ -40,11 +40,11 @@ func (c *Chain) ToV2() *apemanager_v2.Chain {
} }
// ReadFromV2 fills Chain from v2. // 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) { switch v := v2ct.GetKind().(type) {
default: default:
return fmt.Errorf("unsupported chain kind: %T", v) return fmt.Errorf("unsupported chain kind: %T", v)
case *apemanager_v2.ChainRaw: case *apeV2.ChainRaw:
raw := v.GetRaw() raw := v.GetRaw()
c.Raw = raw c.Raw = raw
} }

View file

@ -1,11 +1,11 @@
package apemanager package ape
import ( 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. // TargetType is an SDK representation for v2's TargetType.
type TargetType apemanager_v2.TargetType type TargetType apeV2.TargetType
const ( const (
TargetTypeUndefined TargetType = iota TargetTypeUndefined TargetType = iota
@ -16,12 +16,12 @@ const (
) )
// ToV2 converts TargetType to v2. // ToV2 converts TargetType to v2.
func (targetType TargetType) ToV2() apemanager_v2.TargetType { func (targetType TargetType) ToV2() apeV2.TargetType {
return apemanager_v2.TargetType(targetType) return apeV2.TargetType(targetType)
} }
// FromV2 reads TargetType to v2. // FromV2 reads TargetType to v2.
func (targetType *TargetType) FromV2(v2targetType apemanager_v2.TargetType) { func (targetType *TargetType) FromV2(v2targetType apeV2.TargetType) {
*targetType = TargetType(v2targetType) *targetType = TargetType(v2targetType)
} }
@ -37,8 +37,8 @@ type ChainTarget struct {
} }
// ToV2 converts ChainTarget to v2. // ToV2 converts ChainTarget to v2.
func (ct *ChainTarget) ToV2() *apemanager_v2.ChainTarget { func (ct *ChainTarget) ToV2() *apeV2.ChainTarget {
v2ct := new(apemanager_v2.ChainTarget) v2ct := new(apeV2.ChainTarget)
v2ct.SetTargetType(ct.TargetType.ToV2()) v2ct.SetTargetType(ct.TargetType.ToV2())
v2ct.SetName(ct.Name) v2ct.SetName(ct.Name)
@ -47,7 +47,7 @@ func (ct *ChainTarget) ToV2() *apemanager_v2.ChainTarget {
} }
// FromV2 reads ChainTarget frpm v2. // 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.TargetType.FromV2(v2ct.GetTargetType())
ct.Name = v2ct.GetName() ct.Name = v2ct.GetName()
} }

View file

@ -1,21 +1,21 @@
package apemanager_test package ape_test
import ( import (
"testing" "testing"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apemanager" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/ape"
"github.com/stretchr/testify/require" "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 ( var (
m = map[apemanager.TargetType]apemanager_v2.TargetType{ m = map[ape.TargetType]apeV2.TargetType{
apemanager.TargetTypeUndefined: apemanager_v2.TargetTypeUndefined, ape.TargetTypeUndefined: apeV2.TargetTypeUndefined,
apemanager.TargetTypeNamespace: apemanager_v2.TargetTypeNamespace, ape.TargetTypeNamespace: apeV2.TargetTypeNamespace,
apemanager.TargetTypeContainer: apemanager_v2.TargetTypeContainer, ape.TargetTypeContainer: apeV2.TargetTypeContainer,
apemanager.TargetTypeUser: apemanager_v2.TargetTypeUser, ape.TargetTypeUser: apeV2.TargetTypeUser,
apemanager.TargetTypeGroup: apemanager_v2.TargetTypeGroup, 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) { t.Run("from v2 to sdk "+typev2.String(), func(t *testing.T) {
var typ apemanager.TargetType var typ ape.TargetType
typ.FromV2(typev2) typ.FromV2(typev2)
require.Equal(t, typesdk, typ) require.Equal(t, typesdk, typ)
}) })
@ -36,12 +36,12 @@ func TestTargetType(t *testing.T) {
func TestChainTarget(t *testing.T) { func TestChainTarget(t *testing.T) {
var ( var (
typ = apemanager.TargetTypeNamespace typ = ape.TargetTypeNamespace
name = "namespaceXXYYZZ" name = "namespaceXXYYZZ"
) )
t.Run("from sdk to v2", func(t *testing.T) { t.Run("from sdk to v2", func(t *testing.T) {
ct := apemanager.ChainTarget{ ct := ape.ChainTarget{
TargetType: typ, TargetType: typ,
Name: name, Name: name,
} }
@ -52,11 +52,11 @@ func TestChainTarget(t *testing.T) {
}) })
t.Run("from v2 to sdk", func(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.SetTargetType(m[typ])
v2.SetName(name) v2.SetName(name)
var ct apemanager.ChainTarget var ct ape.ChainTarget
ct.FromV2(v2) ct.FromV2(v2)
require.Equal(t, typ, ct.TargetType) require.Equal(t, typ, ct.TargetType)

View file

@ -1,12 +1,12 @@
package apemanager_test package ape_test
import ( import (
"testing" "testing"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/apemanager" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/ape"
"github.com/stretchr/testify/require" "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 ( const (
@ -15,12 +15,12 @@ const (
func TestChainData(t *testing.T) { func TestChainData(t *testing.T) {
t.Run("raw chain", func(t *testing.T) { t.Run("raw chain", func(t *testing.T) {
var c apemanager.Chain var c ape.Chain
b := []byte(encoded) b := []byte(encoded)
c.Raw = b c.Raw = b
v2, ok := c.ToV2().GetKind().(*apemanager_v2.ChainRaw) v2, ok := c.ToV2().GetKind().(*apeV2.ChainRaw)
require.True(t, ok) require.True(t, ok)
require.Equal(t, b, v2.Raw) require.Equal(t, b, v2.Raw)
}) })
@ -29,13 +29,13 @@ func TestChainData(t *testing.T) {
func TestChainMessageV2(t *testing.T) { func TestChainMessageV2(t *testing.T) {
b := []byte(encoded) b := []byte(encoded)
v2Raw := &apemanager_v2.ChainRaw{} v2Raw := &apeV2.ChainRaw{}
v2Raw.SetRaw(b) v2Raw.SetRaw(b)
v2 := &apemanager_v2.Chain{} v2 := &apeV2.Chain{}
v2.SetKind(v2Raw) v2.SetKind(v2Raw)
var c apemanager.Chain var c ape.Chain
c.ReadFromV2(v2) c.ReadFromV2(v2)
require.NotNil(t, c.Raw) require.NotNil(t, c.Raw)

View file

@ -4,12 +4,12 @@ import (
"context" "context"
"fmt" "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" rpcapi "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc"
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client" "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" "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" apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
) )
@ -17,25 +17,25 @@ import (
type PrmAPEManagerAddChain struct { type PrmAPEManagerAddChain struct {
XHeaders []string 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 { if len(prm.XHeaders)%2 != 0 {
return nil, errorInvalidXHeaders return nil, errorInvalidXHeaders
} }
req := new(apemanager_v2.AddChainRequest) req := new(apemanagerV2.AddChainRequest)
reqBody := new(apemanager_v2.AddChainRequestBody) reqBody := new(apemanagerV2.AddChainRequestBody)
reqBody.SetTarget(prm.ChainTarget.ToV2()) reqBody.SetTarget(prm.ChainTarget.ToV2())
reqBody.SetChain(prm.Chain.ToV2()) reqBody.SetChain(prm.Chain.ToV2())
req.SetBody(reqBody) req.SetBody(reqBody)
var meta session_v2.RequestMetaHeader var meta sessionV2.RequestMetaHeader
writeXHeadersToMeta(prm.XHeaders, &meta) writeXHeadersToMeta(prm.XHeaders, &meta)
c.prepareRequest(req, &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 of set Chain. If Chain does not contain chainID before request, then
// ChainID is generated. // ChainID is generated.
ChainID apemanager_sdk.ChainID ChainID apeSDK.ChainID
} }
// APEManagerAddChain sets Chain for ChainTarget. // APEManagerAddChain sets Chain for ChainTarget.

View file

@ -4,12 +4,12 @@ import (
"context" "context"
"fmt" "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" rpcapi "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc"
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client" "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" "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" apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
) )
@ -17,22 +17,22 @@ import (
type PrmAPEManagerListChains struct { type PrmAPEManagerListChains struct {
XHeaders []string 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 { if len(prm.XHeaders)%2 != 0 {
return nil, errorInvalidXHeaders return nil, errorInvalidXHeaders
} }
req := new(apemanager_v2.ListChainsRequest) req := new(apemanagerV2.ListChainsRequest)
reqBody := new(apemanager_v2.ListChainsRequestBody) reqBody := new(apemanagerV2.ListChainsRequestBody)
reqBody.SetTarget(prm.ChainTarget.ToV2()) reqBody.SetTarget(prm.ChainTarget.ToV2())
req.SetBody(reqBody) req.SetBody(reqBody)
var meta session_v2.RequestMetaHeader var meta sessionV2.RequestMetaHeader
writeXHeadersToMeta(prm.XHeaders, &meta) writeXHeadersToMeta(prm.XHeaders, &meta)
c.prepareRequest(req, &meta) c.prepareRequest(req, &meta)
@ -43,7 +43,7 @@ func (prm *PrmAPEManagerListChains) buildRequest(c *Client) (*apemanager_v2.List
type ResAPEManagerListChains struct { type ResAPEManagerListChains struct {
statusRes statusRes
Chains []apemanager_sdk.Chain Chains []apeSDK.Chain
} }
// APEManagerListChains lists Chains for ChainTarget. // APEManagerListChains lists Chains for ChainTarget.
@ -69,7 +69,7 @@ func (c *Client) APEManagerListChains(ctx context.Context, prm PrmAPEManagerList
} }
for _, ch := range resp.GetBody().GetChains() { for _, ch := range resp.GetBody().GetChains() {
var chSDK apemanager_sdk.Chain var chSDK apeSDK.Chain
if err := chSDK.ReadFromV2(ch); err != nil { if err := chSDK.ReadFromV2(ch); err != nil {
return nil, err return nil, err
} }

View file

@ -4,12 +4,12 @@ import (
"context" "context"
"fmt" "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" rpcapi "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc"
"git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client" "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" "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" apistatus "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client/status"
) )
@ -17,25 +17,25 @@ import (
type PrmAPEManagerRemoveChain struct { type PrmAPEManagerRemoveChain struct {
XHeaders []string 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 { if len(prm.XHeaders)%2 != 0 {
return nil, errorInvalidXHeaders return nil, errorInvalidXHeaders
} }
req := new(apemanager_v2.RemoveChainRequest) req := new(apemanagerV2.RemoveChainRequest)
reqBody := new(apemanager_v2.RemoveChainRequestBody) reqBody := new(apemanagerV2.RemoveChainRequestBody)
reqBody.SetTarget(prm.ChainTarget.ToV2()) reqBody.SetTarget(prm.ChainTarget.ToV2())
reqBody.SetChainID(prm.ChainID) reqBody.SetChainID(prm.ChainID)
req.SetBody(reqBody) req.SetBody(reqBody)
var meta session_v2.RequestMetaHeader var meta sessionV2.RequestMetaHeader
writeXHeadersToMeta(prm.XHeaders, &meta) writeXHeadersToMeta(prm.XHeaders, &meta)
c.prepareRequest(req, &meta) c.prepareRequest(req, &meta)

2
go.mod
View file

@ -3,7 +3,7 @@ module git.frostfs.info/TrueCloudLab/frostfs-sdk-go
go 1.20 go 1.20
require ( 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-contract v0.0.0-20230307110621-19a8ef2d02fb
git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0 git.frostfs.info/TrueCloudLab/frostfs-crypto v0.6.0
git.frostfs.info/TrueCloudLab/hrw v1.2.1 git.frostfs.info/TrueCloudLab/hrw v1.2.1

BIN
go.sum

Binary file not shown.