mirror of
https://github.com/rclone/rclone.git
synced 2024-11-22 08:23:47 +01:00
serve nfs: convert options to new style
This commit is contained in:
parent
58da1a165c
commit
28ba4b832d
@ -15,7 +15,6 @@ import (
|
|||||||
"github.com/rclone/rclone/cmd"
|
"github.com/rclone/rclone/cmd"
|
||||||
"github.com/rclone/rclone/fs"
|
"github.com/rclone/rclone/fs"
|
||||||
"github.com/rclone/rclone/fs/config/flags"
|
"github.com/rclone/rclone/fs/config/flags"
|
||||||
"github.com/rclone/rclone/fs/rc"
|
|
||||||
"github.com/rclone/rclone/vfs"
|
"github.com/rclone/rclone/vfs"
|
||||||
"github.com/rclone/rclone/vfs/vfscommon"
|
"github.com/rclone/rclone/vfs/vfscommon"
|
||||||
"github.com/rclone/rclone/vfs/vfsflags"
|
"github.com/rclone/rclone/vfs/vfsflags"
|
||||||
@ -23,19 +22,32 @@ import (
|
|||||||
"github.com/spf13/pflag"
|
"github.com/spf13/pflag"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// OptionsInfo descripts the Options in use
|
||||||
|
var OptionsInfo = fs.Options{{
|
||||||
|
Name: "addr",
|
||||||
|
Default: "",
|
||||||
|
Help: "IPaddress:Port or :Port to bind server to",
|
||||||
|
}, {
|
||||||
|
Name: "nfs_cache_handle_limit",
|
||||||
|
Default: 1000000,
|
||||||
|
Help: "max file handles cached simultaneously (min 5)",
|
||||||
|
}}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
fs.RegisterGlobalOptions(fs.OptionsInfo{Name: "nfs", Opt: &opt, Options: OptionsInfo})
|
||||||
|
}
|
||||||
|
|
||||||
// Options contains options for the NFS Server
|
// Options contains options for the NFS Server
|
||||||
type Options struct {
|
type Options struct {
|
||||||
ListenAddr string // Port to listen on
|
ListenAddr string `config:"addr"` // Port to listen on
|
||||||
HandleLimit int // max file handles cached by go-nfs CachingHandler
|
HandleLimit int `config:"nfs_cache_handle_limit"` // max file handles cached by go-nfs CachingHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
var opt Options
|
var opt Options
|
||||||
|
|
||||||
// AddFlags adds flags for serve nfs (and nfsmount)
|
// AddFlags adds flags for serve nfs (and nfsmount)
|
||||||
func AddFlags(flagSet *pflag.FlagSet, Opt *Options) {
|
func AddFlags(flagSet *pflag.FlagSet, Opt *Options) {
|
||||||
rc.AddOption("nfs", &Opt)
|
flags.AddFlagsFromOptions(flagSet, "", OptionsInfo)
|
||||||
flags.StringVarP(flagSet, &Opt.ListenAddr, "addr", "", Opt.ListenAddr, "IPaddress:Port or :Port to bind server to", "")
|
|
||||||
flags.IntVarP(flagSet, &Opt.HandleLimit, "nfs-cache-handle-limit", "", 1000000, "max file handles cached simultaneously (min 5)", "")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
Loading…
Reference in New Issue
Block a user