forked from TrueCloudLab/frostfs-node
[#932] adm: Move dump/restore/list-containers
to package container
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
be15eab82a
commit
36fd6c663c
3 changed files with 74 additions and 58 deletions
68
cmd/frostfs-adm/internal/modules/morph/container/root.go
Normal file
68
cmd/frostfs-adm/internal/modules/morph/container/root.go
Normal file
|
@ -0,0 +1,68 @@
|
|||
package container
|
||||
|
||||
import (
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const (
|
||||
containerDumpFlag = "dump"
|
||||
containerContractFlag = "container-contract"
|
||||
containerIDsFlag = "cid"
|
||||
)
|
||||
|
||||
var (
|
||||
DumpCmd = &cobra.Command{
|
||||
Use: "dump-containers",
|
||||
Short: "Dump FrostFS containers to file",
|
||||
PreRun: func(cmd *cobra.Command, _ []string) {
|
||||
_ = viper.BindPFlag(util.EndpointFlag, cmd.Flags().Lookup(util.EndpointFlag))
|
||||
},
|
||||
RunE: dumpContainers,
|
||||
}
|
||||
|
||||
RestoreCmd = &cobra.Command{
|
||||
Use: "restore-containers",
|
||||
Short: "Restore FrostFS containers from file",
|
||||
PreRun: func(cmd *cobra.Command, _ []string) {
|
||||
_ = viper.BindPFlag(util.AlphabetWalletsFlag, cmd.Flags().Lookup(util.AlphabetWalletsFlag))
|
||||
_ = viper.BindPFlag(util.EndpointFlag, cmd.Flags().Lookup(util.EndpointFlag))
|
||||
},
|
||||
RunE: restoreContainers,
|
||||
}
|
||||
|
||||
ListCmd = &cobra.Command{
|
||||
Use: "list-containers",
|
||||
Short: "List FrostFS containers",
|
||||
PreRun: func(cmd *cobra.Command, _ []string) {
|
||||
_ = viper.BindPFlag(util.EndpointFlag, cmd.Flags().Lookup(util.EndpointFlag))
|
||||
},
|
||||
RunE: listContainers,
|
||||
}
|
||||
)
|
||||
|
||||
func initListContainersCmd() {
|
||||
ListCmd.Flags().StringP(util.EndpointFlag, util.EndpointFlagShort, "", util.EndpointFlagDesc)
|
||||
ListCmd.Flags().String(containerContractFlag, "", "Container contract hash (for networks without NNS)")
|
||||
}
|
||||
|
||||
func initRestoreContainersCmd() {
|
||||
RestoreCmd.Flags().String(util.AlphabetWalletsFlag, "", util.AlphabetWalletsFlagDesc)
|
||||
RestoreCmd.Flags().StringP(util.EndpointFlag, util.EndpointFlagShort, "", util.EndpointFlagDesc)
|
||||
RestoreCmd.Flags().String(containerDumpFlag, "", "File to restore containers from")
|
||||
RestoreCmd.Flags().StringSlice(containerIDsFlag, nil, "Containers to restore")
|
||||
}
|
||||
|
||||
func initDumpContainersCmd() {
|
||||
DumpCmd.Flags().StringP(util.EndpointFlag, util.EndpointFlagShort, "", util.EndpointFlagDesc)
|
||||
DumpCmd.Flags().String(containerDumpFlag, "", "File where to save dumped containers")
|
||||
DumpCmd.Flags().String(containerContractFlag, "", "Container contract hash (for networks without NNS)")
|
||||
DumpCmd.Flags().StringSlice(containerIDsFlag, nil, "Containers to dump")
|
||||
}
|
||||
|
||||
func init() {
|
||||
initDumpContainersCmd()
|
||||
initRestoreContainersCmd()
|
||||
initListContainersCmd()
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue