Migrate "golang.org/x/net/context" -> "context" (#3333)

In some places, where ctxhttp or gRPC are concerned, we still need to use the
old contexts.
pull/3354/head
Julius Volz 7 years ago committed by GitHub
parent bd52950ce8
commit 099df0c5f0

@ -15,6 +15,7 @@
package main
import (
"context"
"fmt"
"net"
"net/http"
@ -34,7 +35,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/prometheus/common/version"
"golang.org/x/net/context"
"gopkg.in/alecthomas/kingpin.v2"
k8s_runtime "k8s.io/apimachinery/pkg/util/runtime"

@ -14,6 +14,7 @@
package azure
import (
"context"
"fmt"
"net"
"strings"
@ -27,7 +28,6 @@ import (
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil"

@ -14,6 +14,7 @@
package consul
import (
"context"
"fmt"
"net"
"net/http"
@ -30,7 +31,6 @@ import (
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/httputil"
"github.com/prometheus/prometheus/util/strutil"
"golang.org/x/net/context"
)
const (

@ -14,6 +14,7 @@
package discovery
import (
"context"
"fmt"
"sync"
"time"
@ -32,7 +33,6 @@ import (
"github.com/prometheus/prometheus/discovery/openstack"
"github.com/prometheus/prometheus/discovery/triton"
"github.com/prometheus/prometheus/discovery/zookeeper"
"golang.org/x/net/context"
)
// A TargetProvider provides information about target groups. It maintains a set

@ -14,10 +14,10 @@
package discovery
import (
"context"
"testing"
"github.com/prometheus/prometheus/config"
"golang.org/x/net/context"
yaml "gopkg.in/yaml.v2"
)

@ -14,6 +14,7 @@
package dns
import (
"context"
"fmt"
"net"
"strings"
@ -25,7 +26,6 @@ import (
"github.com/miekg/dns"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config"
)

@ -14,6 +14,7 @@
package ec2
import (
"context"
"fmt"
"net"
"strings"
@ -27,7 +28,6 @@ import (
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"golang.org/x/net/context"
"github.com/aws/aws-sdk-go/service/ec2"
"github.com/prometheus/prometheus/config"

@ -14,6 +14,7 @@
package file
import (
"context"
"encoding/json"
"errors"
"fmt"
@ -26,7 +27,6 @@ import (
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"golang.org/x/net/context"
"gopkg.in/fsnotify.v1"
"gopkg.in/yaml.v2"

@ -14,6 +14,7 @@
package file
import (
"context"
"fmt"
"io"
"os"
@ -22,7 +23,6 @@ import (
"time"
"github.com/prometheus/common/model"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config"
)

@ -14,20 +14,19 @@
package gce
import (
"context"
"fmt"
"net/http"
"strings"
"time"
"google.golang.org/api/compute/v1"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"golang.org/x/net/context"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"google.golang.org/api/compute/v1"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil"

@ -14,18 +14,18 @@
package kubernetes
import (
"context"
"fmt"
"net"
"strconv"
"github.com/prometheus/prometheus/config"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/common/model"
"golang.org/x/net/context"
apiv1 "k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/tools/cache"
"github.com/prometheus/prometheus/config"
)
// Endpoints discovers new endpoint targets.

@ -14,6 +14,7 @@
package kubernetes
import (
"context"
"fmt"
"github.com/go-kit/kit/log"
@ -21,7 +22,6 @@ import (
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil"
"golang.org/x/net/context"
"k8s.io/client-go/pkg/apis/extensions/v1beta1"
"k8s.io/client-go/tools/cache"
)

@ -14,23 +14,23 @@
package kubernetes
import (
"context"
"io/ioutil"
"sync"
"time"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/prometheus/config"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"golang.org/x/net/context"
"k8s.io/client-go/kubernetes"
"k8s.io/client-go/pkg/api"
apiv1 "k8s.io/client-go/pkg/api/v1"
extensionsv1beta1 "k8s.io/client-go/pkg/apis/extensions/v1beta1"
"k8s.io/client-go/rest"
"k8s.io/client-go/tools/cache"
"github.com/prometheus/prometheus/config"
)
const (

@ -14,6 +14,7 @@
package kubernetes
import (
"context"
"fmt"
"net"
"strconv"
@ -23,7 +24,6 @@ import (
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil"
"golang.org/x/net/context"
"k8s.io/client-go/pkg/api"
apiv1 "k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/tools/cache"

@ -14,6 +14,7 @@
package kubernetes
import (
"context"
"encoding/json"
"fmt"
"sync"
@ -21,12 +22,12 @@ import (
"time"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config"
"github.com/stretchr/testify/require"
"golang.org/x/net/context"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/tools/cache"
"github.com/prometheus/prometheus/config"
)
type fakeInformer struct {

@ -14,6 +14,7 @@
package kubernetes
import (
"context"
"fmt"
"net"
"strconv"
@ -22,12 +23,12 @@ import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil"
"golang.org/x/net/context"
"k8s.io/client-go/pkg/api"
apiv1 "k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/tools/cache"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil"
)
// Pod discovers new pod targets.

@ -14,6 +14,7 @@
package kubernetes
import (
"context"
"fmt"
"net"
"strconv"
@ -21,11 +22,11 @@ import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil"
"golang.org/x/net/context"
apiv1 "k8s.io/client-go/pkg/api/v1"
"k8s.io/client-go/tools/cache"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil"
)
// Service implements discovery of Kubernetes services.

@ -14,6 +14,7 @@
package marathon
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
@ -24,8 +25,6 @@ import (
"strings"
"time"
"golang.org/x/net/context"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/mwitkow/go-conntrack"

@ -14,13 +14,13 @@
package marathon
import (
"context"
"errors"
"net/http"
"testing"
"time"
"github.com/prometheus/common/model"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config"
)

@ -14,6 +14,7 @@
package openstack
import (
"context"
"fmt"
"net"
"time"
@ -25,7 +26,6 @@ import (
"github.com/gophercloud/gophercloud/openstack/compute/v2/extensions/hypervisors"
"github.com/gophercloud/gophercloud/pagination"
"github.com/prometheus/common/model"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config"
)

@ -14,6 +14,7 @@
package openstack
import (
"context"
"fmt"
"net"
"time"
@ -26,7 +27,6 @@ import (
"github.com/gophercloud/gophercloud/openstack/compute/v2/servers"
"github.com/gophercloud/gophercloud/pagination"
"github.com/prometheus/common/model"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil"

@ -14,6 +14,7 @@
package openstack
import (
"context"
"errors"
"time"
@ -21,7 +22,6 @@ import (
"github.com/gophercloud/gophercloud"
"github.com/gophercloud/gophercloud/openstack"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config"
)

@ -14,6 +14,7 @@
package triton
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
@ -25,9 +26,9 @@ import (
"github.com/mwitkow/go-conntrack"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/httputil"
"golang.org/x/net/context"
)
const (

@ -14,6 +14,7 @@
package triton
import (
"context"
"fmt"
"net"
"net/http"
@ -23,10 +24,10 @@ import (
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
)
var (

@ -14,17 +14,17 @@
package zookeeper
import (
"context"
"encoding/json"
"fmt"
"net"
"strconv"
"time"
"github.com/go-kit/kit/log"
"github.com/prometheus/common/model"
"github.com/samuel/go-zookeeper/zk"
"golang.org/x/net/context"
"github.com/go-kit/kit/log"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/util/strutil"
"github.com/prometheus/prometheus/util/treecache"

@ -15,6 +15,7 @@ package opentsdb
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io/ioutil"
@ -26,7 +27,6 @@ import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/common/model"
"golang.org/x/net/context"
"golang.org/x/net/context/ctxhttp"
)

@ -15,6 +15,7 @@ package notifier
import (
"bytes"
"context"
"encoding/json"
"fmt"
"net"
@ -30,7 +31,7 @@ import (
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"golang.org/x/net/context"
old_ctx "golang.org/x/net/context"
"golang.org/x/net/context/ctxhttp"
"github.com/prometheus/prometheus/config"
@ -123,7 +124,7 @@ type Options struct {
ExternalLabels model.LabelSet
RelabelConfigs []*config.RelabelConfig
// Used for sending HTTP requests to the Alertmanager.
Do func(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error)
Do func(ctx old_ctx.Context, client *http.Client, req *http.Request) (*http.Response, error)
Registerer prometheus.Registerer
}

@ -14,6 +14,7 @@
package notifier
import (
"context"
"encoding/json"
"fmt"
"io/ioutil"
@ -24,7 +25,7 @@ import (
"testing"
"time"
"golang.org/x/net/context"
old_ctx "golang.org/x/net/context"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config"
@ -198,7 +199,7 @@ func TestCustomDo(t *testing.T) {
var received bool
h := New(&Options{
Do: func(ctx context.Context, client *http.Client, req *http.Request) (*http.Response, error) {
Do: func(ctx old_ctx.Context, client *http.Client, req *http.Request) (*http.Response, error) {
received = true
body, err := ioutil.ReadAll(req.Body)
if err != nil {

@ -14,6 +14,7 @@
package promql
import (
"context"
"fmt"
"io/ioutil"
"math"
@ -23,7 +24,6 @@ import (
"time"
"github.com/prometheus/common/model"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/storage"

@ -17,6 +17,7 @@ import (
"bufio"
"bytes"
"compress/gzip"
"context"
"fmt"
"io"
"math"
@ -29,9 +30,7 @@ import (
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/prometheus/common/version"
"golang.org/x/net/context"
"golang.org/x/net/context/ctxhttp"
"github.com/prometheus/prometheus/config"

@ -15,6 +15,7 @@ package retrieval
import (
"bytes"
"context"
"fmt"
"io"
"io/ioutil"
@ -30,7 +31,6 @@ import (
"github.com/prometheus/common/model"
"github.com/stretchr/testify/require"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/pkg/labels"

@ -14,11 +14,11 @@
package retrieval
import (
"context"
"sync"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/discovery"

@ -14,17 +14,16 @@
package rules
import (
"context"
"fmt"
"net/url"
"sync"
"time"
yaml "gopkg.in/yaml.v2"
"golang.org/x/net/context"
html_template "html/template"
yaml "gopkg.in/yaml.v2"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/common/model"

@ -14,6 +14,7 @@
package rules
import (
"context"
"errors"
"fmt"
"math"
@ -28,7 +29,6 @@ import (
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/notifier"

@ -14,6 +14,7 @@
package rules
import (
"context"
"fmt"
"html/template"
"net/url"
@ -21,8 +22,6 @@ import (
yaml "gopkg.in/yaml.v2"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/pkg/rulefmt"
"github.com/prometheus/prometheus/promql"

@ -14,12 +14,11 @@
package rules
import (
"context"
"reflect"
"testing"
"time"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/pkg/timestamp"
"github.com/prometheus/prometheus/promql"

@ -16,6 +16,7 @@ package remote
import (
"bufio"
"bytes"
"context"
"fmt"
"io"
"io/ioutil"
@ -24,10 +25,9 @@ import (
"github.com/golang/protobuf/proto"
"github.com/golang/snappy"
"golang.org/x/net/context"
"github.com/prometheus/common/model"
"golang.org/x/net/context/ctxhttp"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/prompb"
"github.com/prometheus/prometheus/util/httputil"

@ -15,6 +15,7 @@ package template
import (
"bytes"
"context"
"errors"
"fmt"
"math"
@ -28,9 +29,8 @@ import (
text_template "text/template"
"github.com/prometheus/common/model"
"github.com/prometheus/prometheus/pkg/labels"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/util/strutil"
)

@ -14,13 +14,13 @@
package template
import (
"context"
"math"
"net/url"
"testing"
"github.com/prometheus/common/model"
"github.com/stretchr/testify/require"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql"

@ -14,6 +14,7 @@
package v1
import (
"context"
"encoding/json"
"errors"
"fmt"
@ -26,7 +27,6 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/prometheus/common/route"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/pkg/labels"

@ -14,6 +14,7 @@
package v1
import (
"context"
"encoding/json"
"errors"
"fmt"
@ -27,7 +28,6 @@ import (
"github.com/prometheus/common/model"
"github.com/prometheus/common/route"
"golang.org/x/net/context"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/pkg/labels"

@ -14,7 +14,7 @@
package api_v2
import (
native_context "context"
"context"
"fmt"
"math"
"math/rand"
@ -24,7 +24,7 @@ import (
"path/filepath"
"time"
"golang.org/x/net/context"
old_ctx "golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
@ -33,14 +33,15 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/protoutil"
"github.com/grpc-ecosystem/grpc-gateway/runtime"
"github.com/pkg/errors"
"github.com/prometheus/tsdb"
tsdbLabels "github.com/prometheus/tsdb/labels"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/pkg/timestamp"
pb "github.com/prometheus/prometheus/prompb"
"github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/retrieval"
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/tsdb"
tsdbLabels "github.com/prometheus/tsdb/labels"
)
// API encapsulates all API services.
@ -48,7 +49,7 @@ type API struct {
enableAdmin bool
now func() time.Time
db func() *tsdb.DB
q func(ctx native_context.Context, mint, maxt int64) (storage.Querier, error)
q func(ctx context.Context, mint, maxt int64) (storage.Querier, error)
targets func() []*retrieval.Target
alertmanagers func() []*url.URL
}
@ -58,7 +59,7 @@ func New(
now func() time.Time,
db func() *tsdb.DB,
qe *promql.Engine,
q func(ctx native_context.Context, mint, maxt int64) (storage.Querier, error),
q func(ctx context.Context, mint, maxt int64) (storage.Querier, error),
targets func() []*retrieval.Target,
alertmanagers func() []*url.URL,
enableAdmin bool,
@ -139,12 +140,12 @@ type adminDisabled struct {
}
// TSDBSnapshot implements pb.AdminServer.
func (s *adminDisabled) TSDBSnapshot(_ context.Context, _ *pb.TSDBSnapshotRequest) (*pb.TSDBSnapshotResponse, error) {
func (s *adminDisabled) TSDBSnapshot(_ old_ctx.Context, _ *pb.TSDBSnapshotRequest) (*pb.TSDBSnapshotResponse, error) {
return nil, status.Error(codes.Unavailable, "Admin APIs are disabled")
}
// DeleteSeries imeplements pb.AdminServer.
func (s *adminDisabled) DeleteSeries(_ context.Context, r *pb.SeriesDeleteRequest) (*pb.SeriesDeleteResponse, error) {
func (s *adminDisabled) DeleteSeries(_ old_ctx.Context, r *pb.SeriesDeleteRequest) (*pb.SeriesDeleteResponse, error) {
return nil, status.Error(codes.Unavailable, "Admin APIs are disabled")
}
@ -161,7 +162,7 @@ func NewAdmin(db func() *tsdb.DB) *Admin {
}
// TSDBSnapshot implements pb.AdminServer.
func (s *Admin) TSDBSnapshot(_ context.Context, _ *pb.TSDBSnapshotRequest) (*pb.TSDBSnapshotResponse, error) {
func (s *Admin) TSDBSnapshot(_ old_ctx.Context, _ *pb.TSDBSnapshotRequest) (*pb.TSDBSnapshotResponse, error) {
db := s.db()
if db == nil {
return nil, status.Errorf(codes.Unavailable, "TSDB not ready")
@ -181,7 +182,7 @@ func (s *Admin) TSDBSnapshot(_ context.Context, _ *pb.TSDBSnapshotRequest) (*pb.
}
// DeleteSeries implements pb.AdminServer.
func (s *Admin) DeleteSeries(_ context.Context, r *pb.SeriesDeleteRequest) (*pb.SeriesDeleteResponse, error) {
func (s *Admin) DeleteSeries(_ old_ctx.Context, r *pb.SeriesDeleteRequest) (*pb.SeriesDeleteResponse, error) {
mint, maxt, err := extractTimeRange(r.MinTime, r.MaxTime)
if err != nil {
return nil, status.Error(codes.InvalidArgument, err.Error())

@ -15,6 +15,7 @@ package web
import (
"bytes"
"context"
"encoding/json"
"fmt"
"io"
@ -41,23 +42,22 @@ import (
"github.com/cockroachdb/cmux"
"github.com/go-kit/kit/log"
"github.com/go-kit/kit/log/level"
"github.com/mwitkow/go-conntrack"
"github.com/opentracing-contrib/go-stdlib/nethttp"
"github.com/opentracing/opentracing-go"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/common/model"
"github.com/prometheus/common/route"
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/tsdb"
"golang.org/x/net/context"
"golang.org/x/net/netutil"
"github.com/mwitkow/go-conntrack"
"github.com/prometheus/prometheus/config"
"github.com/prometheus/prometheus/notifier"
"github.com/prometheus/prometheus/pkg/labels"
"github.com/prometheus/prometheus/promql"
"github.com/prometheus/prometheus/retrieval"
"github.com/prometheus/prometheus/rules"
"github.com/prometheus/prometheus/storage"
"github.com/prometheus/prometheus/template"
"github.com/prometheus/prometheus/util/httputil"
api_v1 "github.com/prometheus/prometheus/web/api/v1"

Loading…
Cancel
Save