| 26 | } |
| 27 | |
| 28 | func newGitLab(baseURL string, httpClient *http.Client, clock quartz.Clock) (*gitlabProvider, error) { |
| 29 | if baseURL == "" { |
| 30 | baseURL = "https://gitlab.com" |
| 31 | } |
| 32 | baseURL = strings.TrimRight(baseURL, "/") |
| 33 | baseURL = strings.TrimSuffix(baseURL, "/api/v4") |
| 34 | if httpClient == nil { |
| 35 | httpClient = http.DefaultClient |
| 36 | } |
| 37 | |
| 38 | client, err := gitlab.NewClient("", |
| 39 | gitlab.WithBaseURL(baseURL), |
| 40 | gitlab.WithHTTPClient(httpClient), |
| 41 | gitlab.WithoutRetries(), |
| 42 | ) |
| 43 | if err != nil { |
| 44 | return nil, xerrors.Errorf("create gitlab client: %w", err) |
| 45 | } |
| 46 | |
| 47 | return &gitlabProvider{ |
| 48 | webBaseURL: baseURL, |
| 49 | client: client, |
| 50 | clock: clock, |
| 51 | }, nil |
| 52 | } |
| 53 | |
| 54 | var _ Provider = (*gitlabProvider)(nil) |
| 55 | |