2024-02-02 07:15:55 +00:00
|
|
|
package generate
|
|
|
|
|
|
|
|
import (
|
2024-02-02 12:04:48 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/commonflags"
|
2024-02-02 07:15:55 +00:00
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"github.com/spf13/viper"
|
|
|
|
)
|
|
|
|
|
|
|
|
const (
|
|
|
|
storageWalletLabelFlag = "label"
|
|
|
|
storageGasCLIFlag = "initial-gas"
|
|
|
|
storageGasConfigFlag = "storage.initial_gas"
|
|
|
|
walletAddressFlag = "wallet-address"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
GenerateStorageCmd = &cobra.Command{
|
|
|
|
Use: "generate-storage-wallet",
|
|
|
|
Short: "Generate storage node wallet for the morph network",
|
|
|
|
PreRun: func(cmd *cobra.Command, _ []string) {
|
2024-02-02 12:04:48 +00:00
|
|
|
_ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag))
|
|
|
|
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
|
2024-02-02 07:15:55 +00:00
|
|
|
_ = viper.BindPFlag(storageGasConfigFlag, cmd.Flags().Lookup(storageGasCLIFlag))
|
|
|
|
},
|
|
|
|
RunE: generateStorageCreds,
|
|
|
|
}
|
|
|
|
RefillGasCmd = &cobra.Command{
|
|
|
|
Use: "refill-gas",
|
|
|
|
Short: "Refill GAS of storage node's wallet in the morph network",
|
|
|
|
PreRun: func(cmd *cobra.Command, _ []string) {
|
2024-02-02 12:04:48 +00:00
|
|
|
_ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag))
|
|
|
|
_ = viper.BindPFlag(commonflags.EndpointFlag, cmd.Flags().Lookup(commonflags.EndpointFlag))
|
|
|
|
_ = viper.BindPFlag(commonflags.RefillGasAmountFlag, cmd.Flags().Lookup(commonflags.RefillGasAmountFlag))
|
2024-02-02 07:15:55 +00:00
|
|
|
},
|
2024-03-11 14:11:49 +00:00
|
|
|
RunE: func(cmd *cobra.Command, _ []string) error {
|
2024-02-02 12:04:48 +00:00
|
|
|
return refillGas(cmd, commonflags.RefillGasAmountFlag, false)
|
2024-02-02 07:15:55 +00:00
|
|
|
},
|
|
|
|
}
|
|
|
|
GenerateAlphabetCmd = &cobra.Command{
|
|
|
|
Use: "generate-alphabet",
|
|
|
|
Short: "Generate alphabet wallets for consensus nodes of the morph network",
|
|
|
|
PreRun: func(cmd *cobra.Command, _ []string) {
|
|
|
|
// PreRun fixes https://github.com/spf13/viper/issues/233
|
2024-02-02 12:04:48 +00:00
|
|
|
_ = viper.BindPFlag(commonflags.AlphabetWalletsFlag, cmd.Flags().Lookup(commonflags.AlphabetWalletsFlag))
|
2024-02-02 07:15:55 +00:00
|
|
|
},
|
|
|
|
RunE: AlphabetCreds,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func initRefillGasCmd() {
|
2024-02-02 12:04:48 +00:00
|
|
|
RefillGasCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
|
|
|
|
RefillGasCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
|
|
|
RefillGasCmd.Flags().String(commonflags.StorageWalletFlag, "", "Path to storage node wallet")
|
2024-02-02 07:15:55 +00:00
|
|
|
RefillGasCmd.Flags().String(walletAddressFlag, "", "Address of wallet")
|
2024-02-02 12:04:48 +00:00
|
|
|
RefillGasCmd.Flags().String(commonflags.RefillGasAmountFlag, "", "Additional amount of GAS to transfer")
|
|
|
|
RefillGasCmd.MarkFlagsMutuallyExclusive(walletAddressFlag, commonflags.StorageWalletFlag)
|
2024-02-02 07:15:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func initGenerateStorageCmd() {
|
2024-02-02 12:04:48 +00:00
|
|
|
GenerateStorageCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
|
|
|
|
GenerateStorageCmd.Flags().StringP(commonflags.EndpointFlag, commonflags.EndpointFlagShort, "", commonflags.EndpointFlagDesc)
|
|
|
|
GenerateStorageCmd.Flags().String(commonflags.StorageWalletFlag, "", "Path to new storage node wallet")
|
2024-02-02 07:15:55 +00:00
|
|
|
GenerateStorageCmd.Flags().String(storageGasCLIFlag, "", "Initial amount of GAS to transfer")
|
|
|
|
GenerateStorageCmd.Flags().StringP(storageWalletLabelFlag, "l", "", "Wallet label")
|
|
|
|
}
|
|
|
|
|
|
|
|
func initGenerateAlphabetCmd() {
|
2024-02-02 12:04:48 +00:00
|
|
|
GenerateAlphabetCmd.Flags().String(commonflags.AlphabetWalletsFlag, "", commonflags.AlphabetWalletsFlagDesc)
|
|
|
|
GenerateAlphabetCmd.Flags().Uint(commonflags.AlphabetSizeFlag, 7, "Amount of alphabet wallets to generate")
|
2024-02-02 07:15:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
initRefillGasCmd()
|
|
|
|
initGenerateStorageCmd()
|
|
|
|
initGenerateAlphabetCmd()
|
|
|
|
}
|