This repository has been archived by the owner on Jul 11, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathdeployment_manifest_primatives.go
235 lines (203 loc) · 7.31 KB
/
deployment_manifest_primatives.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
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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
package enaml
type Deployment interface {
GetDeployment() DeploymentManifest
}
type CloudConfig interface {
GetManifest() CloudConfigManifest
}
type DeploymentManifest struct {
Name string `yaml:"name"`
DirectorUUID string `yaml:"director_uuid,omitempty"`
Releases []Release `yaml:"releases,omitempty"`
Stemcells []Stemcell `yaml:"stemcells,omitempty"`
InstanceGroups []*InstanceGroup `yaml:"instance_groups,omitempty"`
Networks []DeploymentNetwork `yaml:"networks,omitempty"`
ResourcePools []ResourcePool `yaml:"resource_pools,omitempty"`
DiskPools []DiskPool `yaml:"disk_pools,omitempty"`
Compilation *Compilation `yaml:"compilation,omitempty"`
Update Update `yaml:"update,omitempty"`
Jobs []Job `yaml:"jobs,omitempty"`
Properties Properties `yaml:"properties,omitempty"`
CloudProvider *CloudProvider `yaml:"cloud_provider,omitempty"`
Tags map[string]string `yaml:"tags,omitempty"`
}
type InstanceGroup struct {
Name string `yaml:"name"`
ResourcePool string `yaml:"resource_pool,omitempty"`
PersistentDisk int `yaml:"persistent_disk,omitempty"`
PersistentDiskType string `yaml:"persistent_disk_type,omitempty"`
Instances int `yaml:"instances"`
VMType string `yaml:"vm_type,omitempty"`
Stemcell string `yaml:"stemcell,omitempty"`
AZs []string `yaml:"azs,flow,omitempty"`
Networks []Network `yaml:"networks,flow"`
Jobs []InstanceJob `yaml:"jobs"`
Update Update `yaml:"update,omitempty"`
Lifecycle string `yaml:"lifecycle,omitempty"`
VMExtensions []string `yaml:"vm_extensions,omitempty"`
}
type InstanceJob struct {
Name string `yaml:"name"`
Release string `yaml:"release"`
Properties interface{} `yaml:"properties"`
}
type DeploymentNetwork interface {
}
type Release struct {
Name string `yaml:"name"`
Version string `yaml:"version,omitempty"`
URL string `yaml:"url,omitempty"`
SHA1 string `yaml:"sha1,omitempty"`
}
func NewVIPNetwork(name string) VIPNetwork {
return VIPNetwork{
Name: name,
Type: "vip",
}
}
type VIPNetwork struct {
Name string `yaml:"name"`
Type string `yaml:"type"`
CloudProperties CloudProperties `yaml:"cloud_properties,omitempty"`
}
type DynamicNetwork struct {
Name string `yaml:"name"`
Type string `yaml:"type"`
DNS []string `yaml:"dns"`
CloudProperties CloudProperties `yaml:"cloud_properties"`
}
func (s DynamicNetwork) GetName() (name string) {
return s.Name
}
func NewManualNetwork(name string) ManualNetwork {
return ManualNetwork{
Name: name,
Type: "manual",
}
}
type ManualNetwork struct {
Name string `yaml:"name"`
Type string `yaml:"type"`
Subnets []Subnet `yaml:"subnets"`
}
func (s *ManualNetwork) AddSubnet(subnet Subnet) (err error) {
s.Subnets = append(s.Subnets, subnet)
return
}
func NewSubnet(cidr, gateway, azName string) Subnet {
return Subnet{
Range: cidr,
Gateway: gateway,
AZ: azName,
}
}
type Subnet struct {
Range string `yaml:"range,omitempty"`
Gateway string `yaml:"gateway,omitempty"`
DNS []string `yaml:"dns,omitempty"`
Reserved []string `yaml:"reserved,omitempty"`
Static []string `yaml:"static,omitempty"`
AZ string `yaml:"az,omitempty"`
AZs []string `yaml:"azs,omitempty"`
CloudProperties CloudProperties `yaml:"cloud_properties"`
}
func (s *Subnet) AddDNS(dns string) (err error) {
s.DNS = append(s.DNS, dns)
return
}
func (s *Subnet) AddReserved(rsv string) (err error) {
s.Reserved = append(s.Reserved, rsv)
return
}
func (s *Subnet) AddStatic(stc string) (err error) {
s.Static = append(s.Static, stc)
return
}
type ResourcePool struct {
Name string `yaml:"name"`
Network string `yaml:"network"`
Size int `yaml:"size,omitempty"`
Stemcell Stemcell `yaml:"stemcell"`
CloudProperties CloudProperties `yaml:"cloud_properties"`
Env map[string]interface{} `yaml:"env,omitempty"`
}
func (s *ResourcePool) SetStemcell(sc Stemcell) (err error) {
s.Stemcell = sc
return
}
type Stemcell struct {
Alias string `yaml:"alias,omitempty"`
OS string `yaml:"os,omitempty"`
Name string `yaml:"name,omitempty"`
Version string `yaml:"version,omitempty"`
URL string `yaml:"url,omitempty"`
SHA1 string `yaml:"sha1,omitempty"`
}
type DiskType DiskPool
type DiskPool struct {
Name string `yaml:"name"`
DiskSize int `yaml:"disk_size"`
CloudProperties CloudProperties `yaml:"cloud_properties"`
}
type Compilation struct {
Workers int `yaml:"workers"`
Network string `yaml:"network"`
ReuseCompilationVMs bool `yaml:"reuse_compilation_vms"`
CloudProperties CloudProperties `yaml:"cloud_properties,omitempty"`
VMType string `yaml:"vm_type,omitempty"`
AZ string `yaml:"az,omitempty"`
}
type Update struct {
Canaries int `yaml:"canaries,omitempty"`
MaxInFlight int `yaml:"max_in_flight,omitempty"`
CanaryWatchTime string `yaml:"canary_watch_time,omitempty"`
UpdateWatchTime string `yaml:"update_watch_time,omitempty"`
Serial bool `yaml:"serial,omitempty"`
}
type Job struct {
Name string `yaml:"name"`
Templates []Template `yaml:"templates,flow"`
Lifecycle string `yaml:"lifeycle,omitempty"`
PersistentDisk string `yaml:"persistent_disk,omitempty"`
PersistentDiskPool string `yaml:"persistent_disk_pool,omitempty"`
Properties Properties `yaml:"properties,omitempty"`
ResourcePool string `yaml:"resource_pool"`
Update Update `yaml:"update,omitempty"`
Instances int `yaml:"instances"`
Networks []Network `yaml:"networks"`
}
func (s *Job) AddProperty(propName string, prop interface{}) {
s.Properties[propName] = prop
}
func (s *Job) AddTemplate(t Template) (err error) {
s.Templates = append(s.Templates, t)
return
}
func (s *Job) AddNetwork(n Network) (err error) {
s.Networks = append(s.Networks, n)
return
}
type Network struct {
Name string `yaml:"name"`
StaticIPs []string `yaml:"static_ips,omitempty"`
Default []interface{} `yaml:"default,omitempty"`
}
type Template struct {
Name string `yaml:"name"`
Release string `yaml:"release"`
}
type CloudProvider struct {
Template Template `yaml:"template,flow"`
MBus string `yaml:"mbus"`
Properties CloudProviderProperties `yaml:"properties"`
SSHTunnel SSHTunnel `yaml:"ssh_tunnel"`
}
type SSHTunnel struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
User string `yaml:"user"`
PrivateKeyPath string `yaml:"private_key"`
}
type CloudProviderProperties interface{}
type Properties map[string]interface{}
type CloudProperties interface{}