-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.go
42 lines (35 loc) · 1.07 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
package main
import (
"flag"
"fmt"
"os"
"github.com/chengtiesheng/ContainerAnalyzer/analyse"
)
var (
flagImage = flag.String("image", "", "When analysing a local file, it selects a particular image to analyse. Format: IMAGE_NAME[:TAG]")
flagDebug = flag.Bool("debug", false, "Enables debug messages")
flagInsecure = flag.Bool("insecure", false, "Uses unencrypted connections when fetching images")
)
func usage() {
fmt.Fprintf(os.Stderr, "Usage of %s:\n", os.Args[0])
fmt.Fprintf(os.Stderr, "analyzer [--debug] IMAGE\n")
fmt.Fprintf(os.Stderr, " Where IMAGE is\n")
fmt.Fprintf(os.Stderr, " [--image=IMAGE_NAME[:TAG]] FILEPATH\n")
fmt.Fprintf(os.Stderr, " or\n")
fmt.Fprintf(os.Stderr, " docker://[REGISTRYURL/]IMAGE_NAME[:TAG]\n")
fmt.Fprintf(os.Stderr, "Flags:\n")
flag.PrintDefaults()
}
func main() {
flag.Usage = usage
flag.Parse()
args := flag.Args()
if len(args) < 1 {
usage()
return
}
if err := analyse.AnalyseDockerImage(args[0], *flagImage, *flagDebug, *flagInsecure); err != nil {
fmt.Fprintf(os.Stderr, "Error: %v\n", err)
os.Exit(1)
}
}