-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathmain.go
42 lines (35 loc) · 837 Bytes
/
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
package main
import (
"fmt"
"github.com/s12v/exec-with-secrets/provider"
_ "github.com/s12v/exec-with-secrets/provider/awskms"
_ "github.com/s12v/exec-with-secrets/provider/awssecretsmanager"
_ "github.com/s12v/exec-with-secrets/provider/awsssm"
_ "github.com/s12v/exec-with-secrets/provider/azurekeyvault"
"os"
"os/exec"
"syscall"
)
func main() {
defer func() {
if r := recover(); r != nil {
fmt.Println("exec-with-secrets:", r)
os.Exit(1)
}
}()
if len(os.Args) < 2 {
fmt.Println("Usage: exec-with-secrets program [args]")
os.Exit(0)
}
path := lookPath(os.Args[1])
env := provider.Populate(os.Environ())
_ = syscall.Exec(path, os.Args[1:], env)
panic("Unable to start " + path)
}
func lookPath(name string) string {
path, err := exec.LookPath(name)
if err != nil {
panic(err)
}
return path
}