forked from TrueCloudLab/frostfs-node
47 lines
1.5 KiB
Go
47 lines
1.5 KiB
Go
package policy
|
|
|
|
import (
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
var (
|
|
Set = &cobra.Command{
|
|
Use: "set-policy [ExecFeeFactor=<n1>] [StoragePrice=<n2>] [FeePerByte=<n3>]",
|
|
DisableFlagsInUseLine: true,
|
|
Short: "Set global policy values",
|
|
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: SetPolicyCmd,
|
|
ValidArgsFunction: func(cmd *cobra.Command, args []string, toComplete string) ([]string, cobra.ShellCompDirective) {
|
|
return []string{"ExecFeeFactor=", "StoragePrice=", "FeePerByte="}, cobra.ShellCompDirectiveNoSpace
|
|
},
|
|
}
|
|
|
|
Dump = &cobra.Command{
|
|
Use: "dump-policy",
|
|
Short: "Dump FrostFS policy",
|
|
PreRun: func(cmd *cobra.Command, _ []string) {
|
|
_ = viper.BindPFlag(util.EndpointFlag, cmd.Flags().Lookup(util.EndpointFlag))
|
|
},
|
|
RunE: dumpPolicyCmd,
|
|
}
|
|
)
|
|
|
|
func initSetPolicyCmd() {
|
|
Set.Flags().String(util.AlphabetWalletsFlag, "", util.AlphabetWalletsFlagDesc)
|
|
Set.Flags().StringP(util.EndpointFlag, util.EndpointFlagShort, "", util.EndpointFlagDesc)
|
|
Set.Flags().String(util.LocalDumpFlag, "", "Path to the blocks dump file")
|
|
}
|
|
|
|
func initDumpPolicyCmd() {
|
|
Dump.Flags().StringP(util.EndpointFlag, util.EndpointFlagShort, "", util.EndpointFlagDesc)
|
|
}
|
|
|
|
func init() {
|
|
initSetPolicyCmd()
|
|
initDumpPolicyCmd()
|
|
}
|