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>
58 lines
1.3 KiB
Go
58 lines
1.3 KiB
Go
package container
|
|
|
|
import (
|
|
"github.com/nspcc-dev/neofs-node/cmd/neofs-cli/internal/commonflags"
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
// Cmd represents the container command.
|
|
var Cmd = &cobra.Command{
|
|
Use: "container",
|
|
Short: "Operations with containers",
|
|
Long: "Operations with containers",
|
|
PersistentPreRun: func(cmd *cobra.Command, args []string) {
|
|
// bind exactly that cmd's flags to
|
|
// the viper before execution
|
|
commonflags.Bind(cmd)
|
|
commonflags.BindAPI(cmd)
|
|
},
|
|
}
|
|
|
|
func init() {
|
|
containerChildCommand := []*cobra.Command{
|
|
listContainersCmd,
|
|
createContainerCmd,
|
|
deleteContainerCmd,
|
|
listContainerObjectsCmd,
|
|
getContainerInfoCmd,
|
|
getExtendedACLCmd,
|
|
setExtendedACLCmd,
|
|
containerNodesCmd,
|
|
}
|
|
|
|
Cmd.AddCommand(containerChildCommand...)
|
|
|
|
initContainerListContainersCmd()
|
|
initContainerCreateCmd()
|
|
initContainerDeleteCmd()
|
|
initContainerListObjectsCmd()
|
|
initContainerInfoCmd()
|
|
initContainerGetEACLCmd()
|
|
initContainerSetEACLCmd()
|
|
initContainerNodesCmd()
|
|
|
|
for _, containerCommand := range containerChildCommand {
|
|
commonflags.InitAPI(containerCommand)
|
|
}
|
|
|
|
for _, el := range []struct {
|
|
cmd *cobra.Command
|
|
verb string
|
|
}{
|
|
{createContainerCmd, "PUT"},
|
|
{deleteContainerCmd, "DELETE"},
|
|
{setExtendedACLCmd, "SETEACL"},
|
|
} {
|
|
commonflags.InitSession(el.cmd, "container "+el.verb)
|
|
}
|
|
}
|