Add filesystem factory functions and add related cli options

This commit is contained in:
Harshavardhana
2015-05-30 03:22:25 -07:00
parent 0cc63706bb
commit 82a0eac659
3 changed files with 50 additions and 2 deletions

34
main.go
View File

@@ -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")