-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
72 lines (59 loc) · 1.6 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
package main
import (
"fmt"
"log"
"os"
"github.com/DataManager-Go/DMM---DataManagerMount/dmfs"
"github.com/DataManager-Go/libdatamanager"
dmConfig "github.com/DataManager-Go/libdatamanager/config"
"gopkg.in/alecthomas/kingpin.v2"
)
const (
appName = "dmount"
version = "v0.0.1"
)
// ...
const (
// EnVarPrefix prefix for env vars
EnVarPrefix = "DMOUNT"
// EnVarPrefix prefix of all used env vars
EnVarLogLevel = "LOG_LEVEL"
EnVarConfigFile = "CONFIG"
)
// Return the variable using the server prefix
func getEnVar(name string) string {
return fmt.Sprintf("%s_%s", EnVarPrefix, name)
}
var (
app = kingpin.New(appName, "A DataManager")
appCfgFile = app.Flag("config", "the configuration file for the app").Envar(getEnVar(EnVarConfigFile)).Short('c').String()
appDebugFS = app.Flag("debug-fs", "Debug the filesystem").Bool()
appDebug = app.Flag("debug", "Debug the fs bridge").Bool()
appMountpoint = app.Arg("mountPoint", "The folder to mount your dm namespaces in").Required().String()
)
func main() {
app.HelpFlag.Short('h')
app.Version(version)
// Prase cli flags
kingpin.MustParse(app.Parse(os.Args[1:]))
// Init config
var err error
config, err := dmConfig.InitConfig(dmConfig.GetDefaultConfigFile(), *appCfgFile)
if err != nil {
log.Fatalln(err)
}
if config == nil {
fmt.Println("New config created")
return
}
// Create mount options
options := dmfs.Mounter{
Libdm: libdatamanager.NewLibDM(config.MustGetRequestConfig()),
MountPoint: *appMountpoint,
Config: config,
Debug: *appDebug,
DebugFS: *appDebugFS,
}
// Monut the fs
options.Mount()
}