Verified Commit 4237f6aa authored by Florian Forster's avatar Florian Forster
Browse files

fix: Add `/v2` suffix to module path.

The `module` directive in `go.mod` and all internal imports were missing the
required `/v2` suffix, making the module unusable with Go tooling.

Fixes: #2239
parent 5b5a2dad
Loading
Loading
Loading
Loading
+9 −9
Original line number Diff line number Diff line
@@ -18,7 +18,7 @@ in a major release version to follow SemVar. For the release 2.0 migration guide
## Usage

```go
import "gitlab.com/gitlab-org/api/client-go"
import "gitlab.com/gitlab-org/api/client-go/v2"
```

Construct a new GitLab client, then use the various services on the client to
@@ -64,7 +64,7 @@ package main
import (
	"log"

	"gitlab.com/gitlab-org/api/client-go"
	"gitlab.com/gitlab-org/api/client-go/v2"
)

func main() {
@@ -102,7 +102,7 @@ func main() {

#### Use OAuth2 helper package

The following example demonstrates how to use the `gitlab.com/gitlab-org/api/client-go/oauth2` package:
The following example demonstrates how to use the `gitlab.com/gitlab-org/api/client-go/v2/oauth2` package:

```go
package main
@@ -112,8 +112,8 @@ import (
	"fmt"
	"os/exec"

	gitlab "gitlab.com/gitlab-org/api/client-go"
	"gitlab.com/gitlab-org/api/client-go/gitlaboauth2"
	gitlab "gitlab.com/gitlab-org/api/client-go/v2"
	"gitlab.com/gitlab-org/api/client-go/v2/gitlaboauth2"
)

func main() {
@@ -192,8 +192,8 @@ import (
	"fmt"
	"log"

	"gitlab.com/gitlab-org/api/client-go"
	"gitlab.com/gitlab-org/api/client-go/config"
	"gitlab.com/gitlab-org/api/client-go/v2"
	"gitlab.com/gitlab-org/api/client-go/v2/config"
)

func main() {
@@ -240,12 +240,12 @@ For complete usage of go-gitlab, see the full [package docs](https://pkg.go.dev/
To install the library, use the following command:

```go
go get gitlab.com/gitlab-org/api/client-go
go get gitlab.com/gitlab-org/api/client-go/v2
```

## Testing

The `client-go` project comes with a `testing` package at `gitlab.com/gitlab-org/api/client-go/testing`
The `client-go` project comes with a `testing` package at `gitlab.com/gitlab-org/api/client-go/v2/testing`
which contains a `TestClient` with [gomock](https://github.com/uber-go/mock) mocks for the individual services.

You can use them like this:
+3 −3
Original line number Diff line number Diff line
@@ -27,9 +27,9 @@ import (
	"buf.build/go/protovalidate"
	"buf.build/go/protoyaml"
	"github.com/zalando/go-keyring"
	gitlab "gitlab.com/gitlab-org/api/client-go"
	"gitlab.com/gitlab-org/api/client-go/config/v1beta1"
	"gitlab.com/gitlab-org/api/client-go/gitlaboauth2"
	gitlab "gitlab.com/gitlab-org/api/client-go/v2"
	"gitlab.com/gitlab-org/api/client-go/v2/config/v1beta1"
	"gitlab.com/gitlab-org/api/client-go/v2/gitlaboauth2"
	"golang.org/x/oauth2"
	"golang.org/x/time/rate"
	"google.golang.org/protobuf/types/known/structpb"
+2 −2
Original line number Diff line number Diff line
@@ -7,8 +7,8 @@ import (
	"github.com/MakeNowJust/heredoc/v2"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
	gitlab "gitlab.com/gitlab-org/api/client-go"
	"gitlab.com/gitlab-org/api/client-go/config/v1beta1"
	gitlab "gitlab.com/gitlab-org/api/client-go/v2"
	"gitlab.com/gitlab-org/api/client-go/v2/config/v1beta1"
)

func TestConfig_EmptyConfig(t *testing.T) {
+2 −2
Original line number Diff line number Diff line
@@ -5,8 +5,8 @@ import (
	"log"

	"github.com/MakeNowJust/heredoc/v2"
	"gitlab.com/gitlab-org/api/client-go"
	"gitlab.com/gitlab-org/api/client-go/config"
	"gitlab.com/gitlab-org/api/client-go/v2"
	"gitlab.com/gitlab-org/api/client-go/v2/config"
)

func main() {
+1 −1
Original line number Diff line number Diff line
@@ -1735,7 +1735,7 @@ const file_config_v1beta1_config_proto_rawDesc = "" +
	"\xbaH\a\xc8\x01\x01r\x02\x10\x01R\x04user:\xbb\x01\n" +
	"\funique_names\x12\x1b.buf.validate.RepeatedRules\x18\xaa\xe8\x92& \x01(\bBx\xc2Hu\n" +
	"s\n" +
	"\funique_names\x12\x18all names must be unique\x1aIthis.map(i, i.name).all(name, this.filter(j, j.name == name).size() == 1)R\vuniqueNamesB4Z2gitlab.com/gitlab-org/api/client-go/config/v1beta1b\beditionsp\xe8\a"
	"\funique_names\x12\x18all names must be unique\x1aIthis.map(i, i.name).all(name, this.filter(j, j.name == name).size() == 1)R\vuniqueNamesB7Z5gitlab.com/gitlab-org/api/client-go/v2/config/v1beta1b\beditionsp\xe8\a"

var (
	file_config_v1beta1_config_proto_rawDescOnce sync.Once
Loading