Evgenii Stratonikov
e81f8689f5
All checks were successful
DCO action / DCO (pull_request) Successful in 3m49s
Vulncheck / Vulncheck (pull_request) Successful in 5m17s
Build / Build Components (1.21) (pull_request) Successful in 8m46s
Build / Build Components (1.20) (pull_request) Successful in 10m14s
Tests and linters / Staticcheck (pull_request) Successful in 11m0s
Tests and linters / Tests (1.21) (pull_request) Successful in 13m1s
Tests and linters / Lint (pull_request) Successful in 13m20s
Tests and linters / Tests (1.20) (pull_request) Successful in 2m43s
Tests and linters / Tests with -race (pull_request) Successful in 5m21s
Adopt EnableTraverseRunHooks to get rid of tracing boilerplate in multiple commands. Now adding `--trace` flag is sufficient for a command to support tracing. Finally, it looks how it _should_. Refs #406 Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
60 lines
1.4 KiB
Go
60 lines
1.4 KiB
Go
package container
|
|
|
|
import (
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-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,
|
|
policyPlaygroundCmd,
|
|
}
|
|
|
|
Cmd.AddCommand(containerChildCommand...)
|
|
|
|
initContainerListContainersCmd()
|
|
initContainerCreateCmd()
|
|
initContainerDeleteCmd()
|
|
initContainerListObjectsCmd()
|
|
initContainerInfoCmd()
|
|
initContainerGetEACLCmd()
|
|
initContainerSetEACLCmd()
|
|
initContainerNodesCmd()
|
|
initContainerPolicyPlaygroundCmd()
|
|
|
|
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)
|
|
}
|
|
}
|