-
Notifications
You must be signed in to change notification settings - Fork 3
/
harbour.go
65 lines (51 loc) · 1019 Bytes
/
harbour.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
// harbour project main.go
package main
import (
"fmt"
"os"
"os/exec"
"github.com/huawei-openlab/harbour/mflag"
"github.com/huawei-openlab/harbour/opts"
"github.com/Sirupsen/logrus"
)
func main() {
mflag.Parse()
if *flVersion {
showVersion()
return
}
if *flHelp {
mflag.Usage()
return
}
if *flDebug {
logrus.SetLevel(logrus.DebugLevel)
}
if len(*flRuntime) != 0 {
if *flRuntime != opts.DEFAULTRUNTIME && *flRuntime != opts.RKTRUNTIME {
fmt.Println("Invalid container runtime")
return
}
}
if len(flHosts) == 0 {
defaultHost := fmt.Sprintf("unix://%s", opts.DEFAULTUNIXSOCKET)
flHosts = append(flHosts, defaultHost)
}
_, ok := exec.LookPath("docker")
if ok != nil {
logrus.Fatal("Can't find docker")
}
if *flDaemon {
mainDaemon()
return
}
if len(flHosts) > 1 {
fmt.Fprintf(os.Stderr, "Please specify only one -H")
os.Exit(0)
}
// If no flag specified, print help info.
mflag.Usage()
}
func showVersion() {
fmt.Printf("harbour version 0.0.1\n")
}