-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
executable file
·65 lines (56 loc) · 1.32 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
package main
import (
"os"
"github.com/sirupsen/logrus"
"github.com/urfave/cli"
)
var revision string // build number set at compile-time
func main() {
app := cli.NewApp()
app.Name = "awscli plugin"
app.Usage = "awscli plugin"
app.Action = run
app.Version = revision
app.Flags = []cli.Flag{
//
// plugin args
//
cli.StringFlag{
Name: "assume_role",
Usage: "A role to assume before running the awscli commands",
EnvVar: "PLUGIN_ASSUME_ROLE",
},
cli.StringFlag{
Name: "awscli_version",
Usage: "AWSCli version number",
EnvVar: "PLUGIN_AWSCLI_VERSION",
},
cli.StringSliceFlag{
Name: "awscli_commands",
Usage: "AWSCli commands to be run",
EnvVar: "PLUGIN_COMMANDS",
},
cli.StringFlag{
Name: "shell",
Usage: "Run awscli in shell",
EnvVar: "PLUGIN_SHELL",
Value: "false",
},
}
if err := app.Run(os.Args); err != nil {
logrus.Fatal(err)
}
}
func run(c *cli.Context) error {
plugin := Plugin{
Config: Config{
RoleARN: c.String("assume_role"),
Shell: c.Bool("shell"),
},
AWSCli: AWSCli{
Version: c.String("awscli_version"),
Commands: c.StringSlice("awscli_commands"),
},
}
return plugin.Exec()
}