This repository has been archived by the owner on Jun 21, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
90 lines (83 loc) · 1.62 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package main
import (
"os"
"github.com/Sirupsen/logrus"
"github.com/urfave/cli"
)
var (
version = "unknown"
)
func main() {
app := cli.NewApp()
app.Name = "mercurial plugin"
app.Usage = "mercurial plugin"
app.Action = run
app.Version = version
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "remote",
Usage: "hg remote url",
EnvVar: "DRONE_REMOTE_URL",
},
cli.StringFlag{
Name: "path",
Usage: "hg clone path",
EnvVar: "DRONE_WORKSPACE",
},
cli.StringFlag{
Name: "sha",
Usage: "hg commit rev",
EnvVar: "DRONE_COMMIT_SHA",
},
cli.StringFlag{
Name: "event",
Value: "push",
Usage: "build event",
EnvVar: "DRONE_BUILD_EVENT",
},
cli.StringFlag{
Name: "netrc.machine",
Usage: "netrc machine",
EnvVar: "DRONE_NETRC_MACHINE",
},
cli.StringFlag{
Name: "netrc.username",
Usage: "netrc username",
EnvVar: "DRONE_NETRC_USERNAME",
},
cli.StringFlag{
Name: "netrc.password",
Usage: "netrc password",
EnvVar: "DRONE_NETRC_PASSWORD",
},
cli.StringFlag{
Name: "share.pool",
Usage: "pool storage",
EnvVar: "HG_SHARE_POOL",
},
}
if err := app.Run(os.Args); err != nil {
logrus.Fatal(err)
}
}
func run(c *cli.Context) error {
plugin := Plugin{
Repo: Repo{
Clone: c.String("remote"),
},
Build: Build{
Path: c.String("path"),
Event: c.String("event"),
Commit: c.String("sha"),
},
Netrc: Netrc{
Machine: c.String("netrc.machine"),
Login: c.String("netrc.username"),
Password: c.String("netrc.password"),
},
Share: Share{
Pool: c.String("share.pool"),
},
}
return plugin.Exec()
}