From 9b2758baf1336bc3ea2ddb81bc4279647f8f49bb Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 15 Nov 2023 13:33:30 +0300 Subject: [PATCH 1/3] [#808] go.mod: Update dependencies Signed-off-by: Evgenii Stratonikov --- go.mod | 10 +++++----- go.sum | Bin 328127 -> 328462 bytes 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/go.mod b/go.mod index 5c22fdfc2..c48c8781e 100644 --- a/go.mod +++ b/go.mod @@ -27,11 +27,11 @@ require ( github.com/paulmach/orb v0.9.2 github.com/prometheus/client_golang v1.16.0 github.com/spf13/cast v1.5.1 - github.com/spf13/cobra v1.7.0 + github.com/spf13/cobra v1.8.0 github.com/spf13/pflag v1.0.5 github.com/spf13/viper v1.16.0 github.com/stretchr/testify v1.8.4 - go.etcd.io/bbolt v1.3.7 + go.etcd.io/bbolt v1.3.8 go.opentelemetry.io/otel v1.16.0 go.opentelemetry.io/otel/trace v1.16.0 go.uber.org/zap v1.26.0 @@ -63,7 +63,7 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // indirect github.com/consensys/bavard v0.1.13 // indirect github.com/consensys/gnark-crypto v0.12.2-0.20231013160410-1f65e75b6dfb // indirect - github.com/cpuguy83/go-md2man/v2 v2.0.2 // indirect + github.com/cpuguy83/go-md2man/v2 v2.0.3 // indirect github.com/davecgh/go-spew v1.1.1 // indirect github.com/decred/dcrd/dcrec/secp256k1/v4 v4.2.0 // indirect github.com/dgraph-io/badger/v4 v4.1.0 @@ -124,8 +124,8 @@ require ( go.uber.org/multierr v1.11.0 // indirect golang.org/x/crypto v0.14.0 // indirect golang.org/x/net v0.17.0 // indirect - golang.org/x/sys v0.13.0 // indirect - golang.org/x/text v0.13.0 // indirect + golang.org/x/sys v0.14.0 // indirect + golang.org/x/text v0.14.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20231016165738-49dd2c1f3d0b // indirect gopkg.in/ini.v1 v1.67.0 // indirect diff --git a/go.sum b/go.sum index 806648251a87ae0a88775fbdc251e2e17884ced0..ebf29ce8dc5ce8644acc5e6bb07204f55476a2e3 100644 GIT binary patch delta 560 zcmXxfId9Wo0LF2-wwiEA5s-$e6O2_v?bnXuH%xU7=dyG9h>bvUbJWh!*l`H4CnO}; zV0=eFkZcSHq%4&>qt5vN>Z@D4&Mc$>ytg5bTi{wW<p#vG&}>kg-))MgXO;EaXo`MhUz8l* z{FF!M0N=;pY9qW`qc0&Mhkjq;AqFI_KB)m$_mXr<8k7ckzc5#Zje;F$rAD6a!`?}~ z+|P+>vts#N9sRt-V`%*qkHkq;vAT|JmZZAkB;sR}NrN=bF~fmbd}<&MpO0&7o&MnBDxZdtDAK~q6@4v71Rj1i&L JvpvH6^&c?#wCMl< delta 410 zcmeBc6WQM^(y)awda1rbhM`q~p=)}%r@phfUq*<5S8iB#xwDH=l#{nbmPul&M_`0e zfv<;$Q<`s}S^4ydOBpq$M=fP^o&IkbBY%79GREzx%a}@Hjm-57KxSoB7KZ0VmKa6_ z24{Gtr1+a=I~8OZmz5fr>T7FPn3Z^$rKDT9I-8msc}`_y7MU*3!pva_)T^JKua}#j z0y3i1ry|PJC#W)5-_#&HC&S;<+r>QGEX*`1J=L>B+oagjxgx`?G|0Co$zb|H7G{m@ z9W2Z#x?rDVX;*pq=jFL(x#?$DdgQpcq`T*Z`RF@(7J7OG6k3GlI~lnL`=w=vrUg#F zY{(q5{g@H6&sDHi$25yP?||G=x5|RdP^YZ0{7}m0#*+930JW`zi2wiq -- 2.45.2 From 4b1223980981228177ab3c712c8bf4fa045460b1 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 15 Nov 2023 14:26:23 +0300 Subject: [PATCH 2/3] [#808] cli: Use MarkFlagsOneRequired after cobra update Signed-off-by: Evgenii Stratonikov --- cmd/frostfs-cli/modules/control/ir_remove_container.go | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/cmd/frostfs-cli/modules/control/ir_remove_container.go b/cmd/frostfs-cli/modules/control/ir_remove_container.go index 52eaa574d..a66d7e06d 100644 --- a/cmd/frostfs-cli/modules/control/ir_remove_container.go +++ b/cmd/frostfs-cli/modules/control/ir_remove_container.go @@ -1,8 +1,6 @@ package control import ( - "errors" - "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/refs" rawclient "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/rpc/client" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags" @@ -35,6 +33,7 @@ func initControlIRRemoveContainerCmd() { flags.String(commonflags.CIDFlag, "", commonflags.CIDFlagUsage) flags.String(ownerFlag, "", "Container owner's wallet address.") removeContainerCmd.MarkFlagsMutuallyExclusive(commonflags.CIDFlag, ownerFlag) + removeContainerCmd.MarkFlagsOneRequired(commonflags.CIDFlag, ownerFlag) } func removeContainer(cmd *cobra.Command, _ []string) { @@ -74,10 +73,6 @@ func prepareRemoveContainerRequest(cmd *cobra.Command) *ircontrol.RemoveContaine ownerStr, err := cmd.Flags().GetString(ownerFlag) commonCmd.ExitOnErr(cmd, "failed to get owner: ", err) - if len(ownerStr) == 0 && len(cidStr) == 0 { - commonCmd.ExitOnErr(cmd, "invalid usage: %w", errors.New("neither owner's wallet address nor container ID are specified")) - } - if len(ownerStr) > 0 { var owner user.ID commonCmd.ExitOnErr(cmd, "invalid owner ID: %w", owner.DecodeString(ownerStr)) -- 2.45.2 From e81f8689f53eba70a09c4e7eea3b29340c4cd4c4 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Wed, 15 Nov 2023 14:31:37 +0300 Subject: [PATCH 3/3] [#808] cli: Use EnableTraverseRunHooks in cobra Adopt EnableTraverseRunHooks to get rid of tracing boilerplate in multiple commands. Now adding `--trace` flag is sufficient for a command to support tracing. Finally, it looks how it _should_. Refs https://git.frostfs.info/TrueCloudLab/frostfs-node/pulls/406 Signed-off-by: Evgenii Stratonikov --- cmd/frostfs-cli/modules/accounting/root.go | 3 --- cmd/frostfs-cli/modules/container/root.go | 3 --- cmd/frostfs-cli/modules/netmap/root.go | 3 --- cmd/frostfs-cli/modules/object/root.go | 3 --- cmd/frostfs-cli/modules/root.go | 5 +++++ cmd/frostfs-cli/modules/session/create.go | 3 --- 6 files changed, 5 insertions(+), 15 deletions(-) diff --git a/cmd/frostfs-cli/modules/accounting/root.go b/cmd/frostfs-cli/modules/accounting/root.go index f94488b6f..8ab8aa125 100644 --- a/cmd/frostfs-cli/modules/accounting/root.go +++ b/cmd/frostfs-cli/modules/accounting/root.go @@ -1,7 +1,6 @@ package accounting import ( - "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -18,9 +17,7 @@ var Cmd = &cobra.Command{ _ = viper.BindPFlag(commonflags.WalletPath, flags.Lookup(commonflags.WalletPath)) _ = viper.BindPFlag(commonflags.Account, flags.Lookup(commonflags.Account)) _ = viper.BindPFlag(commonflags.RPC, flags.Lookup(commonflags.RPC)) - common.StartClientCommandSpan(cmd) }, - PersistentPostRun: common.StopClientCommandSpan, } func init() { diff --git a/cmd/frostfs-cli/modules/container/root.go b/cmd/frostfs-cli/modules/container/root.go index f3c3e0e3a..ab7f5fb90 100644 --- a/cmd/frostfs-cli/modules/container/root.go +++ b/cmd/frostfs-cli/modules/container/root.go @@ -1,7 +1,6 @@ package container import ( - "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags" "github.com/spf13/cobra" ) @@ -16,9 +15,7 @@ var Cmd = &cobra.Command{ // the viper before execution commonflags.Bind(cmd) commonflags.BindAPI(cmd) - common.StartClientCommandSpan(cmd) }, - PersistentPostRun: common.StopClientCommandSpan, } func init() { diff --git a/cmd/frostfs-cli/modules/netmap/root.go b/cmd/frostfs-cli/modules/netmap/root.go index 006ac6d9f..aaa83f12f 100644 --- a/cmd/frostfs-cli/modules/netmap/root.go +++ b/cmd/frostfs-cli/modules/netmap/root.go @@ -1,7 +1,6 @@ package netmap import ( - "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags" "github.com/spf13/cobra" ) @@ -15,9 +14,7 @@ var Cmd = &cobra.Command{ // the viper before execution commonflags.Bind(cmd) commonflags.BindAPI(cmd) - common.StartClientCommandSpan(cmd) }, - PersistentPostRun: common.StopClientCommandSpan, } func init() { diff --git a/cmd/frostfs-cli/modules/object/root.go b/cmd/frostfs-cli/modules/object/root.go index d9d4bb84d..e04366f4d 100644 --- a/cmd/frostfs-cli/modules/object/root.go +++ b/cmd/frostfs-cli/modules/object/root.go @@ -1,7 +1,6 @@ package object import ( - "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags" "github.com/spf13/cobra" ) @@ -16,9 +15,7 @@ var Cmd = &cobra.Command{ // the viper before execution commonflags.Bind(cmd) commonflags.BindAPI(cmd) - common.StartClientCommandSpan(cmd) }, - PersistentPostRun: common.StopClientCommandSpan, } func init() { diff --git a/cmd/frostfs-cli/modules/root.go b/cmd/frostfs-cli/modules/root.go index 808bd6d07..87e6a905f 100644 --- a/cmd/frostfs-cli/modules/root.go +++ b/cmd/frostfs-cli/modules/root.go @@ -46,6 +46,10 @@ of frostfs-api and some useful utilities for compiling ACL rules from JSON notation, managing container access through protocol gates, querying network map and much more!`, Run: entryPoint, + PersistentPreRun: func(cmd *cobra.Command, _ []string) { + common.StartClientCommandSpan(cmd) + }, + PersistentPostRun: common.StopClientCommandSpan, } // Execute adds all child commands to the root command and sets flags appropriately. @@ -57,6 +61,7 @@ func Execute() { func init() { cobra.OnInitialize(initConfig) + cobra.EnableTraverseRunHooks = true // use stdout as default output for cmd.Print() rootCmd.SetOut(os.Stdout) diff --git a/cmd/frostfs-cli/modules/session/create.go b/cmd/frostfs-cli/modules/session/create.go index 94ae595a8..e92e4baa6 100644 --- a/cmd/frostfs-cli/modules/session/create.go +++ b/cmd/frostfs-cli/modules/session/create.go @@ -6,7 +6,6 @@ import ( "os" internalclient "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/client" - "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/common" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/commonflags" "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-cli/internal/key" commonCmd "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/internal/common" @@ -33,9 +32,7 @@ var createCmd = &cobra.Command{ PersistentPreRun: func(cmd *cobra.Command, args []string) { _ = viper.BindPFlag(commonflags.WalletPath, cmd.Flags().Lookup(commonflags.WalletPath)) _ = viper.BindPFlag(commonflags.Account, cmd.Flags().Lookup(commonflags.Account)) - common.StartClientCommandSpan(cmd) }, - PersistentPostRun: common.StopClientCommandSpan, } func init() { -- 2.45.2