From 65be09d3db24a7c019e55dcac817a913abd5e015 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Thu, 5 Nov 2020 18:51:43 +0300 Subject: [PATCH] [#155] Update neofs-api-go with refactored pkg/netmap Refactored pkg/netmap package provides JSON converters for NodeInfo and PlacementPolicy structures, that has been used by client applications. It also updates Node structure itself so it is a part of grpc <-> v2 <-> pkg conversion chain. Signed-off-by: Alex Vanin --- cmd/neofs-cli/modules/container.go | 7 +- go.mod | 2 +- go.sum | Bin 59670 -> 59670 bytes pkg/core/container/fmt_test.go | 2 +- pkg/innerring/invoke/netmap.go | 6 +- .../processors/netmap/cleanup_table_test.go | 21 +++--- pkg/morph/client/netmap/wrapper/netmap.go | 6 +- pkg/policy/encode.go | 67 ++++++------------ pkg/policy/query.go | 50 ++++++------- pkg/policy/query_test.go | 20 +++--- pkg/services/object/acl/classifier.go | 4 +- pkg/services/object/util/local.go | 2 +- .../object_manager/placement/traverser.go | 8 +-- .../placement/traverser_test.go | 16 ++--- pkg/services/policer/check.go | 8 +-- pkg/services/replicator/process.go | 2 +- 16 files changed, 98 insertions(+), 123 deletions(-) diff --git a/cmd/neofs-cli/modules/container.go b/cmd/neofs-cli/modules/container.go index 4f2b82b2..107ee7af 100644 --- a/cmd/neofs-cli/modules/container.go +++ b/cmd/neofs-cli/modules/container.go @@ -139,7 +139,7 @@ It will be stored in sidechain when inner ring will accepts it.`, } cnr := container.New() - cnr.SetPlacementPolicy(placementPolicy) + cnr.SetPlacementPolicy(placementPolicy.ToV2()) cnr.SetBasicACL(basicACL) cnr.SetAttributes(attributes) cnr.SetNonce(nonce[:]) @@ -531,7 +531,7 @@ func parseContainerPolicy(policyString string) (*netmap.PlacementPolicy, error) return result, nil } - result, err = policy.FromJSON([]byte(policyString)) + result, err = netmap.PlacementPolicyFromJSON([]byte(policyString)) if err == nil { printVerbose("Parsed JSON encoded policy") return result, nil @@ -684,7 +684,8 @@ func prettyPrintContainer(cnr *container.Container, jsonEncoding bool) { } fmt.Println("placement policy:") - fmt.Println(strings.Join(policy.Encode(cnr.GetPlacementPolicy()), "\n")) + cnrPolicy := netmap.NewPlacementPolicyFromV2(cnr.GetPlacementPolicy()) + fmt.Println(strings.Join(policy.Encode(cnrPolicy), "\n")) } func parseEACL(eaclPath string) (*eacl.Table, error) { diff --git a/go.mod b/go.mod index 0b4bb8ca..782450e5 100644 --- a/go.mod +++ b/go.mod @@ -14,7 +14,7 @@ require ( github.com/multiformats/go-multiaddr-net v0.1.2 // v0.1.1 => v0.1.2 github.com/multiformats/go-multihash v0.0.13 // indirect github.com/nspcc-dev/neo-go v0.91.1-pre.0.20201030072836-71216865717b - github.com/nspcc-dev/neofs-api-go v1.3.1-0.20201103083623-89a7a946dcd5 + github.com/nspcc-dev/neofs-api-go v1.3.1-0.20201106062850-d704795dcc7b github.com/nspcc-dev/neofs-crypto v0.3.0 github.com/nspcc-dev/tzhash v1.4.0 github.com/panjf2000/ants/v2 v2.3.0 diff --git a/go.sum b/go.sum index cd75838b79af90c01625acfc9b3482e21e072a1a..8ed2897dbd52f54f99cecbfde09ce93e1c0f0505 100644 GIT binary patch delta 169 zcmbPsiFw*3<_*U)oy`o)j4VtIbW_X?Ow27!Q<9U-lN2%xt-K;LOFSYRy~_%{l1-A+ zGm~A?UA!W-Q;fVay@SlnD^ilH+N3)4bFCojyFoxCAa+zXpo`sw+4x%nv|Bcr?v zN&`ZTQa#)%BTNH|O+3vFvJFf1)3hthT#TGklk`ipojfdZa?Fw)fkvutUZ0g-2LL(@ BHzfc7 delta 169 zcmbPsiFw*3<_*U)osA7FjLnRUbuBCt%@Zw6%u