forked from TrueCloudLab/frostfs-node
[#1074] neofs-cli: Move common API flags to a separate package
TTL and XHeader flags are reused between multiple commands. Signed-off-by: Evgenii Stratonikov <evgeniy@nspcc.ru>
This commit is contained in:
parent
736e09a70d
commit
a2bcb3e0ce
6 changed files with 45 additions and 41 deletions
33
cmd/neofs-cli/internal/commonflags/api.go
Normal file
33
cmd/neofs-cli/internal/commonflags/api.go
Normal file
|
@ -0,0 +1,33 @@
|
|||
package commonflags
|
||||
|
||||
import (
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
const (
|
||||
TTL = "ttl"
|
||||
TTLShorthand = ""
|
||||
TTLDefault = 2
|
||||
TTLUsage = "TTL value in request meta header"
|
||||
|
||||
XHeadersKey = "xhdr"
|
||||
XHeadersShorthand = "x"
|
||||
XHeadersUsage = "Request X-Headers in form of Key=Value"
|
||||
)
|
||||
|
||||
// InitAPI inits common flags for storage node services.
|
||||
func InitAPI(cmd *cobra.Command) {
|
||||
ff := cmd.Flags()
|
||||
|
||||
ff.StringSliceP(XHeadersKey, XHeadersShorthand, []string{}, XHeadersUsage)
|
||||
ff.Uint32P(TTL, TTLShorthand, TTLDefault, TTLUsage)
|
||||
}
|
||||
|
||||
// BindAPI binds API flags of storage node services to the viper.
|
||||
func BindAPI(cmd *cobra.Command) {
|
||||
ff := cmd.Flags()
|
||||
|
||||
_ = viper.BindPFlag(TTL, ff.Lookup(TTL))
|
||||
_ = viper.BindPFlag(XHeadersKey, ff.Lookup(XHeadersKey))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue