-
Notifications
You must be signed in to change notification settings - Fork 8
/
application.vdl.go
500 lines (470 loc) · 12.4 KB
/
application.vdl.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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file was auto-generated by the vanadium vdl tool.
// Package: application
// Package application defines types for describing applications.
package application
import (
"time"
"v.io/v23/security"
"v.io/v23/vdl"
vdltime "v.io/v23/vdlroot/time"
)
var _ = __VDLInit() // Must be first; see __VDLInit comments for details.
//////////////////////////////////////////////////
// Type definitions
// SignedFile represents a file accompanied by a signature of its contents.
type SignedFile struct {
// File is the object name of the file.
File string
// Signature represents a signature on the sha256 hash of the file
// contents by the publisher principal.
Signature security.Signature
}
func (SignedFile) VDLReflect(struct {
Name string `vdl:"v.io/v23/services/application.SignedFile"`
}) {
}
func (x SignedFile) VDLIsZero() bool {
if x.File != "" {
return false
}
if !x.Signature.VDLIsZero() {
return false
}
return true
}
func (x SignedFile) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_1); err != nil {
return err
}
if x.File != "" {
if err := enc.NextFieldValueString(0, vdl.StringType, x.File); err != nil {
return err
}
}
if !x.Signature.VDLIsZero() {
if err := enc.NextField(1); err != nil {
return err
}
if err := x.Signature.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(-1); err != nil {
return err
}
return enc.FinishValue()
}
func (x *SignedFile) VDLRead(dec vdl.Decoder) error {
*x = SignedFile{}
if err := dec.StartValue(__VDLType_struct_1); err != nil {
return err
}
decType := dec.Type()
for {
index, err := dec.NextField()
switch {
case err != nil:
return err
case index == -1:
return dec.FinishValue()
}
if decType != __VDLType_struct_1 {
index = __VDLType_struct_1.FieldIndexByName(decType.Field(index).Name)
if index == -1 {
if err := dec.SkipValue(); err != nil {
return err
}
continue
}
}
switch index {
case 0:
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
x.File = value
}
case 1:
if err := x.Signature.VDLRead(dec); err != nil {
return err
}
}
}
}
// Packages represents a set of packages. The map key is the local
// file/directory name, relative to the instance's packages directory, where the
// package should be installed. For archives, this name represents a directory
// into which the archive is to be extracted, and for regular files it
// represents the name for the file. The map value is the package
// specification.
//
// Each object's media type determines how to install it.
//
// For example, with key=pkg1,value=SignedFile{File:binaryrepo/configfiles} (an
// archive), the "configfiles" package will be installed under the "pkg1"
// directory. With key=pkg2,value=SignedFile{File:binaryrepo/binfile} (a
// binary), the "binfile" file will be installed as the "pkg2" file.
//
// The keys must be valid file/directory names, without path separators.
//
// Any number of packages may be specified.
type Packages map[string]SignedFile
func (Packages) VDLReflect(struct {
Name string `vdl:"v.io/v23/services/application.Packages"`
}) {
}
func (x Packages) VDLIsZero() bool {
return len(x) == 0
}
func (x Packages) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_map_3); err != nil {
return err
}
if err := enc.SetLenHint(len(x)); err != nil {
return err
}
for key, elem := range x {
if err := enc.NextEntryValueString(vdl.StringType, key); err != nil {
return err
}
if err := elem.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextEntry(true); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Packages) VDLRead(dec vdl.Decoder) error {
if err := dec.StartValue(__VDLType_map_3); err != nil {
return err
}
var tmpMap Packages
if len := dec.LenHint(); len > 0 {
tmpMap = make(Packages, len)
}
for {
switch done, key, err := dec.NextEntryValueString(); {
case err != nil:
return err
case done:
*x = tmpMap
return dec.FinishValue()
default:
var elem SignedFile
if err := elem.VDLRead(dec); err != nil {
return err
}
if tmpMap == nil {
tmpMap = make(Packages)
}
tmpMap[key] = elem
}
}
}
// Envelope is a collection of metadata that describes an application.
type Envelope struct {
// Title is the publisher-assigned application title. Application
// installations with the same title are considered as belonging to the
// same application by the application management system.
//
// A change in the title signals a new application.
Title string
// Args is an array of command-line arguments to be used when executing
// the binary.
Args []string
// Binary identifies the application binary.
Binary SignedFile
// Publisher represents the set of blessings that have been bound to
// the principal who published this binary.
Publisher security.Blessings
// Env is an array that stores the environment variable values to be
// used when executing the binary.
Env []string
// Packages is the set of packages to install on the local filesystem
// before executing the binary
Packages Packages
// Restarts specifies how many times the device manager will attempt
// to automatically restart an application that has crashed before
// giving up and marking the application as NotRunning.
Restarts int32
// RestartTimeWindow is the time window within which an
// application exit is considered a crash that counts against the
// Restarts budget. If the application crashes after less than
// RestartTimeWindow time for Restarts consecutive times, the
// application is marked NotRunning and no more restart attempts
// are made. If the application has run continuously for more
// than RestartTimeWindow, subsequent crashes will again benefit
// from up to Restarts restarts (that is, the Restarts budget is
// reset by a successful run of at least RestartTimeWindow
// duration).
RestartTimeWindow time.Duration
}
func (Envelope) VDLReflect(struct {
Name string `vdl:"v.io/v23/services/application.Envelope"`
}) {
}
func (x Envelope) VDLIsZero() bool {
if x.Title != "" {
return false
}
if len(x.Args) != 0 {
return false
}
if !x.Binary.VDLIsZero() {
return false
}
if !x.Publisher.IsZero() {
return false
}
if len(x.Env) != 0 {
return false
}
if len(x.Packages) != 0 {
return false
}
if x.Restarts != 0 {
return false
}
if x.RestartTimeWindow != 0 {
return false
}
return true
}
func (x Envelope) VDLWrite(enc vdl.Encoder) error {
if err := enc.StartValue(__VDLType_struct_4); err != nil {
return err
}
if x.Title != "" {
if err := enc.NextFieldValueString(0, vdl.StringType, x.Title); err != nil {
return err
}
}
if len(x.Args) != 0 {
if err := enc.NextField(1); err != nil {
return err
}
if err := __VDLWriteAnon_list_1(enc, x.Args); err != nil {
return err
}
}
if !x.Binary.VDLIsZero() {
if err := enc.NextField(2); err != nil {
return err
}
if err := x.Binary.VDLWrite(enc); err != nil {
return err
}
}
if !x.Publisher.IsZero() {
if err := enc.NextField(3); err != nil {
return err
}
var wire security.WireBlessings
if err := security.WireBlessingsFromNative(&wire, x.Publisher); err != nil {
return err
}
if err := wire.VDLWrite(enc); err != nil {
return err
}
}
if len(x.Env) != 0 {
if err := enc.NextField(4); err != nil {
return err
}
if err := __VDLWriteAnon_list_1(enc, x.Env); err != nil {
return err
}
}
if len(x.Packages) != 0 {
if err := enc.NextField(5); err != nil {
return err
}
if err := x.Packages.VDLWrite(enc); err != nil {
return err
}
}
if x.Restarts != 0 {
if err := enc.NextFieldValueInt(6, vdl.Int32Type, int64(x.Restarts)); err != nil {
return err
}
}
if x.RestartTimeWindow != 0 {
if err := enc.NextField(7); err != nil {
return err
}
var wire vdltime.Duration
if err := vdltime.DurationFromNative(&wire, x.RestartTimeWindow); err != nil {
return err
}
if err := wire.VDLWrite(enc); err != nil {
return err
}
}
if err := enc.NextField(-1); err != nil {
return err
}
return enc.FinishValue()
}
func __VDLWriteAnon_list_1(enc vdl.Encoder, x []string) error {
if err := enc.StartValue(__VDLType_list_5); err != nil {
return err
}
if err := enc.SetLenHint(len(x)); err != nil {
return err
}
for _, elem := range x {
if err := enc.NextEntryValueString(vdl.StringType, elem); err != nil {
return err
}
}
if err := enc.NextEntry(true); err != nil {
return err
}
return enc.FinishValue()
}
func (x *Envelope) VDLRead(dec vdl.Decoder) error {
*x = Envelope{}
if err := dec.StartValue(__VDLType_struct_4); err != nil {
return err
}
decType := dec.Type()
for {
index, err := dec.NextField()
switch {
case err != nil:
return err
case index == -1:
return dec.FinishValue()
}
if decType != __VDLType_struct_4 {
index = __VDLType_struct_4.FieldIndexByName(decType.Field(index).Name)
if index == -1 {
if err := dec.SkipValue(); err != nil {
return err
}
continue
}
}
switch index {
case 0:
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
x.Title = value
}
case 1:
if err := __VDLReadAnon_list_1(dec, &x.Args); err != nil {
return err
}
case 2:
if err := x.Binary.VDLRead(dec); err != nil {
return err
}
case 3:
var wire security.WireBlessings
if err := wire.VDLRead(dec); err != nil {
return err
}
if err := security.WireBlessingsToNative(wire, &x.Publisher); err != nil {
return err
}
case 4:
if err := __VDLReadAnon_list_1(dec, &x.Env); err != nil {
return err
}
case 5:
if err := x.Packages.VDLRead(dec); err != nil {
return err
}
case 6:
switch value, err := dec.ReadValueInt(32); {
case err != nil:
return err
default:
x.Restarts = int32(value)
}
case 7:
var wire vdltime.Duration
if err := wire.VDLRead(dec); err != nil {
return err
}
if err := vdltime.DurationToNative(wire, &x.RestartTimeWindow); err != nil {
return err
}
}
}
}
func __VDLReadAnon_list_1(dec vdl.Decoder, x *[]string) error {
if err := dec.StartValue(__VDLType_list_5); err != nil {
return err
}
if len := dec.LenHint(); len > 0 {
*x = make([]string, 0, len)
} else {
*x = nil
}
for {
switch done, elem, err := dec.NextEntryValueString(); {
case err != nil:
return err
case done:
return dec.FinishValue()
default:
*x = append(*x, elem)
}
}
}
//////////////////////////////////////////////////
// Const definitions
// Device manager application envelopes must present this title.
const DeviceManagerTitle = "device manager"
// Hold type definitions in package-level variables, for better performance.
var (
__VDLType_struct_1 *vdl.Type
__VDLType_struct_2 *vdl.Type
__VDLType_map_3 *vdl.Type
__VDLType_struct_4 *vdl.Type
__VDLType_list_5 *vdl.Type
__VDLType_struct_6 *vdl.Type
__VDLType_struct_7 *vdl.Type
)
var __VDLInitCalled bool
// __VDLInit performs vdl initialization. It is safe to call multiple times.
// If you have an init ordering issue, just insert the following line verbatim
// into your source files in this package, right after the "package foo" clause:
//
// var _ = __VDLInit()
//
// The purpose of this function is to ensure that vdl initialization occurs in
// the right order, and very early in the init sequence. In particular, vdl
// registration and package variable initialization needs to occur before
// functions like vdl.TypeOf will work properly.
//
// This function returns a dummy value, so that it can be used to initialize the
// first var in the file, to take advantage of Go's defined init order.
func __VDLInit() struct{} {
if __VDLInitCalled {
return struct{}{}
}
__VDLInitCalled = true
// Register types.
vdl.Register((*SignedFile)(nil))
vdl.Register((*Packages)(nil))
vdl.Register((*Envelope)(nil))
// Initialize type definitions.
__VDLType_struct_1 = vdl.TypeOf((*SignedFile)(nil)).Elem()
__VDLType_struct_2 = vdl.TypeOf((*security.Signature)(nil)).Elem()
__VDLType_map_3 = vdl.TypeOf((*Packages)(nil))
__VDLType_struct_4 = vdl.TypeOf((*Envelope)(nil)).Elem()
__VDLType_list_5 = vdl.TypeOf((*[]string)(nil))
__VDLType_struct_6 = vdl.TypeOf((*security.WireBlessings)(nil)).Elem()
__VDLType_struct_7 = vdl.TypeOf((*vdltime.Duration)(nil)).Elem()
return struct{}{}
}