Add filesystem factory functions and add related cli options

master
Harshavardhana 9 years ago
parent 0cc63706bb
commit 82a0eac659
  1. 2
      Makefile
  2. 34
      main.go
  3. 16
      pkg/server/server.go

@ -29,7 +29,7 @@ lint:
cyclo:
@echo "Running $@:"
@test -z "$$(gocyclo -over 16 . | grep -v Godeps/_workspace/src/ | tee /dev/stderr)"
@test -z "$$(gocyclo -over 19 . | grep -v Godeps/_workspace/src/ | tee /dev/stderr)"
pre-build:
@echo "Running pre-build:"

@ -42,6 +42,7 @@ var commands = []cli.Command{
var modeCommands = []cli.Command{
memoryCmd,
fsCmd,
donutCmd,
}
@ -70,6 +71,23 @@ EXAMPLES:
`,
}
var fsCmd = cli.Command{
Name: "fs",
Description: "Specify a path to instantiate filesystem driver",
Action: runFilesystem,
CustomHelpTemplate: `NAME:
minio mode {{.Name}} - {{.Description}}
USAGE:
minio mode {{.Name}} limit SIZE expire TIME
EXAMPLES:
1. Export an existing filesystem path
$ minio mode {{.Name}} /var/www
`,
}
var donutCmd = cli.Command{
Name: "donut",
Description: "Specify a path to instantiate donut",
@ -204,7 +222,6 @@ func runDonut(c *cli.Context) {
if len(c.Args()) < 1 {
cli.ShowCommandHelpAndExit(c, "donut", 1) // last argument is exit code
}
// supporting multiple paths
var paths []string
if strings.TrimSpace(c.Args().First()) == "" {
@ -226,6 +243,21 @@ func runDonut(c *cli.Context) {
server.StartMinio(servers)
}
func runFilesystem(c *cli.Context) {
if len(c.Args()) != 1 {
cli.ShowCommandHelpAndExit(c, "fs", 1) // last argument is exit code
}
apiServerConfig := getAPIServerConfig(c)
fsDriver := server.FilesystemFactory{
Config: apiServerConfig,
Path: c.Args()[0],
}
apiServer := fsDriver.GetStartServerFunc()
webServer := getWebServerConfigFunc(c)
servers := []server.StartServerFunc{apiServer, webServer}
server.StartMinio(servers)
}
func getAPIServerConfig(c *cli.Context) httpserver.Config {
certFile := c.String("cert")
keyFile := c.String("key")

@ -27,6 +27,7 @@ import (
"github.com/minio/minio/pkg/iodine"
"github.com/minio/minio/pkg/server/httpserver"
"github.com/minio/minio/pkg/storage/drivers/donut"
fs "github.com/minio/minio/pkg/storage/drivers/fs"
"github.com/minio/minio/pkg/storage/drivers/memory"
"github.com/minio/minio/pkg/utils/log"
)
@ -47,6 +48,21 @@ func (f MemoryFactory) GetStartServerFunc() StartServerFunc {
}
}
// FilesystemFactory is used to build filesystem api servers
type FilesystemFactory struct {
httpserver.Config
Path string
}
// GetStartServerFunc builds memory api servers
func (f FilesystemFactory) GetStartServerFunc() StartServerFunc {
return func() (chan<- string, <-chan error) {
_, _, driver := fs.Start(f.Path)
ctrl, status, _ := httpserver.Start(api.HTTPHandler(driver), f.Config)
return ctrl, status
}
}
// WebFactory is used to build web cli servers
type WebFactory struct {
httpserver.Config

Loading…
Cancel
Save