-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfromdb.go
More file actions
42 lines (36 loc) · 733 Bytes
/
fromdb.go
File metadata and controls
42 lines (36 loc) · 733 Bytes
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 fromdb
import (
"strings"
"github.com/torfstack/kayvault/backend/models"
sqlc "github.com/torfstack/kayvault/sql/gen"
)
func Secret(in sqlc.Secret) models.Secret {
return models.Secret{
ID: in.ID,
Value: string(in.Value),
Key: in.Key,
Url: in.Url,
Tags: tagsSlice(in.Tags),
}
}
func Secrets(in []sqlc.Secret) []models.Secret {
out := make([]models.Secret, len(in))
for i, s := range in {
out[i] = Secret(s)
}
return out
}
func User(in sqlc.User) models.User {
return models.User{
ID: in.ID,
Subject: in.Subject,
Email: in.Email,
FullName: in.FullName,
}
}
func tagsSlice(tags string) []string {
if tags == "" {
return []string{}
}
return strings.Split(tags, ",")
}