This repository has been archived by the owner on Nov 22, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 162
/
project.go
85 lines (77 loc) · 2.23 KB
/
project.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
package api
import "github.com/xanzy/go-gitlab"
var GetProject = func(client *gitlab.Client, projectID interface{}) (*gitlab.Project, error) {
if client == nil {
client = apiClient.Lab()
}
opts := &gitlab.GetProjectOptions{
Statistics: gitlab.Bool(true),
License: gitlab.Bool(true),
WithCustomAttributes: gitlab.Bool(true),
}
project, _, err := client.Projects.GetProject(projectID, opts)
if err != nil {
return nil, err
}
return project, nil
}
var DeleteProject = func(client *gitlab.Client, projectID interface{}) (*gitlab.Response, error) {
if client == nil {
client = apiClient.Lab()
}
project, err := client.Projects.DeleteProject(projectID)
if err != nil {
return nil, err
}
return project, nil
}
var CreateProject = func(client *gitlab.Client, opts *gitlab.CreateProjectOptions) (*gitlab.Project, error) {
if client == nil {
client = apiClient.Lab()
}
project, _, err := client.Projects.CreateProject(opts)
if err != nil {
return nil, err
}
return project, nil
}
var ForkProject = func(client *gitlab.Client, projectID interface{}, opts *gitlab.ForkProjectOptions) (*gitlab.Project, error) {
if client == nil {
client = apiClient.Lab()
}
project, _, err := client.Projects.ForkProject(projectID, opts)
if err != nil {
return nil, err
}
return project, nil
}
var GetGroup = func(client *gitlab.Client, groupID interface{}) (*gitlab.Group, error) {
if client == nil {
client = apiClient.Lab()
}
group, _, err := client.Groups.GetGroup(groupID, &gitlab.GetGroupOptions{})
if err != nil {
return nil, err
}
return group, nil
}
var ListGroupProjects = func(client *gitlab.Client, groupID interface{}, opts *gitlab.ListGroupProjectsOptions) ([]*gitlab.Project, error) {
if client == nil {
client = apiClient.Lab()
}
project, _, err := client.Groups.ListGroupProjects(groupID, opts)
if err != nil {
return nil, err
}
return project, nil
}
var ListProjectMembers = func(client *gitlab.Client, projectID interface{}, opts *gitlab.ListProjectMembersOptions) ([]*gitlab.ProjectMember, error) {
if client == nil {
client = apiClient.Lab()
}
members, _, err := client.ProjectMembers.ListAllProjectMembers(projectID, opts)
if err != nil {
return nil, err
}
return members, nil
}