-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathgitlab.go
More file actions
38 lines (34 loc) · 936 Bytes
/
gitlab.go
File metadata and controls
38 lines (34 loc) · 936 Bytes
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
package plugins
import (
"flag"
"fmt"
)
// GitLab returns an Integration configured for the GitLab API.
func GitLab(name, tokenRef string) Integration {
return Integration{
Name: name,
Destination: "https://gitlab.com/api/v4",
InRateLimit: 100,
OutRateLimit: 100,
OutgoingAuth: []AuthPluginConfig{{
Type: "token",
Params: map[string]interface{}{
"secrets": []string{tokenRef},
"header": "PRIVATE-TOKEN",
},
}},
}
}
func init() { Register("gitlab", gitlabBuilder) }
func gitlabBuilder(args []string) (Integration, error) {
fs := flag.NewFlagSet("gitlab", flag.ContinueOnError)
name := fs.String("name", "gitlab", "integration name")
token := fs.String("token", "", "secret reference for API token")
if err := fs.Parse(args); err != nil {
return Integration{}, err
}
if *token == "" {
return Integration{}, fmt.Errorf("-token is required")
}
return GitLab(*name, *token), nil
}