forked from TrueCloudLab/frostfs-node
[#525] morph/container: Attach all parsed items to container in Get
Unmarshal session token from `GetValues` and write it to resulting `Container` structure in `Wrapper.Get` method. Write key-signature pair from `GetValues` to resulting `Container` structure in `Wrapper.Get` method. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
b9b369dd5b
commit
c4a3adc8b0
1 changed files with 19 additions and 0 deletions
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
||||||
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
cid "github.com/nspcc-dev/neofs-api-go/pkg/container/id"
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
"github.com/nspcc-dev/neofs-api-go/pkg/owner"
|
||||||
|
"github.com/nspcc-dev/neofs-api-go/pkg/session"
|
||||||
v2refs "github.com/nspcc-dev/neofs-api-go/v2/refs"
|
v2refs "github.com/nspcc-dev/neofs-api-go/v2/refs"
|
||||||
core "github.com/nspcc-dev/neofs-node/pkg/core/container"
|
core "github.com/nspcc-dev/neofs-node/pkg/core/container"
|
||||||
client "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
|
client "github.com/nspcc-dev/neofs-node/pkg/morph/client/container"
|
||||||
|
@ -127,6 +128,24 @@ func (w *Wrapper) Get(cid []byte) (*container.Container, error) {
|
||||||
return nil, fmt.Errorf("can't unmarshal container: %w", err)
|
return nil, fmt.Errorf("can't unmarshal container: %w", err)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
binToken := rpcAnswer.SessionToken()
|
||||||
|
if len(binToken) > 0 {
|
||||||
|
tok := session.NewToken()
|
||||||
|
|
||||||
|
err = tok.Unmarshal(binToken)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("could not unmarshal session token: %w", err)
|
||||||
|
}
|
||||||
|
|
||||||
|
cnr.SetSessionToken(tok)
|
||||||
|
}
|
||||||
|
|
||||||
|
sig := pkg.NewSignature()
|
||||||
|
sig.SetKey(rpcAnswer.PublicKey())
|
||||||
|
sig.SetSign(rpcAnswer.Signature())
|
||||||
|
|
||||||
|
cnr.SetSignature(sig)
|
||||||
|
|
||||||
return cnr, nil
|
return cnr, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue