-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.go
52 lines (40 loc) · 1.15 KB
/
client.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
// Copyright (c) 2023, the WebKit for Windows project authors. Please see the
// AUTHORS file for details. All rights reserved. Use of this source code is
// governed by a BSD-style license that can be found in the LICENSE file.
package reqcheck
import (
"context"
"errors"
"fmt"
"github.com/Masterminds/semver"
)
type (
Release struct {
Tag string
SemVer *semver.Version
}
ListOptions struct {
// For paginated result sets, page of results to retrieve.
Page int
// For paginated result sets, the number of results to include per page.
PerPage int
}
Client interface {
ListReleases(ctx context.Context, owner, name string, opt ListOptions) ([]Release, error)
ListTags(ctx context.Context, owner, name string, opt ListOptions) ([]Release, error)
}
)
var ErrScmDriver = errors.New("scm driver error")
const (
DriverGitHub = "github"
DriverGitLab = "gitlab"
)
func NewClientFromDriver(driver, uri, token string) (Client, error) {
if driver == DriverGitHub {
return NewGitHub(uri, token)
}
if driver == DriverGitLab {
return NewGitLab(uri, token)
}
return nil, fmt.Errorf("unknown scm driver %s: %w", driver, ErrScmDriver)
}