-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.go
51 lines (45 loc) · 1.01 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
package main
import (
"fmt"
"os"
"github.com/praveenkumar/gopodman/cmd"
"github.com/praveenkumar/gopodman/ioprojectatomicpodman"
"github.com/urfave/cli"
)
func main() {
app := cli.NewApp()
app.Name = "gopodman"
app.Usage = "podman go client"
app.Version = "0.0.1"
app.Commands = []cli.Command{
cmd.PingCommand,
cmd.PodmanVersionCommand,
cmd.ListImagesCommand,
cmd.PsCommand,
cmd.InspectCommand,
}
app.Before = func(c *cli.Context) error {
var err error
uri := c.GlobalString("podman-varlink-uri")
if uri == "" {
uri = os.Getenv("PODMAN_VARLINK_URI")
}
if uri == "" {
return fmt.Errorf("Required podman varlink URL")
}
ioprojectatomicpodman.PodmanConnection, err = ioprojectatomicpodman.NewPodmanConnection(uri)
if err != nil {
return err
}
return nil
}
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "podman-varlink-uri",
Usage: "Podman varlink URI (ex: tcp:127.0.0.1:12345)",
},
}
if err := app.Run(os.Args); err != nil {
fmt.Fprintln(os.Stderr, err.Error())
}
}