2015-01-14 14:29:04 -05:00
|
|
|
package main
|
|
|
|
|
2015-01-25 20:15:18 -05:00
|
|
|
import (
|
2015-01-28 19:07:53 -05:00
|
|
|
"log"
|
|
|
|
|
2015-01-25 20:15:18 -05:00
|
|
|
"github.com/minio-io/minio/pkg/server"
|
2015-01-28 18:04:27 -05:00
|
|
|
"github.com/spf13/cobra"
|
2015-01-25 20:15:18 -05:00
|
|
|
)
|
|
|
|
|
2015-01-14 14:29:04 -05:00
|
|
|
func main() {
|
2015-01-28 18:04:27 -05:00
|
|
|
var tls bool
|
2015-01-28 19:07:53 -05:00
|
|
|
var storageTypeStr string
|
2015-01-28 18:04:27 -05:00
|
|
|
var address string
|
|
|
|
var certFile string
|
|
|
|
var keyFile string
|
|
|
|
var minioCommand = &cobra.Command{
|
|
|
|
Use: "minio",
|
|
|
|
Short: "minio is a minimal object storage system",
|
|
|
|
Long: "",
|
|
|
|
Run: func(cmd *cobra.Command, args []string) {
|
2015-01-28 19:07:53 -05:00
|
|
|
storageType := getStorageType(storageTypeStr)
|
|
|
|
serverConfig := server.ServerConfig{
|
|
|
|
Address: address,
|
|
|
|
Tls: tls,
|
|
|
|
CertFile: certFile,
|
|
|
|
KeyFile: keyFile,
|
|
|
|
StorageType: storageType,
|
|
|
|
}
|
|
|
|
server.Start(serverConfig)
|
2015-01-27 20:47:11 -05:00
|
|
|
},
|
2015-01-25 20:15:18 -05:00
|
|
|
}
|
2015-01-28 18:04:27 -05:00
|
|
|
minioCommand.PersistentFlags().BoolVarP(&tls, "tls", "t", false, "enable tls")
|
2015-01-28 19:07:53 -05:00
|
|
|
minioCommand.PersistentFlags().StringVarP(&storageTypeStr, "storage-type", "s", "file", "file,inmemory")
|
2015-01-28 18:04:27 -05:00
|
|
|
minioCommand.PersistentFlags().StringVarP(&address, "http-address", "a", ":8080", "http address")
|
|
|
|
minioCommand.PersistentFlags().StringVarP(&certFile, "cert", "c", "", "cert file path")
|
|
|
|
minioCommand.PersistentFlags().StringVarP(&keyFile, "key", "k", "", "key file path")
|
|
|
|
minioCommand.Execute()
|
2015-01-14 14:29:04 -05:00
|
|
|
}
|
2015-01-28 19:07:53 -05:00
|
|
|
|
|
|
|
func getStorageType(input string) server.StorageType {
|
|
|
|
switch {
|
|
|
|
case input == "file":
|
|
|
|
return server.InMemoryStorage
|
|
|
|
case input == "inmemory":
|
|
|
|
return server.InMemoryStorage
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
log.Fatal("Unknown server type:", input)
|
|
|
|
// needed for compile, should never return after fatal log msg
|
|
|
|
return server.InMemoryStorage
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|