-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy pathmain.go
51 lines (44 loc) · 1.29 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
package main
import (
"fmt"
"os"
"github.com/codegangsta/cli"
"github.com/opencredo/terrahelp/terrahelp"
)
func main() {
app := cli.NewApp()
app.Name = "terrahelp"
app.Usage = "Provides additional functions helpful with terraform development"
app.Version = "0.7.6-dev"
app.Author = "https://github.com/opencredo OpenCredo - Nicki Watt"
app.Commands = []cli.Command{
vaultAutoConfigCommand(newTerraHelperFunc()),
encryptCommand(newTerraHelperFunc()),
decryptCommand(newTerraHelperFunc()),
maskCommand(),
}
app.Run(os.Args)
}
func newTerraHelperFunc() func(provider string) *terrahelp.CryptoHandler {
return func(provider string) *terrahelp.CryptoHandler {
switch {
case (provider == terrahelp.ThEncryptProviderSimple):
e := terrahelp.NewSimpleEncrypter()
return &terrahelp.CryptoHandler{Encrypter: e}
case (provider == terrahelp.ThEncryptProviderVault):
e, err := terrahelp.NewVaultEncrypter()
if err != nil {
exitIfError(err)
}
return &terrahelp.CryptoHandler{Encrypter: e}
case (provider == terrahelp.ThEncryptProviderVaultCli):
e, err := terrahelp.NewVaultCliEncrypter()
if err != nil {
exitIfError(err)
}
return &terrahelp.CryptoHandler{Encrypter: e}
}
exitIfError(fmt.Errorf("Invalid provider %s specified ", provider))
return nil
}
}