[#886] cli: Fix API flags

Bind API cobra flags(`ttl' and xhdr')
to the Viper.

Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
Pavel Karpy 2021-10-07 13:37:57 +03:00 committed by Alex Vanin
parent 6b1e6456ab
commit 4615ff1392
5 changed files with 11 additions and 2 deletions

View file

@ -83,6 +83,7 @@ var containerCmd = &cobra.Command{
// bind exactly that cmd's flags to
// the viper before execution
bindCommonFlags(cmd)
bindAPIFlags(cmd)
},
}

View file

@ -26,6 +26,7 @@ var netmapCmd = &cobra.Command{
// bind exactly that cmd's flags to
// the viper before execution
bindCommonFlags(cmd)
bindAPIFlags(cmd)
},
}

View file

@ -46,6 +46,7 @@ var (
// bind exactly that cmd's flags to
// the viper before execution
bindCommonFlags(cmd)
bindAPIFlags(cmd)
},
}

View file

@ -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))
}

View file

@ -24,6 +24,7 @@ var storagegroupCmd = &cobra.Command{
// bind exactly that cmd's flags to
// the viper before execution
bindCommonFlags(cmd)
bindAPIFlags(cmd)
},
}