forked from forj-oss/forjj
-
Notifications
You must be signed in to change notification settings - Fork 0
/
secrets.go
59 lines (46 loc) · 1.03 KB
/
secrets.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
package main
import (
"strings"
"github.com/alecthomas/kingpin"
)
type secrets struct {
secrets *kingpin.CmdClause
context secretsContext
common secretsCommon
list secretsList
get struct {
cmd *kingpin.CmdClause
key *string
}
set secretsSet
edit secretsEdit
unset secretsUnset
}
func (s *secrets) init(app *kingpin.Application) {
if s == nil || app == nil {
return
}
s.secrets = app.Command("secrets", "Manage forjj secrets")
s.context.init()
s.common.init(&s.context, s.secrets)
s.list.init(s.secrets, &s.common)
s.set.init(s.secrets, &s.common)
s.edit.init(s.secrets, &s.common)
s.get.cmd = s.secrets.Command("get", "Get value of a credential unencrypted")
s.get.key = s.get.cmd.Arg("key", "Full key path").Required().String()
s.unset.init(s.secrets, &s.common)
}
func (s *secrets) action(action string) {
actions := strings.Split(action, " ")
switch actions[1] {
case "list":
s.list.showList()
case "set":
s.set.doSet()
case "edit":
s.edit.doEdit()
case "unset":
s.unset.doUnset()
case "show":
}
}