From e8bc03d92f49450b64e96be5fbfee302de4da6bc Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Tue, 24 Nov 2020 16:06:02 +0300 Subject: [PATCH] [#206] cli/container: Use GetEACLWithSignature client method Use GetEACLWithSignature client method in get-eacl cmd of container CLI in order to print eACL table and signature regardless of their correctness. The ability to check the correctness of the signature will be added later. Signed-off-by: Leonard Lyubich --- cmd/neofs-cli/modules/container.go | 21 ++++++++++++++++++--- go.mod | 2 +- go.sum | Bin 59749 -> 59749 bytes 3 files changed, 19 insertions(+), 4 deletions(-) diff --git a/cmd/neofs-cli/modules/container.go b/cmd/neofs-cli/modules/container.go index b2cd0cba..ca1a4c6f 100644 --- a/cmd/neofs-cli/modules/container.go +++ b/cmd/neofs-cli/modules/container.go @@ -340,13 +340,21 @@ var getExtendedACLCmd = &cobra.Command{ return err } - eaclTable, err := cli.GetEACL(ctx, id, client.WithTTL(getTTL())) + res, err := cli.GetEACLWithSignature(ctx, id, client.WithTTL(getTTL())) if err != nil { return fmt.Errorf("rpc error: %w", err) } + eaclTable := res.EACL() + sig := res.Signature() + if containerPathTo == "" { + fmt.Println("eACL: ") prettyPrintEACL(eaclTable) + + fmt.Println("Signature:") + printJSONMarshaler(sig, "signature") + return nil } @@ -366,6 +374,9 @@ var getExtendedACLCmd = &cobra.Command{ fmt.Println("dumping data to file:", containerPathTo) + fmt.Println("Signature:") + printJSONMarshaler(sig, "signature") + return ioutil.WriteFile(containerPathTo, data, 0644) }, } @@ -694,9 +705,13 @@ func parseEACL(eaclPath string) (*eacl.Table, error) { } func prettyPrintEACL(table *eacl.Table) { - data, err := table.MarshalJSON() + printJSONMarshaler(table, "eACL") +} + +func printJSONMarshaler(j json.Marshaler, entity string) { + data, err := j.MarshalJSON() if err != nil { - printVerbose("Can't convert container to json: %w", err) + printVerbose("Can't convert %s to json: %w", entity, err) return } buf := new(bytes.Buffer) diff --git a/go.mod b/go.mod index 6eb9791c..4dfde67d 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.20.3-0.20201123111542-5ee500bb43c6 + github.com/nspcc-dev/neofs-api-go v1.20.3-0.20201124121642-8c99d9d54c5c 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 e31d1c98a24863f19540f3f96ecb8e592920f71a..bda477d6fe8651ecace52074978e60c82155fcd9 100644 GIT binary patch delta 107 zcmaEQiTUXz<_)4*&L)ONhGr&4x)#ZnmMNAgrY6az$qE^UR$)o`!Nz`hmN}JWMka|x trn!OMrlsZO<;LYkiC&?}1}?5X`tA`K<+-jFlOJT7ieNKm^TMnnbpUpSBVzyn delta 107 zcmaEQiTUXz<_)4*&c=p@hNdP)x~8eArUnK{NhZe0W(paGR;kIw?goLDCWdC=PCiay t#@Z=W?*8SzQDx5BZkAEnp(Q2dQTl0y*=|0OlOJT7ieNKm^TMnnbpR@CA|U_(