forked from solo-io/unik
-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.go
164 lines (138 loc) · 4.24 KB
/
types.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
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
package types
import (
"fmt"
"time"
)
type InstanceState string
const (
InstanceState_Running InstanceState = "running"
InstanceState_Stopped InstanceState = "stopped"
InstanceState_Pending InstanceState = "pending"
InstanceState_Unknown InstanceState = "unknown"
InstanceState_Terminated InstanceState = "terminated"
)
type Infrastructure string
const (
Infrastructure_AWS Infrastructure = "AWS"
Infrastructure_VSPHERE Infrastructure = "VSPHERE"
Infrastructure_VIRTUALBOX Infrastructure = "VIRTUALBOX"
Infrastructure_QEMU Infrastructure = "QEMU"
)
type Image struct {
Id string `json:"Id"`
Name string `json:"Name"`
SizeMb int64 `json:"SizeMb"`
Infrastructure Infrastructure `json:"Infrastructure"`
Created time.Time `json:"Created"`
StageSpec StageSpec `json:"StageSpec"`
RunSpec RunSpec `json:"RunSpec"`
}
func (image *Image) Copy() *Image {
return &Image{
Id: image.Id,
Name: image.Name,
SizeMb: image.SizeMb,
Infrastructure: image.Infrastructure,
Created: image.Created,
StageSpec: image.StageSpec,
RunSpec: image.RunSpec,
}
}
func (image *Image) String() string {
if image == nil {
return "<nil>"
}
return fmt.Sprintf("%-v", *image)
}
type Instance struct {
Id string `json:"Id"`
Name string `json:"Name"`
State InstanceState `json:"State"`
IpAddress string `json:"IpAddress"`
ImageId string `json:"ImageId"`
Infrastructure Infrastructure `json:"Infrastructure"`
Created time.Time `json:"Created"`
}
func (instance *Instance) Copy() *Instance {
return &Instance{
Id: instance.Id,
ImageId: instance.ImageId,
Infrastructure: instance.Infrastructure,
Name: instance.Name,
State: instance.State,
Created: instance.Created,
}
}
func (instance *Instance) String() string {
if instance == nil {
return "<nil>"
}
return fmt.Sprintf("%+v", *instance)
}
type Volume struct {
Id string `json:"Id"`
Name string `json:"Name"`
SizeMb int64 `json:"SizeMb"`
Attachment string `json:"Attachment"` //instanceId
Infrastructure Infrastructure `json:"Infrastructure"`
Created time.Time `json:"Created"`
}
func (volume *Volume) Copy() *Volume {
return &Volume{
Id: volume.Id,
Name: volume.Name,
SizeMb: volume.SizeMb,
Attachment: volume.Attachment,
Infrastructure: volume.Infrastructure,
Created: volume.Created,
}
}
func (volume *Volume) String() string {
if volume == nil {
return "<nil>"
}
return fmt.Sprintf("%+v", *volume)
}
type RawImage struct {
LocalImagePath string `json:"LocalImagePath"`
StageSpec StageSpec `json:"StageSpec"`
RunSpec RunSpec `json:"RunSpec"`
}
type ImageFormat string
const (
ImageFormat_RAW ImageFormat = "raw"
ImageFormat_QCOW2 ImageFormat = "qcow2"
ImageFormat_VHD ImageFormat = "vhd"
ImageFormat_VMDK ImageFormat = "vmdk"
)
type XenVirtualizationType string
const (
XenVirtualizationType_HVM = "hvm"
XenVirtualizationType_Paravirtual = "paravirtual"
)
type StageSpec struct {
ImageFormat ImageFormat `json:"ImageFormat"` //required for all compilers
XenVirtualizationType XenVirtualizationType `json:"XenVirtualizationType,omitempty"`
}
type StorageDriver string
const (
StorageDriver_SCSI = "SCSI"
StorageDriver_SATA = "SATA"
StorageDriver_IDE = "IDE"
)
type VsphereNetworkType string
const (
VsphereNetworkType_E1000 = "e1000"
VsphereNetworkType_VMXNET3 = "vmxnet3"
)
type RunSpec struct {
DeviceMappings []DeviceMapping `json:"DeviceMappings"` //required for all compilers
DefaultInstanceMemory int `json:"DefaultInstanceMemory"` //required for all compilers
StorageDriver StorageDriver `json:"StorageDriver,omitempty"`
VsphereNetworkType VsphereNetworkType `json:"VsphereNetworkType"`
Compiler string `json:"Compiler,omitempty"`
}
type DeviceMapping struct {
MountPoint string `json:"MountPoint"`
DeviceName string `json:"DeviceName"`
}