-
Notifications
You must be signed in to change notification settings - Fork 42
/
instance.go
48 lines (40 loc) · 1.14 KB
/
instance.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
package engine
import (
"fmt"
"github.com/direktiv/direktiv/pkg/refactor/instancestore"
)
type Instance struct {
Instance *instancestore.InstanceData
TelemetryInfo *InstanceTelemetryInfo
RuntimeInfo *InstanceRuntimeInfo
Settings *InstanceSettings
DescentInfo *InstanceDescentInfo
}
func ParseInstanceData(idata *instancestore.InstanceData) (*Instance, error) {
ti, err := LoadInstanceTelemetryInfo(idata.TelemetryInfo)
if err != nil {
return nil, fmt.Errorf("failed to parse telemetry info: %w", err)
}
var ri *InstanceRuntimeInfo
if len(idata.RuntimeInfo) > 0 {
ri, err = LoadInstanceRuntimeInfo(idata.RuntimeInfo)
if err != nil {
return nil, fmt.Errorf("failed to parse runtime info: %w", err)
}
}
settings, err := LoadInstanceSettings(idata.Settings)
if err != nil {
return nil, fmt.Errorf("failed to parse settings info: %w", err)
}
di, err := LoadInstanceDescentInfo(idata.DescentInfo)
if err != nil {
return nil, fmt.Errorf("failed to parse descent info: %w", err)
}
return &Instance{
Instance: idata,
TelemetryInfo: ti,
RuntimeInfo: ri,
DescentInfo: di,
Settings: settings,
}, nil
}