-
Notifications
You must be signed in to change notification settings - Fork 0
/
registry.go
67 lines (55 loc) · 1.38 KB
/
registry.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
// Package k6registry contains the data model of the k6 extensions registry.
package k6registry
import (
_ "embed"
)
// Schema contains JSON schema for Grafana k6 Extension Registry JSON.
//
//go:embed docs/registry.schema.json
var Schema []byte
//nolint:gochecknoglobals
var (
// Categories contains possible values for Category
Categories = []Category{
CategoryAuthentication,
CategoryBrowser,
CategoryData,
CategoryKubernetes,
CategoryMessaging,
CategoryMisc,
CategoryObservability,
CategoryProtocol,
CategoryReporting,
}
// Products contains possible values for Product
Products = []Product{ProductCloud, ProductOSS, ProductSynthetic}
// Grades contains possible values for Grade
Grades = []Grade{GradeA, GradeB, GradeC, GradeD, GradeE, GradeF}
// Tiers contains possible values for Tier
Tiers = []Tier{TierOfficial, TierPartner, TierCommunity}
)
// Level returns level of support (less is better).
func (t Tier) Level() int {
switch t {
case TierOfficial:
return 1
case TierPartner:
return 2
case TierCommunity:
return 3
}
return 0
}
// RegistryToCatalog converts Registry to Catalog.
func RegistryToCatalog(reg Registry) Catalog {
catalog := make(Catalog, len(reg))
for _, ext := range reg {
for _, importPath := range ext.Imports {
catalog[importPath] = ext
}
for _, output := range ext.Outputs {
catalog[output] = ext
}
}
return catalog
}