Move to frostfs-node
Signed-off-by: Pavel Karpy <p.karpy@yadro.com>
This commit is contained in:
parent
42554a9298
commit
923f84722a
934 changed files with 3470 additions and 3451 deletions
33
cmd/frostfs-cli/internal/commonflags/api.go
Normal file
33
cmd/frostfs-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))
|
||||
}
|
9
cmd/frostfs-cli/internal/commonflags/expiration.go
Normal file
9
cmd/frostfs-cli/internal/commonflags/expiration.go
Normal file
|
@ -0,0 +1,9 @@
|
|||
package commonflags
|
||||
|
||||
const (
|
||||
// ExpireAt is a flag for setting last epoch of an object or a token.
|
||||
ExpireAt = "expire-at"
|
||||
// Lifetime is a flag for setting the lifetime of an object or a token,
|
||||
// starting from the current epoch.
|
||||
Lifetime = "lifetime"
|
||||
)
|
84
cmd/frostfs-cli/internal/commonflags/flags.go
Normal file
84
cmd/frostfs-cli/internal/commonflags/flags.go
Normal file
|
@ -0,0 +1,84 @@
|
|||
package commonflags
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
// Common CLI flag keys, shorthands, default
|
||||
// values and their usage descriptions.
|
||||
const (
|
||||
GenerateKey = "generate-key"
|
||||
generateKeyShorthand = "g"
|
||||
generateKeyDefault = false
|
||||
generateKeyUsage = "Generate new private key"
|
||||
|
||||
WalletPath = "wallet"
|
||||
WalletPathShorthand = "w"
|
||||
WalletPathDefault = ""
|
||||
WalletPathUsage = "Path to the wallet or binary key"
|
||||
|
||||
Account = "address"
|
||||
AccountShorthand = ""
|
||||
AccountDefault = ""
|
||||
AccountUsage = "Address of wallet account"
|
||||
|
||||
RPC = "rpc-endpoint"
|
||||
RPCShorthand = "r"
|
||||
RPCDefault = ""
|
||||
RPCUsage = "Remote node address (as 'multiaddr' or '<host>:<port>')"
|
||||
|
||||
Timeout = "timeout"
|
||||
TimeoutShorthand = "t"
|
||||
TimeoutDefault = 15 * time.Second
|
||||
TimeoutUsage = "Timeout for an operation"
|
||||
|
||||
Verbose = "verbose"
|
||||
VerboseShorthand = "v"
|
||||
VerboseUsage = "Verbose output"
|
||||
|
||||
ForceFlag = "force"
|
||||
ForceFlagShorthand = "f"
|
||||
|
||||
CIDFlag = "cid"
|
||||
CIDFlagUsage = "Container ID."
|
||||
|
||||
OIDFlag = "oid"
|
||||
OIDFlagUsage = "Object ID."
|
||||
)
|
||||
|
||||
// Init adds common flags to the command:
|
||||
// - GenerateKey,
|
||||
// - WalletPath,
|
||||
// - Account,
|
||||
// - RPC,
|
||||
// - Timeout.
|
||||
func Init(cmd *cobra.Command) {
|
||||
InitWithoutRPC(cmd)
|
||||
|
||||
ff := cmd.Flags()
|
||||
ff.StringP(RPC, RPCShorthand, RPCDefault, RPCUsage)
|
||||
ff.DurationP(Timeout, TimeoutShorthand, TimeoutDefault, TimeoutUsage)
|
||||
}
|
||||
|
||||
// InitWithoutRPC is similar to Init but doesn't create the RPC flag.
|
||||
func InitWithoutRPC(cmd *cobra.Command) {
|
||||
ff := cmd.Flags()
|
||||
|
||||
ff.BoolP(GenerateKey, generateKeyShorthand, generateKeyDefault, generateKeyUsage)
|
||||
ff.StringP(WalletPath, WalletPathShorthand, WalletPathDefault, WalletPathUsage)
|
||||
ff.StringP(Account, AccountShorthand, AccountDefault, AccountUsage)
|
||||
}
|
||||
|
||||
// Bind binds common command flags to the viper.
|
||||
func Bind(cmd *cobra.Command) {
|
||||
ff := cmd.Flags()
|
||||
|
||||
_ = viper.BindPFlag(GenerateKey, ff.Lookup(GenerateKey))
|
||||
_ = viper.BindPFlag(WalletPath, ff.Lookup(WalletPath))
|
||||
_ = viper.BindPFlag(Account, ff.Lookup(Account))
|
||||
_ = viper.BindPFlag(RPC, ff.Lookup(RPC))
|
||||
_ = viper.BindPFlag(Timeout, ff.Lookup(Timeout))
|
||||
}
|
3
cmd/frostfs-cli/internal/commonflags/json.go
Normal file
3
cmd/frostfs-cli/internal/commonflags/json.go
Normal file
|
@ -0,0 +1,3 @@
|
|||
package commonflags
|
||||
|
||||
const JSON = "json"
|
19
cmd/frostfs-cli/internal/commonflags/session.go
Normal file
19
cmd/frostfs-cli/internal/commonflags/session.go
Normal file
|
@ -0,0 +1,19 @@
|
|||
package commonflags
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
const SessionToken = "session"
|
||||
|
||||
// InitSession registers SessionToken flag representing filepath to the token
|
||||
// of the session with the given name. Supports NeoFS-binary and JSON files.
|
||||
func InitSession(cmd *cobra.Command, name string) {
|
||||
cmd.Flags().String(
|
||||
SessionToken,
|
||||
"",
|
||||
fmt.Sprintf("Filepath to a JSON- or binary-encoded token of the %s session", name),
|
||||
)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue