All checks were successful
Vulncheck / Vulncheck (push) Successful in 1m38s
Pre-commit hooks / Pre-commit (push) Successful in 1m57s
Build / Build Components (push) Successful in 2m9s
Tests and linters / gopls check (push) Successful in 3m57s
OCI image / Build container images (push) Successful in 4m20s
Tests and linters / Run gofumpt (push) Successful in 5m4s
Tests and linters / Staticcheck (push) Successful in 5m35s
Tests and linters / Lint (push) Successful in 5m39s
Tests and linters / Tests (push) Successful in 5m40s
Tests and linters / Tests with -race (push) Successful in 5m56s
Change-Id: I051a27af57a74304713c1f832dc31dbaeb10cbc6 Signed-off-by: Dmitrii Stepanov <d.stepanov@yadro.com>
33 lines
818 B
Go
33 lines
818 B
Go
package commonflags
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
"github.com/spf13/viper"
|
|
)
|
|
|
|
const (
|
|
TTL = "ttl"
|
|
TTLShorthand = ""
|
|
TTLDefault = 2
|
|
TTLUsage = "The maximum number of intermediate nodes in the request route"
|
|
|
|
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))
|
|
}
|