/
main.go
72 lines (61 loc) · 1.38 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
package main
import (
"os"
"github.com/mikesimons/envelope/keysvc"
"github.com/ansel1/merry"
"github.com/mikesimons/envelope/keysvc/awskms"
"gopkg.in/urfave/cli.v1"
)
var COLLECT_DEBUG = true
var envelope_version_string = "dev"
func main() {
app := cli.NewApp()
app.Name = "envelope"
app.Usage = "Envelope secrets encryption"
app.Version = envelope_version_string
app.Flags = []cli.Flag{
cli.StringFlag{
Name: "keyring",
Value: "keyring.yaml",
Usage: "Keyring file / url",
EnvVar: "ENVELOPE_KEYRING",
},
cli.StringFlag{
Name: "aws-region",
Usage: "AWS region",
},
cli.StringFlag{
Name: "aws-role",
Usage: "AWS role ARN",
},
cli.StringFlag{
Name: "aws-profile",
Usage: "AWS profile name",
},
cli.BoolFlag{
Name: "debug",
Usage: "Enable debug",
},
}
app.Commands = []cli.Command{
cli.Command{
Name: "profile",
Usage: "Profile related commands",
Subcommands: []cli.Command{
profileAddCommand(),
},
},
encryptCommand(),
decryptCommand(),
}
app.Before = func(c *cli.Context) error {
COLLECT_DEBUG = c.Bool("debug")
merry.SetStackCaptureEnabled(c.Bool("debug"))
sess := awsSession(c.String("aws-profile"), c.String("aws-region"), c.String("aws-role"))
keysvc.AddKeyServiceFn("awskms", func() (keysvc.KeyServiceProvider, error) {
return awskms.New(sess)
})
return nil
}
app.Run(os.Args)
}