From 638e9576d144b677e7823924eb05e1f3c98027da Mon Sep 17 00:00:00 2001 From: Alejandro Lopez Date: Mon, 10 Jul 2023 11:03:02 +0300 Subject: [PATCH] [#244] Remove --local-dump from frostfs-adm config Signed-off-by: Alejandro Lopez --- cmd/frostfs-adm/internal/modules/morph/initialize.go | 6 +++--- cmd/frostfs-adm/internal/modules/morph/local_client.go | 3 +-- cmd/frostfs-adm/internal/modules/morph/root.go | 1 - 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/cmd/frostfs-adm/internal/modules/morph/initialize.go b/cmd/frostfs-adm/internal/modules/morph/initialize.go index 9eb867faa..dec1fba20 100644 --- a/cmd/frostfs-adm/internal/modules/morph/initialize.go +++ b/cmd/frostfs-adm/internal/modules/morph/initialize.go @@ -210,11 +210,11 @@ func validateInit(cmd *cobra.Command) error { func createClient(cmd *cobra.Command, v *viper.Viper, wallets []*wallet.Wallet) (Client, error) { var c Client var err error - if v.GetString(localDumpFlag) != "" { - if v.GetString(endpointFlag) != "" { + if ldf := cmd.Flags().Lookup(localDumpFlag); ldf != nil && ldf.Changed { + if cmd.Flags().Changed(endpointFlag) { return nil, fmt.Errorf("`%s` and `%s` flags are mutually exclusive", endpointFlag, localDumpFlag) } - c, err = newLocalClient(cmd, v, wallets) + c, err = newLocalClient(cmd, v, wallets, ldf.Value.String()) } else { c, err = getN3Client(v) } diff --git a/cmd/frostfs-adm/internal/modules/morph/local_client.go b/cmd/frostfs-adm/internal/modules/morph/local_client.go index 45d09c387..0367f7479 100644 --- a/cmd/frostfs-adm/internal/modules/morph/local_client.go +++ b/cmd/frostfs-adm/internal/modules/morph/local_client.go @@ -51,7 +51,7 @@ type localClient struct { maxGasInvoke int64 } -func newLocalClient(cmd *cobra.Command, v *viper.Viper, wallets []*wallet.Wallet) (*localClient, error) { +func newLocalClient(cmd *cobra.Command, v *viper.Viper, wallets []*wallet.Wallet, dumpPath string) (*localClient, error) { cfg, err := config.LoadFile(v.GetString(protoConfigPath)) if err != nil { return nil, err @@ -87,7 +87,6 @@ func newLocalClient(cmd *cobra.Command, v *viper.Viper, wallets []*wallet.Wallet go bc.Run() - dumpPath := v.GetString(localDumpFlag) if cmd.Name() != "init" { f, err := os.OpenFile(dumpPath, os.O_RDONLY, 0600) if err != nil { diff --git a/cmd/frostfs-adm/internal/modules/morph/root.go b/cmd/frostfs-adm/internal/modules/morph/root.go index 431be125c..6a9e5b9c1 100644 --- a/cmd/frostfs-adm/internal/modules/morph/root.go +++ b/cmd/frostfs-adm/internal/modules/morph/root.go @@ -77,7 +77,6 @@ var ( _ = viper.BindPFlag(containerAliasFeeInitFlag, cmd.Flags().Lookup(containerAliasFeeCLIFlag)) _ = viper.BindPFlag(withdrawFeeInitFlag, cmd.Flags().Lookup(withdrawFeeCLIFlag)) _ = viper.BindPFlag(protoConfigPath, cmd.Flags().Lookup(protoConfigPath)) - _ = viper.BindPFlag(localDumpFlag, cmd.Flags().Lookup(localDumpFlag)) }, RunE: initializeSideChainCmd, }