From 8148c9dc19e8b7fd29d4de916ec66b1772a025ac Mon Sep 17 00:00:00 2001 From: Anton Nikiforov Date: Thu, 1 Feb 2024 16:31:46 +0300 Subject: [PATCH] [#932] adm: Move command `morph proxy` to package `proxy` Signed-off-by: Anton Nikiforov --- .../modules/morph/{ => proxy}/proxy.go | 2 +- .../internal/modules/morph/proxy/root.go | 43 +++++++++++++++++++ .../internal/modules/morph/root.go | 38 ++-------------- 3 files changed, 47 insertions(+), 36 deletions(-) rename cmd/frostfs-adm/internal/modules/morph/{ => proxy}/proxy.go (99%) create mode 100644 cmd/frostfs-adm/internal/modules/morph/proxy/root.go diff --git a/cmd/frostfs-adm/internal/modules/morph/proxy.go b/cmd/frostfs-adm/internal/modules/morph/proxy/proxy.go similarity index 99% rename from cmd/frostfs-adm/internal/modules/morph/proxy.go rename to cmd/frostfs-adm/internal/modules/morph/proxy/proxy.go index aa98fb70..7455c0bd 100644 --- a/cmd/frostfs-adm/internal/modules/morph/proxy.go +++ b/cmd/frostfs-adm/internal/modules/morph/proxy/proxy.go @@ -1,4 +1,4 @@ -package morph +package proxy import ( "fmt" diff --git a/cmd/frostfs-adm/internal/modules/morph/proxy/root.go b/cmd/frostfs-adm/internal/modules/morph/proxy/root.go new file mode 100644 index 00000000..14820d5a --- /dev/null +++ b/cmd/frostfs-adm/internal/modules/morph/proxy/root.go @@ -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() +} diff --git a/cmd/frostfs-adm/internal/modules/morph/root.go b/cmd/frostfs-adm/internal/modules/morph/root.go index 0d6f48d9..7eb41ddc 100644 --- a/cmd/frostfs-adm/internal/modules/morph/root.go +++ b/cmd/frostfs-adm/internal/modules/morph/root.go @@ -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)