forked from AliyunContainerService/flexvolume
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
42 lines (36 loc) · 969 Bytes
/
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
package main
import (
"fmt"
driver "github.com/AliyunContainerService/flexvolume/provider/driver"
utils "github.com/AliyunContainerService/flexvolume/provider/utils"
"os"
"strings"
)
// Expect to support K8s and Swarm platform
// Under K8s, plugin will run in cli mode, process running and exit after the actions.
// Under swarm, plugin will be running always, and communicate with docker by socket.
func main() {
// get the environment of platform
platform := os.Getenv("ACS_PLATFORM")
if platform == "swarm" {
driver.RunningInSwarm()
} else {
driver.RunK8sAction()
}
}
// check running environment and print help
func init() {
if len(os.Args) == 1 {
utils.Usage()
os.Exit(0)
}
argsOne := strings.ToLower(os.Args[1])
if argsOne == "--version" || argsOne == "version" || argsOne == "-v" {
fmt.Printf(utils.PluginVersion())
os.Exit(0)
}
if argsOne == "--help" || argsOne == "help" || argsOne == "-h" {
utils.Usage()
os.Exit(0)
}
}