/
repos.go
47 lines (34 loc) · 1.06 KB
/
repos.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
package store
import (
"context"
"github.com/mikkeloscar/maze/model"
)
type RepoStore interface {
// Get gets a repo by unique ID.
Get(int64) (*model.Repo, error)
// GetByName gets a repo by owner and name.
GetByName(string, string) (*model.Repo, error)
// Get all repos.
GetRepoList() ([]*model.Repo, error)
// Create creates a new repository.
Create(*model.Repo) error
// Update updates a repository.
Update(*model.Repo) error
// Delete deletes a user repository.
Delete(*model.Repo) error
}
func GetRepo(c context.Context, id int64) (*model.Repo, error) {
return FromContext(c).Repos().Get(id)
}
func GetRepoByOwnerName(c context.Context, owner, name string) (*model.Repo, error) {
return FromContext(c).Repos().GetByName(owner, name)
}
func CreateRepo(c context.Context, repo *model.Repo) error {
return FromContext(c).Repos().Create(repo)
}
func UpdateRepo(c context.Context, repo *model.Repo) error {
return FromContext(c).Repos().Update(repo)
}
func DeleteRepo(c context.Context, repo *model.Repo) error {
return FromContext(c).Repos().Delete(repo)
}