[#932] adm: Move command morph proxy to package proxy

Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
Anton Nikiforov 2024-02-01 16:31:46 +03:00
parent 218bd72f9a
commit 8148c9dc19
3 changed files with 47 additions and 36 deletions

View file

@ -1,4 +1,4 @@
package morph
package proxy
import (
"fmt"

View file

@ -0,0 +1,43 @@
package proxy
import (
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
"github.com/spf13/cobra"
"github.com/spf13/viper"
)
var (
AddAccountCmd = &cobra.Command{
Use: "proxy-add-account",
Short: "Adds account to proxy contract",
PreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlag(util.AlphabetWalletsFlag, cmd.Flags().Lookup(util.AlphabetWalletsFlag))
_ = viper.BindPFlag(util.EndpointFlag, cmd.Flags().Lookup(util.EndpointFlag))
},
Run: addProxyAccount,
}
RemoveAccountCmd = &cobra.Command{
Use: "proxy-remove-account",
Short: "Remove from proxy contract",
PreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlag(util.AlphabetWalletsFlag, cmd.Flags().Lookup(util.AlphabetWalletsFlag))
_ = viper.BindPFlag(util.EndpointFlag, cmd.Flags().Lookup(util.EndpointFlag))
},
Run: removeProxyAccount,
}
)
func initProxyAddAccount() {
AddAccountCmd.Flags().StringP(util.EndpointFlag, util.EndpointFlagShort, "", util.EndpointFlagDesc)
AddAccountCmd.Flags().String(accountAddressFlag, "", "Wallet address string")
}
func initProxyRemoveAccount() {
RemoveAccountCmd.Flags().StringP(util.EndpointFlag, util.EndpointFlagShort, "", util.EndpointFlagDesc)
RemoveAccountCmd.Flags().String(accountAddressFlag, "", "Wallet address string")
}
func init() {
initProxyAddAccount()
initProxyRemoveAccount()
}

View file

@ -4,6 +4,7 @@ import (
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/ape"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/frostfsid"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/policy"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/proxy"
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-adm/internal/modules/morph/util"
"github.com/spf13/cobra"
"github.com/spf13/viper"
@ -215,26 +216,6 @@ var (
},
Run: listNetmapCandidatesNodes,
}
proxyAddAccountCmd = &cobra.Command{
Use: "proxy-add-account",
Short: "Adds account to proxy contract",
PreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlag(util.AlphabetWalletsFlag, cmd.Flags().Lookup(util.AlphabetWalletsFlag))
_ = viper.BindPFlag(util.EndpointFlag, cmd.Flags().Lookup(util.EndpointFlag))
},
Run: addProxyAccount,
}
proxyRemoveAccountCmd = &cobra.Command{
Use: "proxy-remove-account",
Short: "Remove from proxy contract",
PreRun: func(cmd *cobra.Command, _ []string) {
_ = viper.BindPFlag(util.AlphabetWalletsFlag, cmd.Flags().Lookup(util.AlphabetWalletsFlag))
_ = viper.BindPFlag(util.EndpointFlag, cmd.Flags().Lookup(util.EndpointFlag))
},
Run: removeProxyAccount,
}
)
func init() {
@ -259,25 +240,12 @@ func init() {
initNetmapCandidatesCmd()
RootCmd.AddCommand(ape.Cmd)
initProxyAddAccount()
initProxyRemoveAccount()
RootCmd.AddCommand(proxy.AddAccountCmd)
RootCmd.AddCommand(proxy.RemoveAccountCmd)
RootCmd.AddCommand(frostfsid.Cmd)
}
func initProxyAddAccount() {
RootCmd.AddCommand(proxyAddAccountCmd)
proxyAddAccountCmd.Flags().StringP(util.EndpointFlag, util.EndpointFlagShort, "", util.EndpointFlagDesc)
proxyAddAccountCmd.Flags().String(accountAddressFlag, "", "Wallet address string")
}
func initProxyRemoveAccount() {
RootCmd.AddCommand(proxyRemoveAccountCmd)
proxyRemoveAccountCmd.Flags().StringP(util.EndpointFlag, util.EndpointFlagShort, "", util.EndpointFlagDesc)
proxyRemoveAccountCmd.Flags().String(accountAddressFlag, "", "Wallet address string")
}
func initNetmapCandidatesCmd() {
RootCmd.AddCommand(netmapCandidatesCmd)
netmapCandidatesCmd.Flags().StringP(util.EndpointFlag, util.EndpointFlagShort, "", util.EndpointFlagDesc)