forked from TrueCloudLab/frostfs-node
8bba490c30
There is a need to support NeoFS-binary sessions along with JSON ones in NeoFS CLI. Provide generic `common.ReadBinaryOrJSON` functions which tries to decode NeoFS-binary structure and falls back to JSON format. Use this function in all places with token reading. Signed-off-by: Leonard Lyubich <ctulhurider@gmail.com>
53 lines
1.4 KiB
Go
53 lines
1.4 KiB
Go
package storagegroup
|
|
|
|
import (
|
|
internalclient "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/client"
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/common"
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/key"
|
|
objectCli "github.com/nspcc-dev/neofs-node/cmd/neofs-cli/modules/object"
|
|
cid "github.com/nspcc-dev/neofs-sdk-go/container/id"
|
|
oid "github.com/nspcc-dev/neofs-sdk-go/object/id"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var sgDelCmd = &cobra.Command{
|
|
Use: "delete",
|
|
Short: "Delete storage group from NeoFS",
|
|
Long: "Delete storage group from NeoFS",
|
|
Run: delSG,
|
|
}
|
|
|
|
func initSGDeleteCmd() {
|
|
commonflags.Init(sgDelCmd)
|
|
|
|
flags := sgDelCmd.Flags()
|
|
|
|
flags.String(cidFlag, "", "Container ID")
|
|
_ = sgDelCmd.MarkFlagRequired(cidFlag)
|
|
|
|
flags.StringVarP(&sgID, sgIDFlag, "", "", "Storage group identifier")
|
|
_ = sgDelCmd.MarkFlagRequired(sgIDFlag)
|
|
}
|
|
|
|
func delSG(cmd *cobra.Command, _ []string) {
|
|
pk := key.GetOrGenerate(cmd)
|
|
|
|
var cnr cid.ID
|
|
var obj oid.ID
|
|
|
|
addr := readObjectAddress(cmd, &cnr, &obj)
|
|
|
|
var prm internalclient.DeleteObjectPrm
|
|
objectCli.OpenSession(cmd, &prm, pk, cnr, &obj)
|
|
objectCli.Prepare(cmd, &prm)
|
|
prm.SetAddress(addr)
|
|
|
|
res, err := internalclient.DeleteObject(prm)
|
|
common.ExitOnErr(cmd, "rpc error: %w", err)
|
|
|
|
tombstone := res.Tombstone()
|
|
|
|
cmd.Println("Storage group removed successfully.")
|
|
cmd.Printf(" Tombstone: %s\n", tombstone)
|
|
}
|