-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
kbfs_git.go
130 lines (117 loc) · 4.07 KB
/
kbfs_git.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
// Auto-generated to Go types and interfaces using avdl-compiler v1.4.10 (https://github.com/keybase/node-avdl-compiler)
// Input file: avdl/keybase1/kbfs_git.avdl
package keybase1
import (
"github.com/keybase/go-framed-msgpack-rpc/rpc"
context "golang.org/x/net/context"
"time"
)
type GcOptions struct {
MaxLooseRefs int `codec:"maxLooseRefs" json:"maxLooseRefs"`
PruneMinLooseObjects int `codec:"pruneMinLooseObjects" json:"pruneMinLooseObjects"`
PruneExpireTime Time `codec:"pruneExpireTime" json:"pruneExpireTime"`
MaxObjectPacks int `codec:"maxObjectPacks" json:"maxObjectPacks"`
}
func (o GcOptions) DeepCopy() GcOptions {
return GcOptions{
MaxLooseRefs: o.MaxLooseRefs,
PruneMinLooseObjects: o.PruneMinLooseObjects,
PruneExpireTime: o.PruneExpireTime.DeepCopy(),
MaxObjectPacks: o.MaxObjectPacks,
}
}
type CreateRepoArg struct {
Folder FolderHandle `codec:"folder" json:"folder"`
Name GitRepoName `codec:"name" json:"name"`
}
type DeleteRepoArg struct {
Folder FolderHandle `codec:"folder" json:"folder"`
Name GitRepoName `codec:"name" json:"name"`
}
type GcArg struct {
Folder FolderHandle `codec:"folder" json:"folder"`
Name GitRepoName `codec:"name" json:"name"`
Options GcOptions `codec:"options" json:"options"`
}
type KBFSGitInterface interface {
// * createRepo creates a bare empty repo on KBFS under the given name in the given TLF.
// * It returns the ID of the repo created.
CreateRepo(context.Context, CreateRepoArg) (RepoID, error)
// * deleteRepo deletes repo on KBFS under the given name in the given TLF.
DeleteRepo(context.Context, DeleteRepoArg) error
// * gc runs garbage collection on the given repo, using the given options to
// * see whether anything needs to be done.
Gc(context.Context, GcArg) error
}
func KBFSGitProtocol(i KBFSGitInterface) rpc.Protocol {
return rpc.Protocol{
Name: "keybase.1.KBFSGit",
Methods: map[string]rpc.ServeHandlerDescription{
"createRepo": {
MakeArg: func() interface{} {
var ret [1]CreateRepoArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]CreateRepoArg)
if !ok {
err = rpc.NewTypeError((*[1]CreateRepoArg)(nil), args)
return
}
ret, err = i.CreateRepo(ctx, typedArgs[0])
return
},
},
"deleteRepo": {
MakeArg: func() interface{} {
var ret [1]DeleteRepoArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]DeleteRepoArg)
if !ok {
err = rpc.NewTypeError((*[1]DeleteRepoArg)(nil), args)
return
}
err = i.DeleteRepo(ctx, typedArgs[0])
return
},
},
"gc": {
MakeArg: func() interface{} {
var ret [1]GcArg
return &ret
},
Handler: func(ctx context.Context, args interface{}) (ret interface{}, err error) {
typedArgs, ok := args.(*[1]GcArg)
if !ok {
err = rpc.NewTypeError((*[1]GcArg)(nil), args)
return
}
err = i.Gc(ctx, typedArgs[0])
return
},
},
},
}
}
type KBFSGitClient struct {
Cli rpc.GenericClient
}
// * createRepo creates a bare empty repo on KBFS under the given name in the given TLF.
// * It returns the ID of the repo created.
func (c KBFSGitClient) CreateRepo(ctx context.Context, __arg CreateRepoArg) (res RepoID, err error) {
err = c.Cli.Call(ctx, "keybase.1.KBFSGit.createRepo", []interface{}{__arg}, &res, 0*time.Millisecond)
return
}
// * deleteRepo deletes repo on KBFS under the given name in the given TLF.
func (c KBFSGitClient) DeleteRepo(ctx context.Context, __arg DeleteRepoArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.KBFSGit.deleteRepo", []interface{}{__arg}, nil, 0*time.Millisecond)
return
}
// * gc runs garbage collection on the given repo, using the given options to
// * see whether anything needs to be done.
func (c KBFSGitClient) Gc(ctx context.Context, __arg GcArg) (err error) {
err = c.Cli.Call(ctx, "keybase.1.KBFSGit.gc", []interface{}{__arg}, nil, 0*time.Millisecond)
return
}