Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: deprecate 'golang.org/x/net/context' #8511

Merged
merged 5 commits into from
Sep 8, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ See [etcdctl][etcdctl] for a simple command line client.

The easiest way to get etcd is to use one of the pre-built release binaries which are available for OSX, Linux, Windows, [rkt][rkt], and Docker. Instructions for using these binaries are on the [GitHub releases page][github-release].

For those wanting to try the very latest version, [build the latest version of etcd][dl-build] from the `master` branch. This first needs [*Go*](https://golang.org/) installed (version 1.8+ is required). All development occurs on `master`, including new features and bug fixes. Bug fixes are first targeted at `master` and subsequently ported to release branches, as described in the [branch management][branch-management] guide.
For those wanting to try the very latest version, [build the latest version of etcd][dl-build] from the `master` branch. This first needs [*Go*](https://golang.org/) installed (version 1.9+ is required). All development occurs on `master`, including new features and bug fixes. Bug fixes are first targeted at `master` and subsequently ported to release branches, as described in the [branch management][branch-management] guide.

[rkt]: https://github.com/rkt/rkt/releases/
[github-release]: https://github.com/coreos/etcd/releases/
Expand Down
2 changes: 1 addition & 1 deletion auth/jwt.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
package auth

import (
"context"
"crypto/rsa"
"io/ioutil"

jwt "github.com/dgrijalva/jwt-go"
"golang.org/x/net/context"
)

type tokenJWT struct {
Expand Down
3 changes: 1 addition & 2 deletions auth/simple_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,14 @@ package auth
// JWT based mechanism will be added in the near future.

import (
"context"
"crypto/rand"
"fmt"
"math/big"
"strconv"
"strings"
"sync"
"time"

"golang.org/x/net/context"
)

const (
Expand Down
3 changes: 2 additions & 1 deletion auth/store.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package auth

import (
"bytes"
"context"
"encoding/binary"
"errors"
"sort"
Expand All @@ -26,9 +27,9 @@ import (
"github.com/coreos/etcd/auth/authpb"
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
"github.com/coreos/etcd/mvcc/backend"

"github.com/coreos/pkg/capnslog"
"golang.org/x/crypto/bcrypt"
"golang.org/x/net/context"
"google.golang.org/grpc/credentials"
"google.golang.org/grpc/metadata"
"google.golang.org/grpc/peer"
Expand Down
2 changes: 1 addition & 1 deletion auth/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package auth

import (
"context"
"fmt"
"os"
"reflect"
Expand All @@ -27,7 +28,6 @@ import (
"github.com/coreos/etcd/mvcc/backend"

"golang.org/x/crypto/bcrypt"
"golang.org/x/net/context"
"google.golang.org/grpc/metadata"
)

Expand Down
2 changes: 1 addition & 1 deletion client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ package main
import (
"log"
"time"
"context"

"golang.org/x/net/context"
"github.com/coreos/etcd/client"
)

Expand Down
3 changes: 1 addition & 2 deletions client/auth_role.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,10 @@ package client

import (
"bytes"
"context"
"encoding/json"
"net/http"
"net/url"

"golang.org/x/net/context"
)

type Role struct {
Expand Down
3 changes: 1 addition & 2 deletions client/auth_user.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,11 @@ package client

import (
"bytes"
"context"
"encoding/json"
"net/http"
"net/url"
"path"

"golang.org/x/net/context"
)

var (
Expand Down
3 changes: 1 addition & 2 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package client

import (
"context"
"encoding/json"
"errors"
"fmt"
Expand All @@ -29,8 +30,6 @@ import (
"time"

"github.com/coreos/etcd/version"

"golang.org/x/net/context"
)

var (
Expand Down
2 changes: 1 addition & 1 deletion client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package client

import (
"context"
"errors"
"io"
"io/ioutil"
Expand All @@ -29,7 +30,6 @@ import (

"github.com/coreos/etcd/pkg/testutil"
"github.com/coreos/etcd/version"
"golang.org/x/net/context"
)

type actionAssertingHTTPClient struct {
Expand Down
2 changes: 1 addition & 1 deletion client/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ Create a Config and exchange it for a Client:

import (
"net/http"
"context"

"github.com/coreos/etcd/client"
"golang.org/x/net/context"
)

cfg := client.Config{
Expand Down
2 changes: 1 addition & 1 deletion client/example_keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@
package client_test

import (
"context"
"fmt"
"log"
"sort"

"github.com/coreos/etcd/client"
"golang.org/x/net/context"
)

func ExampleKeysAPI_directory() {
Expand Down
3 changes: 1 addition & 2 deletions client/integration/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package integration

import (
"context"
"fmt"
"net/http"
"net/http/httptest"
Expand All @@ -23,8 +24,6 @@ import (
"sync/atomic"
"testing"

"golang.org/x/net/context"

"github.com/coreos/etcd/client"
"github.com/coreos/etcd/integration"
"github.com/coreos/etcd/pkg/testutil"
Expand Down
2 changes: 1 addition & 1 deletion client/keys.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package client
//go:generate codecgen -d 1819 -r "Node|Response|Nodes" -o keys.generated.go keys.go

import (
"context"
"encoding/json"
"errors"
"fmt"
Expand All @@ -28,7 +29,6 @@ import (

"github.com/coreos/etcd/pkg/pathutil"
"github.com/ugorji/go/codec"
"golang.org/x/net/context"
)

const (
Expand Down
3 changes: 1 addition & 2 deletions client/keys_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package client

import (
"context"
"errors"
"fmt"
"io/ioutil"
Expand All @@ -23,8 +24,6 @@ import (
"reflect"
"testing"
"time"

"golang.org/x/net/context"
)

func TestV2KeysURLHelper(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions client/members.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@ package client

import (
"bytes"
"context"
"encoding/json"
"fmt"
"net/http"
"net/url"
"path"

"golang.org/x/net/context"

"github.com/coreos/etcd/pkg/types"
)

Expand Down
3 changes: 1 addition & 2 deletions client/members_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@
package client

import (
"context"
"encoding/json"
"errors"
"net/http"
"net/url"
"reflect"
"testing"

"golang.org/x/net/context"

"github.com/coreos/etcd/pkg/types"
)

Expand Down
3 changes: 2 additions & 1 deletion clientv3/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
package clientv3

import (
"context"
"fmt"
"strings"

"github.com/coreos/etcd/auth/authpb"
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
"golang.org/x/net/context"

"google.golang.org/grpc"
)

Expand Down
2 changes: 1 addition & 1 deletion clientv3/balancer.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
package clientv3

import (
"context"
"net/url"
"strings"
"sync"

"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
)
Expand Down
8 changes: 5 additions & 3 deletions clientv3/balancer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package clientv3

import (
"context"
"errors"
"net"
"sync"
Expand All @@ -24,7 +25,6 @@ import (
pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
"github.com/coreos/etcd/pkg/testutil"

"golang.org/x/net/context"
"google.golang.org/grpc"
)

Expand Down Expand Up @@ -84,8 +84,9 @@ func TestBalancerGetBlocking(t *testing.T) {
}
blockingOpts := grpc.BalancerGetOptions{BlockingWait: true}

ctx, _ := context.WithTimeout(context.Background(), time.Millisecond*100)
ctx, cancel := context.WithTimeout(context.Background(), time.Millisecond*100)
_, _, err := sb.Get(ctx, blockingOpts)
cancel()
if err != context.DeadlineExceeded {
t.Errorf("Get() with no up endpoints should timeout, got %v", err)
}
Expand Down Expand Up @@ -124,8 +125,9 @@ func TestBalancerGetBlocking(t *testing.T) {
t.Errorf("closing the only connection should triggered balancer to send the all endpoints via Notify chan so that we can establish a connection")
}
down2(errors.New("error"))
ctx, _ = context.WithTimeout(context.Background(), time.Millisecond*100)
ctx, cancel = context.WithTimeout(context.Background(), time.Millisecond*100)
_, _, err = sb.Get(ctx, blockingOpts)
cancel()
if err != context.DeadlineExceeded {
t.Errorf("Get() with no up endpoints should timeout, got %v", err)
}
Expand Down
10 changes: 6 additions & 4 deletions clientv3/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package clientv3

import (
"context"
"crypto/tls"
"errors"
"fmt"
Expand All @@ -27,7 +28,6 @@ import (

"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"

"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/credentials"
Expand Down Expand Up @@ -143,8 +143,10 @@ func (c *Client) autoSync() {
case <-c.ctx.Done():
return
case <-time.After(c.cfg.AutoSyncInterval):
ctx, _ := context.WithTimeout(c.ctx, 5*time.Second)
if err := c.Sync(ctx); err != nil && err != c.ctx.Err() {
ctx, cancel := context.WithTimeout(c.ctx, 5*time.Second)
err := c.Sync(ctx)
cancel()
if err != nil && err != c.ctx.Err() {
logger.Println("Auto sync endpoints failed:", err)
}
}
Expand Down Expand Up @@ -429,7 +431,7 @@ func (c *Client) checkVersion() (err error) {
errc := make(chan error, len(c.cfg.Endpoints))
ctx, cancel := context.WithCancel(c.ctx)
if c.cfg.DialTimeout > 0 {
ctx, _ = context.WithTimeout(ctx, c.cfg.DialTimeout)
ctx, cancel = context.WithTimeout(ctx, c.cfg.DialTimeout)
}
wg.Add(len(c.cfg.Endpoints))
for _, ep := range c.cfg.Endpoints {
Expand Down
2 changes: 1 addition & 1 deletion clientv3/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
package clientv3

import (
"context"
"fmt"
"net"
"testing"
"time"

"github.com/coreos/etcd/etcdserver/api/v3rpc/rpctypes"
"github.com/coreos/etcd/pkg/testutil"
"golang.org/x/net/context"
)

func TestDialCancel(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion clientv3/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@
package clientv3

import (
"context"

pb "github.com/coreos/etcd/etcdserver/etcdserverpb"
"golang.org/x/net/context"
"google.golang.org/grpc"
)

Expand Down
Loading