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() }