-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathtypes.go
More file actions
220 lines (189 loc) · 4.98 KB
/
types.go
File metadata and controls
220 lines (189 loc) · 4.98 KB
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
package models
import (
"database/sql/driver"
"fmt"
)
// ComponentType represents component type enum
type ComponentType string
const (
ComponentTypePentagi ComponentType = "pentagi"
ComponentTypeScraper ComponentType = "scraper"
ComponentTypeLangfuseWorker ComponentType = "langfuse-worker"
ComponentTypeLangfuseWeb ComponentType = "langfuse-web"
ComponentTypeGrafana ComponentType = "grafana"
ComponentTypeOtelcol ComponentType = "otelcol"
ComponentTypeWorker ComponentType = "worker"
ComponentTypeInstaller ComponentType = "installer"
ComponentTypeEngine ComponentType = "engine"
)
func (ct ComponentType) String() string {
return string(ct)
}
func (ct *ComponentType) Scan(value any) error {
if value == nil {
*ct = ""
return nil
}
if bv, err := driver.String.ConvertValue(value); err == nil {
if v, ok := bv.(string); ok {
*ct = ComponentType(v)
return nil
}
}
return fmt.Errorf("cannot scan %T into ComponentType", value)
}
func (ct ComponentType) Value() (driver.Value, error) {
return string(ct), nil
}
func (ct ComponentType) Valid() error {
switch ct {
case ComponentTypePentagi, ComponentTypeScraper,
ComponentTypeLangfuseWorker, ComponentTypeLangfuseWeb,
ComponentTypeGrafana, ComponentTypeOtelcol,
ComponentTypeWorker, ComponentTypeInstaller, ComponentTypeEngine:
return nil
default:
return fmt.Errorf("invalid ComponentType: %s", ct)
}
}
// ComponentStatus represents component status enum
type ComponentStatus string
const (
ComponentStatusUnused ComponentStatus = "unused"
ComponentStatusConnected ComponentStatus = "connected"
ComponentStatusInstalled ComponentStatus = "installed"
ComponentStatusRunning ComponentStatus = "running"
)
func (cs ComponentStatus) String() string {
return string(cs)
}
func (cs *ComponentStatus) Scan(value any) error {
if value == nil {
*cs = ""
return nil
}
if bv, err := driver.String.ConvertValue(value); err == nil {
if v, ok := bv.(string); ok {
*cs = ComponentStatus(v)
return nil
}
}
return fmt.Errorf("cannot scan %T into ComponentStatus", value)
}
func (cs ComponentStatus) Value() (driver.Value, error) {
return string(cs), nil
}
func (cs ComponentStatus) Valid() error {
switch cs {
case ComponentStatusUnused, ComponentStatusConnected,
ComponentStatusInstalled, ComponentStatusRunning:
return nil
default:
return fmt.Errorf("invalid ComponentStatus: %s", cs)
}
}
// ProductStack represents product stack enum
type ProductStack string
const (
ProductStackPentagi ProductStack = "pentagi"
ProductStackLangfuse ProductStack = "langfuse"
ProductStackObservability ProductStack = "observability"
ProductStackWorker ProductStack = "worker"
ProductStackInstaller ProductStack = "installer"
ProductStackEngine ProductStack = "engine"
)
func (ps ProductStack) String() string {
return string(ps)
}
func (ps *ProductStack) Scan(value any) error {
if value == nil {
*ps = ""
return nil
}
if bv, err := driver.String.ConvertValue(value); err == nil {
if v, ok := bv.(string); ok {
*ps = ProductStack(v)
return nil
}
}
return fmt.Errorf("cannot scan %T into ProductStack", value)
}
func (ps ProductStack) Value() (driver.Value, error) {
return string(ps), nil
}
func (ps ProductStack) Valid() error {
switch ps {
case ProductStackPentagi, ProductStackLangfuse, ProductStackObservability,
ProductStackWorker, ProductStackInstaller, ProductStackEngine:
return nil
default:
return fmt.Errorf("invalid ProductStack: %s", ps)
}
}
// OSType represents operating system enum
type OSType string
const (
OSTypeWindows OSType = "windows"
OSTypeLinux OSType = "linux"
OSTypeDarwin OSType = "darwin"
)
func (os OSType) String() string {
return string(os)
}
func (os *OSType) Scan(value any) error {
if value == nil {
*os = ""
return nil
}
if bv, err := driver.String.ConvertValue(value); err == nil {
if v, ok := bv.(string); ok {
*os = OSType(v)
return nil
}
}
return fmt.Errorf("cannot scan %T into OSType", value)
}
func (os OSType) Value() (driver.Value, error) {
return string(os), nil
}
func (os OSType) Valid() error {
switch os {
case OSTypeWindows, OSTypeLinux, OSTypeDarwin:
return nil
default:
return fmt.Errorf("invalid OSType: %s", os)
}
}
// ArchType represents CPU architecture enum
type ArchType string
const (
ArchTypeAMD64 ArchType = "amd64"
ArchTypeARM64 ArchType = "arm64"
)
func (arch ArchType) String() string {
return string(arch)
}
func (arch *ArchType) Scan(value any) error {
if value == nil {
*arch = ""
return nil
}
if bv, err := driver.String.ConvertValue(value); err == nil {
if v, ok := bv.(string); ok {
*arch = ArchType(v)
return nil
}
}
return fmt.Errorf("cannot scan %T into ArchType", value)
}
func (arch ArchType) Value() (driver.Value, error) {
return string(arch), nil
}
func (arch ArchType) Valid() error {
switch arch {
case ArchTypeAMD64, ArchTypeARM64:
return nil
default:
return fmt.Errorf("invalid ArchType: %s", arch)
}
}