forked from profclems/glab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsnippets.go
37 lines (32 loc) · 792 Bytes
/
snippets.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
package api
import "github.com/xanzy/go-gitlab"
// CreateSnippet for the user inside the users snippets
var CreateSnippet = func(
client *gitlab.Client,
projectID interface{},
opts *gitlab.CreateSnippetOptions,
) (*gitlab.Snippet, error) {
if client == nil {
client = apiClient.Lab()
}
snipet, _, err := client.Snippets.CreateSnippet(opts)
if err != nil {
return nil, err
}
return snipet, err
}
// CreateProjectSnippet inside the project
var CreateProjectSnippet = func(
client *gitlab.Client,
projectID interface{},
opts *gitlab.CreateProjectSnippetOptions,
) (*gitlab.Snippet, error) {
if client == nil {
client = apiClient.Lab()
}
snipet, _, err := client.ProjectSnippets.CreateSnippet(projectID, opts)
if err != nil {
return nil, err
}
return snipet, err
}