forked from josmo/drone-elastic-beanstalk
-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
109 lines (103 loc) · 2.61 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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
package main
import (
log "github.com/Sirupsen/logrus"
"github.com/urfave/cli"
"os"
)
var version string
func main() {
app := cli.NewApp()
app.Name = "Beanstalk deployment plugin"
app.Usage = "beanstalk deployment plugin"
app.Action = run
app.Version = version
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "access-key",
Usage: "aws access key",
EnvVar: "PLUGIN_ACCESS_KEY,AWS_ACCESS_KEY_ID",
},
cli.StringFlag{
Name: "secret-key",
Usage: "aws secret key",
EnvVar: "PLUGIN_SECRET_KEY,AWS_SECRET_ACCESS_KEY",
},
cli.StringFlag{
Name: "bucket",
Usage: "aws bucket",
EnvVar: "PLUGIN_BUCKET",
},
cli.StringFlag{
Name: "region",
Usage: "aws region",
Value: "us-east-1",
EnvVar: "PLUGIN_REGION",
},
cli.StringFlag{
Name: "bucket-key",
Usage: "upload files from source folder",
EnvVar: "PLUGIN_BUCKET_KEY",
},
cli.StringFlag{
Name: "application",
Usage: "application name for beanstalk",
EnvVar: "PLUGIN_APPLICATION",
},
cli.StringFlag{
Name: "environment-name",
Usage: "environment name in the app to update",
EnvVar: "PLUGIN_ENVIRONMENT_NAME",
},
cli.StringFlag{
Name: "version-label",
Usage: "version label for the app",
EnvVar: "PLUGIN_VERSION_LABEL",
},
cli.StringFlag{
Name: "description",
Usage: "description for the app version",
EnvVar: "PLUGIN_DESCRIPTION",
},
cli.StringFlag{
Name: "auto-create",
Usage: "auto create app if it doesn't exist",
EnvVar: "PLUGIN_AUTO_CREATE",
},
cli.StringFlag{
Name: "process",
Usage: "Preprocess and validate manifest",
EnvVar: "PLUGIN_PROCESS",
},
cli.StringFlag{
Name: "environment-update",
Usage: "update the environment",
EnvVar: "PLUGIN_ENVIRONMENT_UPDATE",
},
cli.BoolTFlag{
Name: "yaml-verified",
Usage: "Ensure the yaml was signed",
EnvVar: "DRONE_YAML_VERIFIED",
},
}
if err := app.Run(os.Args); err != nil {
log.Fatal(err)
}
}
func run(c *cli.Context) error {
plugin := Plugin{
Key: c.String("access-key"),
Secret: c.String("secret-key"),
Bucket: c.String("bucket"),
BucketKey: c.String("bucket-key"),
Application: c.String("application"),
EnvironmentName: c.String("environment-name"),
VersionLabel: c.String("version-label"),
Description: c.String("description"),
AutoCreate: c.Bool("auto-create"),
Process: c.Bool("process"),
EnvironmentUpdate: c.Bool("environment-update"),
Region: c.String("region"),
YamlVerified: c.BoolT("yaml-verified"),
}
return plugin.Exec()
}