forked from TrueCloudLab/frostfs-node
[#390] cli: Fix bearer token reading for tree subcommands
Signed-off-by: Airat Arifullin a.arifullin@yadro.comlogs-linter
parent
676a3efa79
commit
0754e6e654
|
@ -55,13 +55,18 @@ func add(cmd *cobra.Command, _ []string) {
|
||||||
rawCID := make([]byte, sha256.Size)
|
rawCID := make([]byte, sha256.Size)
|
||||||
cnr.Encode(rawCID)
|
cnr.Encode(rawCID)
|
||||||
|
|
||||||
|
var bt []byte
|
||||||
|
if t := common.ReadBearerToken(cmd, bearerFlagKey); t != nil {
|
||||||
|
bt = t.Marshal()
|
||||||
|
}
|
||||||
|
|
||||||
req := new(tree.AddRequest)
|
req := new(tree.AddRequest)
|
||||||
req.Body = &tree.AddRequest_Body{
|
req.Body = &tree.AddRequest_Body{
|
||||||
ContainerId: rawCID,
|
ContainerId: rawCID,
|
||||||
TreeId: tid,
|
TreeId: tid,
|
||||||
ParentId: pid,
|
ParentId: pid,
|
||||||
Meta: meta,
|
Meta: meta,
|
||||||
BearerToken: common.ReadBearerToken(cmd, bearerFlagKey).Marshal(),
|
BearerToken: bt,
|
||||||
}
|
}
|
||||||
|
|
||||||
commonCmd.ExitOnErr(cmd, "signing message: %w", tree.SignMessage(req, pk))
|
commonCmd.ExitOnErr(cmd, "signing message: %w", tree.SignMessage(req, pk))
|
||||||
|
|
|
@ -63,6 +63,11 @@ func addByPath(cmd *cobra.Command, _ []string) {
|
||||||
|
|
||||||
path, _ := cmd.Flags().GetString(pathFlagKey)
|
path, _ := cmd.Flags().GetString(pathFlagKey)
|
||||||
|
|
||||||
|
var bt []byte
|
||||||
|
if t := common.ReadBearerToken(cmd, bearerFlagKey); t != nil {
|
||||||
|
bt = t.Marshal()
|
||||||
|
}
|
||||||
|
|
||||||
req := new(tree.AddByPathRequest)
|
req := new(tree.AddByPathRequest)
|
||||||
req.Body = &tree.AddByPathRequest_Body{
|
req.Body = &tree.AddByPathRequest_Body{
|
||||||
ContainerId: rawCID,
|
ContainerId: rawCID,
|
||||||
|
@ -71,7 +76,7 @@ func addByPath(cmd *cobra.Command, _ []string) {
|
||||||
// PathAttribute: pAttr,
|
// PathAttribute: pAttr,
|
||||||
Path: strings.Split(path, "/"),
|
Path: strings.Split(path, "/"),
|
||||||
Meta: meta,
|
Meta: meta,
|
||||||
BearerToken: common.ReadBearerToken(cmd, bearerFlagKey).Marshal(),
|
BearerToken: bt,
|
||||||
}
|
}
|
||||||
|
|
||||||
commonCmd.ExitOnErr(cmd, "signing message: %w", tree.SignMessage(req, pk))
|
commonCmd.ExitOnErr(cmd, "signing message: %w", tree.SignMessage(req, pk))
|
||||||
|
|
Loading…
Reference in New Issue