-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (45 loc) · 1.11 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
package utils
import (
"github.com/aquasecurity/trivy-java-db/pkg/types"
"github.com/daspawnw/trivy-java-db-server/pkg/serverpb"
)
func MapIndexToIndexElement(idx types.Index) *serverpb.IndexElement {
return &serverpb.IndexElement{
GroupID: idx.GroupID,
ArtifactID: idx.ArtifactID,
SHA1: idx.SHA1,
Version: idx.Version,
ArchiveType: ArchiveTypeToString(idx.ArchiveType),
}
}
func MapIndexElementToIndex(idx *serverpb.IndexElement) types.Index {
return types.Index{
GroupID: idx.GroupID,
ArtifactID: idx.ArtifactID,
SHA1: idx.SHA1,
Version: idx.Version,
ArchiveType: StringToArchiveType(idx.ArchiveType),
}
}
func StringToArchiveType(str string) types.ArchiveType {
switch str {
case types.JarType:
return types.JarType
case types.AarType:
return types.AarType
case types.IndexesDir:
return types.IndexesDir
}
return ""
}
func ArchiveTypeToString(archiveType types.ArchiveType) string {
switch archiveType {
case types.AarType:
return types.AarType
case types.JarType:
return types.JarType
case types.IndexesDir:
return types.IndexesDir
}
return ""
}