forked from harness/harness
-
Notifications
You must be signed in to change notification settings - Fork 0
/
user.go
72 lines (57 loc) · 2.12 KB
/
user.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
package datastore
import (
"code.google.com/p/go.net/context"
"github.com/drone/drone/shared/model"
)
type Userstore interface {
// GetUser retrieves a specific user from the
// datastore for the given ID.
GetUser(id int64) (*model.User, error)
// GetUserLogin retrieves a user from the datastore
// for the specified remote and login name.
GetUserLogin(remote, login string) (*model.User, error)
// GetUserToken retrieves a user from the datastore
// with the specified token.
GetUserToken(token string) (*model.User, error)
// GetUserList retrieves a list of all users from
// the datastore that are registered in the system.
GetUserList() ([]*model.User, error)
// PostUser saves a User in the datastore.
PostUser(user *model.User) error
// PutUser saves a user in the datastore.
PutUser(user *model.User) error
// DelUser removes the user from the datastore.
DelUser(user *model.User) error
}
// GetUser retrieves a specific user from the
// datastore for the given ID.
func GetUser(c context.Context, id int64) (*model.User, error) {
return FromContext(c).GetUser(id)
}
// GetUserLogin retrieves a user from the datastore
// for the specified remote and login name.
func GetUserLogin(c context.Context, remote, login string) (*model.User, error) {
return FromContext(c).GetUserLogin(remote, login)
}
// GetUserToken retrieves a user from the datastore
// with the specified token.
func GetUserToken(c context.Context, token string) (*model.User, error) {
return FromContext(c).GetUserToken(token)
}
// GetUserList retrieves a list of all users from
// the datastore that are registered in the system.
func GetUserList(c context.Context) ([]*model.User, error) {
return FromContext(c).GetUserList()
}
// PostUser saves a User in the datastore.
func PostUser(c context.Context, user *model.User) error {
return FromContext(c).PostUser(user)
}
// PutUser saves a user in the datastore.
func PutUser(c context.Context, user *model.User) error {
return FromContext(c).PutUser(user)
}
// DelUser removes the user from the datastore.
func DelUser(c context.Context, user *model.User) error {
return FromContext(c).DelUser(user)
}