/
kms_custom_key_stores.go
71 lines (63 loc) · 1.47 KB
/
kms_custom_key_stores.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
63
64
65
66
67
68
69
70
71
package main
import (
"fmt"
kmsTypes "github.com/aws/aws-sdk-go-v2/service/kms/types"
"github.com/bporter816/aws-tui/repo"
"github.com/bporter816/aws-tui/ui"
"github.com/bporter816/aws-tui/utils"
"github.com/bporter816/aws-tui/view"
)
type KmsCustomKeyStores struct {
*ui.Table
view.KMS
repo *repo.KMS
app *Application
}
func NewKmsCustomKeyStores(repo *repo.KMS, app *Application) *KmsCustomKeyStores {
k := &KmsCustomKeyStores{
Table: ui.NewTable([]string{
"NAME",
"TYPE",
"CONNECTION STATUS",
"CREATED",
}, 1, 0),
repo: repo,
app: app,
}
return k
}
func (k KmsCustomKeyStores) GetLabels() []string {
return []string{"Custom Key Stores"}
}
func (k KmsCustomKeyStores) GetKeyActions() []KeyAction {
return []KeyAction{}
}
func (k KmsCustomKeyStores) Render() {
model, err := k.repo.ListCustomKeyStores()
if err != nil {
panic(err)
}
var data [][]string
for _, v := range model {
var name, keyStoreType, connection, created string
if v.CustomKeyStoreName != nil {
name = *v.CustomKeyStoreName
}
keyStoreType = string(v.CustomKeyStoreType)
if v.ConnectionState == kmsTypes.ConnectionStateTypeFailed {
connection = fmt.Sprintf("%v (%v)", v.ConnectionState, v.ConnectionErrorCode)
} else {
connection = string(v.ConnectionState)
}
if v.CreationDate != nil {
created = v.CreationDate.Format(utils.DefaultTimeFormat)
}
data = append(data, []string{
name,
keyStoreType,
connection,
created,
})
}
k.SetData(data)
}