-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
62 lines (52 loc) · 1.13 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
package main
import (
"log"
"os"
"github.com/juntaki/kms-vault/kms"
"github.com/urfave/cli"
)
const VaultVersion = "0.1.0"
type Crypter interface {
Encrypt(plainText []byte) ([]byte, error)
Decrypt(cipherText []byte) ([]byte, error)
}
var kmsClient Crypter
func initializeKMS(c *cli.Context) (err error) {
kmsClient, err = kms.NewKMSClient(c)
if err != nil {
return err
}
return nil
}
func main() {
log.SetFlags(log.Lshortfile | log.Lmicroseconds)
config := loadConfig()
kmsFlags := kms.Flags(
config.Key,
config.KeyRing,
config.Location,
config.Project,
)
app := cli.NewApp()
app.Name = "kms-vault"
app.Usage = "Manage configuration file that partially contain confidential information in a repository using Cloud KMS."
app.Version = VaultVersion
app.Authors = []cli.Author{
{
Name: "Jumpei Takiyasu",
Email: "[email protected]",
},
}
app.Copyright = "(c) 2020 Jumpei Takiyasu"
app.Commands = []cli.Command{
encryptCommand(kmsFlags),
decryptCommand(kmsFlags),
viewCommand(kmsFlags),
configCommand(kmsFlags),
fillCommand(kmsFlags),
}
err := app.Run(os.Args)
if err != nil {
log.Fatal(err)
}
}