Skip to content

Commit

Permalink
Fix v2.X.X releases for the client, update go.mod (#91)
Browse files Browse the repository at this point in the history
## Problem
We made a mistake when releasing the previous `v2.X.X` of the Go client.
In order to handle major versions properly, the Go module ecosystem
requires that packages include a `/vX` path for major versions. This
needs to be represented in the `go.mod` file for the module. See
https://go.dev/doc/modules/version-numbers under "Major version".

Without making this change to the `go.mod` file, when attempting to
install >v2.x.x, you end up with an error:

```
go get -u github.com/pinecone-io/go-pinecone/[email protected]
go: github.com/pinecone-io/go-pinecone/[email protected]: github.com/pinecone-io/[email protected]: invalid version: module contains a go.mod file, so module path must match major version ("github.com/pinecone-io/go-pinecone/v2")
```

## Solution
- Update `go.mod` for v2 -> `module
github.com/pinecone-io/go-pinecone/v2`.
- Update places where we're importing from
`github.com/pinecone-io/go-pinecone/internal` to
`github.com/pinecone-io/go-pinecone/v2/internal`.

## Type of Change
- [ ] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [X] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update
- [ ] Infrastructure change (CI configs, etc)
- [ ] Non-code change (docs, etc)
- [ ] None of the above: (explain here)

## Test Plan
We need to tag and release a new `v2.2.0` to test that this works as
expected. Testing against previous 2.x.x releases is hampered by the
fact that the `go.mod` file is incorrect.
  • Loading branch information
austin-denoble authored Jan 7, 2025
1 parent af29d07 commit dd9d543
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 58 deletions.
50 changes: 25 additions & 25 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ See the [Pinecone API Docs](https://docs.pinecone.io/reference/) for more inform
To upgrade the SDK to the latest version, run:

```shell
go get -u github.com/pinecone-io/go-pinecone/pinecone@latest
go get -u github.com/pinecone-io/go-pinecone/v2/pinecone@latest
```

## Prerequisites
Expand All @@ -36,7 +36,7 @@ go get -u github.com/pinecone-io/go-pinecone/pinecone@latest
To install the Pinecone Go SDK, run the following in your terminal:

```shell
go get github.com/pinecone-io/go-pinecone/pinecone
go get github.com/pinecone-io/go-pinecone/v2/pinecone
```

For more information on setting up a Go project, see the [Go documentation](https://golang.org/doc/).
Expand All @@ -58,7 +58,7 @@ package main

import (
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -91,7 +91,7 @@ package main

import (
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
)

Expand Down Expand Up @@ -129,7 +129,7 @@ package main
import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -178,7 +178,7 @@ package main
import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -232,7 +232,7 @@ package main
import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -273,7 +273,7 @@ package main
import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -314,7 +314,7 @@ package main
import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -354,7 +354,7 @@ package main
import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -436,7 +436,7 @@ package main
import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -487,7 +487,7 @@ package main
import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -530,7 +530,7 @@ package main
import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"google.golang.org/protobuf/types/known/structpb"
"log"
"os"
Expand Down Expand Up @@ -687,7 +687,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"google.golang.org/protobuf/types/known/structpb"
"log"
"os"
Expand Down Expand Up @@ -818,7 +818,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -879,7 +879,7 @@ package main
import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -927,7 +927,7 @@ package main
import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"google.golang.org/protobuf/types/known/structpb"
"log"
"os"
Expand Down Expand Up @@ -982,7 +982,7 @@ package main
import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -1030,7 +1030,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -1110,7 +1110,7 @@ package main
import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -1166,7 +1166,7 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -1243,7 +1243,7 @@ package main
import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -1284,7 +1284,7 @@ package main
import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -1329,7 +1329,7 @@ package main
import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down Expand Up @@ -1367,7 +1367,7 @@ package main
import (
"context"
"fmt"
"github.com/pinecone-io/go-pinecone/pinecone"
"github.com/pinecone-io/go-pinecone/v2/pinecone"
"log"
"os"
)
Expand Down
2 changes: 1 addition & 1 deletion codegen/apis
Submodule apis updated from 39e90e to 934bd7
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/pinecone-io/go-pinecone
module github.com/pinecone-io/go-pinecone/v2

go 1.21

Expand Down
2 changes: 1 addition & 1 deletion internal/useragent/useragent.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"fmt"
"strings"

"github.com/pinecone-io/go-pinecone/internal"
"github.com/pinecone-io/go-pinecone/v2/internal"
)

func getPackageVersion() string {
Expand Down
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ bootstrap:
gen:
./codegen/build-clients.sh {{api_version}}
docs:
@echo "Serving docs at http://localhost:6060/pkg/github.com/pinecone-io/go-pinecone/pinecone/"
@echo "Serving docs at http://localhost:6060/pkg/github.com/pinecone-io/go-pinecone/v2/pinecone/"
@godoc -http=:6060 >/dev/null
12 changes: 6 additions & 6 deletions pinecone/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ import (
"os"
"strings"

"github.com/pinecone-io/go-pinecone/internal/gen"
"github.com/pinecone-io/go-pinecone/internal/gen/db_control"
db_data_rest "github.com/pinecone-io/go-pinecone/internal/gen/db_data/rest"
"github.com/pinecone-io/go-pinecone/internal/gen/inference"
"github.com/pinecone-io/go-pinecone/internal/provider"
"github.com/pinecone-io/go-pinecone/internal/useragent"
"github.com/pinecone-io/go-pinecone/v2/internal/gen"
"github.com/pinecone-io/go-pinecone/v2/internal/gen/db_control"
db_data_rest "github.com/pinecone-io/go-pinecone/v2/internal/gen/db_data/rest"
"github.com/pinecone-io/go-pinecone/v2/internal/gen/inference"
"github.com/pinecone-io/go-pinecone/v2/internal/provider"
"github.com/pinecone-io/go-pinecone/v2/internal/useragent"
"google.golang.org/grpc"
)

Expand Down
26 changes: 8 additions & 18 deletions pinecone/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ import (

"github.com/google/go-cmp/cmp"
"github.com/google/uuid"
"github.com/pinecone-io/go-pinecone/internal/gen"
"github.com/pinecone-io/go-pinecone/internal/gen/db_control"
"github.com/pinecone-io/go-pinecone/internal/provider"
"github.com/pinecone-io/go-pinecone/v2/internal/gen"
"github.com/pinecone-io/go-pinecone/v2/internal/gen/db_control"
"github.com/pinecone-io/go-pinecone/v2/internal/provider"

"github.com/pinecone-io/go-pinecone/internal/utils"
"github.com/pinecone-io/go-pinecone/v2/internal/utils"

"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -211,13 +211,8 @@ func (ts *IntegrationTests) TestConfigureIndexScaleUpNoPods() {
_, err = ts.client.ConfigureIndex(context.Background(), name, ConfigureIndexParams{Replicas: 2})
require.NoError(ts.T(), err)

// give index a bit of time to start upgrading before we poll
time.Sleep(500 * time.Millisecond)

isReady, _ := WaitUntilIndexReady(ts, context.Background())
require.True(ts.T(), isReady, "Expected index to be ready")

time.Sleep(500 * time.Millisecond)
// give index a bit of time to upgrade
time.Sleep(20 * time.Second)

err = ts.client.DeleteIndex(context.Background(), name)
require.NoError(ts.T(), err)
Expand All @@ -240,13 +235,8 @@ func (ts *IntegrationTests) TestConfigureIndexScaleUpNoReplicas() {
_, err = ts.client.ConfigureIndex(context.Background(), name, ConfigureIndexParams{PodType: "p1.x4"})
require.NoError(ts.T(), err)

// give index a bit of time to start upgrading before we poll
time.Sleep(500 * time.Millisecond)

isReady, _ := WaitUntilIndexReady(ts, context.Background())
require.True(ts.T(), isReady, "Expected index to be ready")

time.Sleep(500 * time.Millisecond)
// give index a bit of time to upgrade
time.Sleep(20 * time.Second)

err = ts.client.DeleteIndex(context.Background(), name)
require.NoError(ts.T(), err)
Expand Down
6 changes: 3 additions & 3 deletions pinecone/index_connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import (
"net/url"
"strings"

db_data_grpc "github.com/pinecone-io/go-pinecone/internal/gen/db_data/grpc"
db_data_rest "github.com/pinecone-io/go-pinecone/internal/gen/db_data/rest"
"github.com/pinecone-io/go-pinecone/internal/useragent"
db_data_grpc "github.com/pinecone-io/go-pinecone/v2/internal/gen/db_data/grpc"
db_data_rest "github.com/pinecone-io/go-pinecone/v2/internal/gen/db_data/rest"
"github.com/pinecone-io/go-pinecone/v2/internal/useragent"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/credentials/insecure"
Expand Down
4 changes: 2 additions & 2 deletions pinecone/index_connection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
"testing"
"time"

db_data_grpc "github.com/pinecone-io/go-pinecone/internal/gen/db_data/grpc"
"github.com/pinecone-io/go-pinecone/internal/utils"
db_data_grpc "github.com/pinecone-io/go-pinecone/v2/internal/gen/db_data/grpc"
"github.com/pinecone-io/go-pinecone/v2/internal/utils"
"google.golang.org/grpc"
"google.golang.org/grpc/metadata"
"google.golang.org/protobuf/types/known/structpb"
Expand Down

0 comments on commit dd9d543

Please sign in to comment.