-
Notifications
You must be signed in to change notification settings - Fork 8
/
mounttable.vdl.go
425 lines (380 loc) · 17 KB
/
mounttable.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
// 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: mounttable
// Package mounttable defines interfaces for managing associations between names
// and servers.
//
// A mount table is a tree of names. Each name may have something mounted on
// it, either a terminal server or another mount table server. If multiple
// servers are mounted onto the same name, they are considered equivalent, i.e.,
// it is semantically irrelevant which is chosen to pass an RPC to.
//
// Access is determined by AccessLists at each node in the tree. When resolving
// a name like a/b/c/d, one must check the client blessings against the
// AccessLists of each node traversed ("", a, a/b, a/b/c, and a/b/c/d).
package mounttable
import (
"v.io/v23"
"v.io/v23/context"
"v.io/v23/naming"
"v.io/v23/rpc"
"v.io/v23/services/permissions"
"v.io/v23/vdl"
)
var _ = __VDLInit() // Must be first; see __VDLInit comments for details.
//////////////////////////////////////////////////
// Type definitions
type Tag string
func (Tag) VDLReflect(struct {
Name string `vdl:"v.io/v23/services/mounttable.Tag"`
}) {
}
func (x Tag) VDLIsZero() bool {
return x == ""
}
func (x Tag) VDLWrite(enc vdl.Encoder) error {
if err := enc.WriteValueString(__VDLType_string_1, string(x)); err != nil {
return err
}
return nil
}
func (x *Tag) VDLRead(dec vdl.Decoder) error {
switch value, err := dec.ReadValueString(); {
case err != nil:
return err
default:
*x = Tag(value)
}
return nil
}
//////////////////////////////////////////////////
// Const definitions
// Admin allow the client to SetPermissions or Delete the receiver. It also subsumes
// all the other tags.
const Admin = Tag("Admin")
// Mount allows the client to Mount or Unmount at the named receiver.
// For example, to Mount onto a/b/c requires Mount or Admin access
// to a/b/c (and Read, Admin, or Resolve to a and a/b).
const Mount = Tag("Mount")
// Read allows the client to Glob any children of the node. Thus to
// perform a Glob of a/* one must have Read access to a AND any other
// access to each child of a. It also allows Resolution through the node.
const Read = Tag("Read")
// Create allows the client to create nodes below the receiver.
const Create = Tag("Create")
// Resolve allows one to resolve through the receiver. Thus to Resolve
// a/b/c, one needs Admin, Resolve, or Read permission on a, a/b,
// and a/b/c.
const Resolve = Tag("Resolve")
//////////////////////////////////////////////////
// Interface definitions
// MountTableClientMethods is the client interface
// containing MountTable methods.
//
// MountTable defines the interface to talk to a mounttable.
//
// In all methods of MountTable, the receiver is the name bound to.
type MountTableClientMethods interface {
// Object provides access control for Vanadium objects.
//
// Vanadium services implementing dynamic access control would typically embed
// this interface and tag additional methods defined by the service with one of
// Admin, Read, Write, Resolve etc. For example, the VDL definition of the
// object would be:
//
// package mypackage
//
// import "v.io/v23/security/access"
// import "v.io/v23/services/permissions"
//
// type MyObject interface {
// permissions.Object
// MyRead() (string, error) {access.Read}
// MyWrite(string) error {access.Write}
// }
//
// If the set of pre-defined tags is insufficient, services may define their
// own tag type and annotate all methods with this new type.
//
// Instead of embedding this Object interface, define SetPermissions and
// GetPermissions in their own interface. Authorization policies will typically
// respect annotations of a single type. For example, the VDL definition of an
// object would be:
//
// package mypackage
//
// import "v.io/v23/security/access"
//
// type MyTag string
//
// const (
// Blue = MyTag("Blue")
// Red = MyTag("Red")
// )
//
// type MyObject interface {
// MyMethod() (string, error) {Blue}
//
// // Allow clients to change access via the access.Object interface:
// SetPermissions(perms access.Permissions, version string) error {Red}
// GetPermissions() (perms access.Permissions, version string, err error) {Blue}
// }
permissions.ObjectClientMethods
// Mount Server (a global name) onto the receiver.
//
// Subsequent mounts add to the servers mounted there. The multiple
// servers are considered equivalent and are meant solely for
// availability, i.e., no load balancing is guaranteed.
//
// The ttl is the number of seconds the mount is to last unless refreshed by
// another mount of the same server. A ttl of 0 represents an infinite
// duration. A server with an expired ttl should never appear in the results
// nor affect the operation of any MountTable method, and should act as if it
// was never present as far as the interface is concerned.
//
// The flags represent a bit mask of options.
Mount(_ *context.T, server string, ttl uint32, flags naming.MountFlag, _ ...rpc.CallOpt) error
// Unmount removes server from the receiver. If server is empty, remove all
// servers mounted there. Returns a non-nil error iff server remains mounted
// at the mount point.
Unmount(_ *context.T, server string, _ ...rpc.CallOpt) error
// Delete removes the receiver. If the receiver has children, it will not
// be removed unless deleteSubtree is true in which case the whole subtree is
// removed.
Delete(_ *context.T, deleteSubtree bool, _ ...rpc.CallOpt) error
// ResolveStep takes the next step in resolving a name. Returns the next
// servers to query and the suffix at those servers.
ResolveStep(*context.T, ...rpc.CallOpt) (naming.MountEntry, error)
}
// MountTableClientStub adds universal methods to MountTableClientMethods.
type MountTableClientStub interface {
MountTableClientMethods
rpc.UniversalServiceMethods
}
// MountTableClient returns a client stub for MountTable.
func MountTableClient(name string) MountTableClientStub {
return implMountTableClientStub{name, permissions.ObjectClient(name)}
}
type implMountTableClientStub struct {
name string
permissions.ObjectClientStub
}
func (c implMountTableClientStub) Mount(ctx *context.T, i0 string, i1 uint32, i2 naming.MountFlag, opts ...rpc.CallOpt) (err error) {
err = v23.GetClient(ctx).Call(ctx, c.name, "Mount", []interface{}{i0, i1, i2}, nil, opts...)
return
}
func (c implMountTableClientStub) Unmount(ctx *context.T, i0 string, opts ...rpc.CallOpt) (err error) {
err = v23.GetClient(ctx).Call(ctx, c.name, "Unmount", []interface{}{i0}, nil, opts...)
return
}
func (c implMountTableClientStub) Delete(ctx *context.T, i0 bool, opts ...rpc.CallOpt) (err error) {
err = v23.GetClient(ctx).Call(ctx, c.name, "Delete", []interface{}{i0}, nil, opts...)
return
}
func (c implMountTableClientStub) ResolveStep(ctx *context.T, opts ...rpc.CallOpt) (o0 naming.MountEntry, err error) {
err = v23.GetClient(ctx).Call(ctx, c.name, "ResolveStep", nil, []interface{}{&o0}, opts...)
return
}
// MountTableServerMethods is the interface a server writer
// implements for MountTable.
//
// MountTable defines the interface to talk to a mounttable.
//
// In all methods of MountTable, the receiver is the name bound to.
type MountTableServerMethods interface {
// Object provides access control for Vanadium objects.
//
// Vanadium services implementing dynamic access control would typically embed
// this interface and tag additional methods defined by the service with one of
// Admin, Read, Write, Resolve etc. For example, the VDL definition of the
// object would be:
//
// package mypackage
//
// import "v.io/v23/security/access"
// import "v.io/v23/services/permissions"
//
// type MyObject interface {
// permissions.Object
// MyRead() (string, error) {access.Read}
// MyWrite(string) error {access.Write}
// }
//
// If the set of pre-defined tags is insufficient, services may define their
// own tag type and annotate all methods with this new type.
//
// Instead of embedding this Object interface, define SetPermissions and
// GetPermissions in their own interface. Authorization policies will typically
// respect annotations of a single type. For example, the VDL definition of an
// object would be:
//
// package mypackage
//
// import "v.io/v23/security/access"
//
// type MyTag string
//
// const (
// Blue = MyTag("Blue")
// Red = MyTag("Red")
// )
//
// type MyObject interface {
// MyMethod() (string, error) {Blue}
//
// // Allow clients to change access via the access.Object interface:
// SetPermissions(perms access.Permissions, version string) error {Red}
// GetPermissions() (perms access.Permissions, version string, err error) {Blue}
// }
permissions.ObjectServerMethods
// Mount Server (a global name) onto the receiver.
//
// Subsequent mounts add to the servers mounted there. The multiple
// servers are considered equivalent and are meant solely for
// availability, i.e., no load balancing is guaranteed.
//
// The ttl is the number of seconds the mount is to last unless refreshed by
// another mount of the same server. A ttl of 0 represents an infinite
// duration. A server with an expired ttl should never appear in the results
// nor affect the operation of any MountTable method, and should act as if it
// was never present as far as the interface is concerned.
//
// The flags represent a bit mask of options.
Mount(_ *context.T, _ rpc.ServerCall, server string, ttl uint32, flags naming.MountFlag) error
// Unmount removes server from the receiver. If server is empty, remove all
// servers mounted there. Returns a non-nil error iff server remains mounted
// at the mount point.
Unmount(_ *context.T, _ rpc.ServerCall, server string) error
// Delete removes the receiver. If the receiver has children, it will not
// be removed unless deleteSubtree is true in which case the whole subtree is
// removed.
Delete(_ *context.T, _ rpc.ServerCall, deleteSubtree bool) error
// ResolveStep takes the next step in resolving a name. Returns the next
// servers to query and the suffix at those servers.
ResolveStep(*context.T, rpc.ServerCall) (naming.MountEntry, error)
}
// MountTableServerStubMethods is the server interface containing
// MountTable methods, as expected by rpc.Server.
// There is no difference between this interface and MountTableServerMethods
// since there are no streaming methods.
type MountTableServerStubMethods MountTableServerMethods
// MountTableServerStub adds universal methods to MountTableServerStubMethods.
type MountTableServerStub interface {
MountTableServerStubMethods
// Describe the MountTable interfaces.
Describe__() []rpc.InterfaceDesc
}
// MountTableServer returns a server stub for MountTable.
// It converts an implementation of MountTableServerMethods into
// an object that may be used by rpc.Server.
func MountTableServer(impl MountTableServerMethods) MountTableServerStub {
stub := implMountTableServerStub{
impl: impl,
ObjectServerStub: permissions.ObjectServer(impl),
}
// Initialize GlobState; always check the stub itself first, to handle the
// case where the user has the Glob method defined in their VDL source.
if gs := rpc.NewGlobState(stub); gs != nil {
stub.gs = gs
} else if gs := rpc.NewGlobState(impl); gs != nil {
stub.gs = gs
}
return stub
}
type implMountTableServerStub struct {
impl MountTableServerMethods
permissions.ObjectServerStub
gs *rpc.GlobState
}
func (s implMountTableServerStub) Mount(ctx *context.T, call rpc.ServerCall, i0 string, i1 uint32, i2 naming.MountFlag) error {
return s.impl.Mount(ctx, call, i0, i1, i2)
}
func (s implMountTableServerStub) Unmount(ctx *context.T, call rpc.ServerCall, i0 string) error {
return s.impl.Unmount(ctx, call, i0)
}
func (s implMountTableServerStub) Delete(ctx *context.T, call rpc.ServerCall, i0 bool) error {
return s.impl.Delete(ctx, call, i0)
}
func (s implMountTableServerStub) ResolveStep(ctx *context.T, call rpc.ServerCall) (naming.MountEntry, error) {
return s.impl.ResolveStep(ctx, call)
}
func (s implMountTableServerStub) Globber() *rpc.GlobState {
return s.gs
}
func (s implMountTableServerStub) Describe__() []rpc.InterfaceDesc {
return []rpc.InterfaceDesc{MountTableDesc, permissions.ObjectDesc}
}
// MountTableDesc describes the MountTable interface.
var MountTableDesc rpc.InterfaceDesc = descMountTable
// descMountTable hides the desc to keep godoc clean.
var descMountTable = rpc.InterfaceDesc{
Name: "MountTable",
PkgPath: "v.io/v23/services/mounttable",
Doc: "// MountTable defines the interface to talk to a mounttable.\n//\n// In all methods of MountTable, the receiver is the name bound to.",
Embeds: []rpc.EmbedDesc{
{"Object", "v.io/v23/services/permissions", "// Object provides access control for Vanadium objects.\n//\n// Vanadium services implementing dynamic access control would typically embed\n// this interface and tag additional methods defined by the service with one of\n// Admin, Read, Write, Resolve etc. For example, the VDL definition of the\n// object would be:\n//\n// package mypackage\n//\n// import \"v.io/v23/security/access\"\n// import \"v.io/v23/services/permissions\"\n//\n// type MyObject interface {\n// permissions.Object\n// MyRead() (string, error) {access.Read}\n// MyWrite(string) error {access.Write}\n// }\n//\n// If the set of pre-defined tags is insufficient, services may define their\n// own tag type and annotate all methods with this new type.\n//\n// Instead of embedding this Object interface, define SetPermissions and\n// GetPermissions in their own interface. Authorization policies will typically\n// respect annotations of a single type. For example, the VDL definition of an\n// object would be:\n//\n// package mypackage\n//\n// import \"v.io/v23/security/access\"\n//\n// type MyTag string\n//\n// const (\n// Blue = MyTag(\"Blue\")\n// Red = MyTag(\"Red\")\n// )\n//\n// type MyObject interface {\n// MyMethod() (string, error) {Blue}\n//\n// // Allow clients to change access via the access.Object interface:\n// SetPermissions(perms access.Permissions, version string) error {Red}\n// GetPermissions() (perms access.Permissions, version string, err error) {Blue}\n// }"},
},
Methods: []rpc.MethodDesc{
{
Name: "Mount",
Doc: "// Mount Server (a global name) onto the receiver.\n//\n// Subsequent mounts add to the servers mounted there. The multiple\n// servers are considered equivalent and are meant solely for\n// availability, i.e., no load balancing is guaranteed.\n//\n// The ttl is the number of seconds the mount is to last unless refreshed by\n// another mount of the same server. A ttl of 0 represents an infinite\n// duration. A server with an expired ttl should never appear in the results\n// nor affect the operation of any MountTable method, and should act as if it\n// was never present as far as the interface is concerned.\n//\n// The flags represent a bit mask of options.",
InArgs: []rpc.ArgDesc{
{"server", ``}, // string
{"ttl", ``}, // uint32
{"flags", ``}, // naming.MountFlag
},
},
{
Name: "Unmount",
Doc: "// Unmount removes server from the receiver. If server is empty, remove all\n// servers mounted there. Returns a non-nil error iff server remains mounted\n// at the mount point.",
InArgs: []rpc.ArgDesc{
{"server", ``}, // string
},
},
{
Name: "Delete",
Doc: "// Delete removes the receiver. If the receiver has children, it will not\n// be removed unless deleteSubtree is true in which case the whole subtree is\n// removed.",
InArgs: []rpc.ArgDesc{
{"deleteSubtree", ``}, // bool
},
},
{
Name: "ResolveStep",
Doc: "// ResolveStep takes the next step in resolving a name. Returns the next\n// servers to query and the suffix at those servers.",
OutArgs: []rpc.ArgDesc{
{"", ``}, // naming.MountEntry
},
},
},
}
// Hold type definitions in package-level variables, for better performance.
var (
__VDLType_string_1 *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((*Tag)(nil))
// Initialize type definitions.
__VDLType_string_1 = vdl.TypeOf((*Tag)(nil))
return struct{}{}
}