-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (47 loc) · 1.08 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
package main
import (
"context"
"fmt"
"log/slog"
"os"
gopassapi "github.com/gopasspw/gopass/pkg/gopass/api"
flag "github.com/spf13/pflag"
)
var (
excludes []string
includes []string
secretKey string
vault string
)
func main() {
flag.StringSliceVar(&excludes, "exclude", []string{}, "exclude secret directories")
flag.StringSliceVar(&includes, "include", []string{}, "include secret directories, ignore others")
flag.StringVar(&secretKey, "key", "", "secret key to fetch")
flag.StringVar(&vault, "vault", "Personal", "vault to use")
flag.Parse()
ctx := context.Background()
gp, err := gopassapi.New(ctx)
if err != nil {
slog.Error("failed to create gopass", err)
os.Exit(1)
}
defer gp.Close(ctx)
s, err := gp.List(ctx)
if err != nil {
slog.Error("failed to list secrets", err)
os.Exit(1)
}
view := false
if len(os.Args) > 1 && os.Args[1] == "view" {
view = true
}
fmt.Println(view)
if view {
compareSecrets(ctx, gp, s)
return
}
if err := convertSecrets(ctx, gp, s); err != nil {
slog.Error("failed to convert secrets", err)
os.Exit(1)
}
}