From 4615ff139259c37a3dd3ce1197a441fe6a144a70 Mon Sep 17 00:00:00 2001 From: Pavel Karpy Date: Thu, 7 Oct 2021 13:37:57 +0300 Subject: [PATCH] [#886] cli: Fix API flags Bind API cobra flags(`ttl' and xhdr') to the Viper. Signed-off-by: Pavel Karpy --- cmd/neofs-cli/modules/container.go | 1 + cmd/neofs-cli/modules/netmap.go | 1 + cmd/neofs-cli/modules/object.go | 1 + cmd/neofs-cli/modules/root.go | 9 +++++++-- cmd/neofs-cli/modules/storagegroup.go | 1 + 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cmd/neofs-cli/modules/container.go b/cmd/neofs-cli/modules/container.go index 8d630d9a8..56e040bac 100644 --- a/cmd/neofs-cli/modules/container.go +++ b/cmd/neofs-cli/modules/container.go @@ -83,6 +83,7 @@ var containerCmd = &cobra.Command{ // bind exactly that cmd's flags to // the viper before execution bindCommonFlags(cmd) + bindAPIFlags(cmd) }, } diff --git a/cmd/neofs-cli/modules/netmap.go b/cmd/neofs-cli/modules/netmap.go index 79e1ad2da..c8aac1b80 100644 --- a/cmd/neofs-cli/modules/netmap.go +++ b/cmd/neofs-cli/modules/netmap.go @@ -26,6 +26,7 @@ var netmapCmd = &cobra.Command{ // bind exactly that cmd's flags to // the viper before execution bindCommonFlags(cmd) + bindAPIFlags(cmd) }, } diff --git a/cmd/neofs-cli/modules/object.go b/cmd/neofs-cli/modules/object.go index c69a02a93..785c3501b 100644 --- a/cmd/neofs-cli/modules/object.go +++ b/cmd/neofs-cli/modules/object.go @@ -46,6 +46,7 @@ var ( // bind exactly that cmd's flags to // the viper before execution bindCommonFlags(cmd) + bindAPIFlags(cmd) }, } diff --git a/cmd/neofs-cli/modules/root.go b/cmd/neofs-cli/modules/root.go index 7cf1bb68e..38f600725 100644 --- a/cmd/neofs-cli/modules/root.go +++ b/cmd/neofs-cli/modules/root.go @@ -28,8 +28,6 @@ const ( envPrefix = "NEOFS_CLI" ) -const xHeadersFlag = "xhdr" - var xHeaders []string // Global scope flags. @@ -402,3 +400,10 @@ func bindCommonFlags(cmd *cobra.Command) { _ = viper.BindPFlag(rpc, ff.Lookup(rpc)) _ = viper.BindPFlag(verbose, ff.Lookup(verbose)) } + +func bindAPIFlags(cmd *cobra.Command) { + ff := cmd.Flags() + + _ = viper.BindPFlag(ttl, ff.Lookup(ttl)) + _ = viper.BindPFlag(xHeadersKey, ff.Lookup(xHeadersKey)) +} diff --git a/cmd/neofs-cli/modules/storagegroup.go b/cmd/neofs-cli/modules/storagegroup.go index 72de1ccd4..2bf17e383 100644 --- a/cmd/neofs-cli/modules/storagegroup.go +++ b/cmd/neofs-cli/modules/storagegroup.go @@ -24,6 +24,7 @@ var storagegroupCmd = &cobra.Command{ // bind exactly that cmd's flags to // the viper before execution bindCommonFlags(cmd) + bindAPIFlags(cmd) }, }