Replace golang.org/x/net/context with std library

Signed-off-by: Shengjing Zhu <zhsj@debian.org>
This commit is contained in:
Shengjing Zhu 2022-02-22 02:15:03 +08:00
parent d128c3767b
commit f4f41296c2
62 changed files with 68 additions and 71 deletions

2
go.mod
View File

@ -66,7 +66,7 @@ require (
go.opentelemetry.io/otel/sdk v1.3.0
go.opentelemetry.io/otel/trace v1.3.0
golang.org/x/crypto v0.0.0-20210817164053-32db794688a5 // indirect
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f
golang.org/x/net v0.0.0-20211216030914-fe4d6282115f // indirect
golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f // indirect
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e

View File

@ -21,6 +21,7 @@ package integration
import (
"bytes"
"context"
"os"
"strings"
"testing"
@ -31,7 +32,6 @@ import (
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -17,6 +17,7 @@
package integration
import (
"context"
"errors"
"fmt"
"testing"
@ -27,7 +28,6 @@ import (
"github.com/containerd/containerd/namespaces"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -17,6 +17,7 @@
package integration
import (
"context"
goruntime "runtime"
"sort"
"syscall"
@ -27,7 +28,6 @@ import (
"github.com/containerd/containerd/errdefs"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -17,6 +17,7 @@
package io
import (
"context"
"io"
"os"
"path/filepath"
@ -24,7 +25,6 @@ import (
"syscall"
"github.com/containerd/containerd/cio"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -20,11 +20,11 @@
package io
import (
"context"
"io"
"os"
"github.com/containerd/fifo"
"golang.org/x/net/context"
)
func openPipe(ctx context.Context, fn string, flag int, perm os.FileMode) (io.ReadWriteCloser, error) {

View File

@ -17,6 +17,7 @@
package io
import (
"context"
"fmt"
"io"
"net"
@ -24,7 +25,6 @@ import (
"sync"
winio "github.com/Microsoft/go-winio"
"golang.org/x/net/context"
)
type pipe struct {

View File

@ -17,12 +17,12 @@
package server
import (
"context"
"fmt"
"io"
"github.com/containerd/containerd"
"github.com/containerd/containerd/log"
"golang.org/x/net/context"
"k8s.io/client-go/tools/remotecommand"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"errors"
"fmt"
"path/filepath"
@ -32,7 +33,6 @@ import (
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
selinux "github.com/opencontainers/selinux/go-selinux"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
cio "github.com/containerd/containerd/pkg/cri/io"

View File

@ -17,9 +17,9 @@
package server
import (
"context"
"fmt"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -18,6 +18,7 @@ package server
import (
"bytes"
"context"
"fmt"
"io"
"syscall"
@ -28,7 +29,6 @@ import (
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/oci"
"golang.org/x/net/context"
"k8s.io/client-go/tools/remotecommand"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"

View File

@ -17,10 +17,9 @@
package server
import (
"context"
"time"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
containerstore "github.com/containerd/containerd/pkg/cri/store/container"

View File

@ -17,12 +17,12 @@
package server
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
containerstore "github.com/containerd/containerd/pkg/cri/store/container"

View File

@ -17,11 +17,10 @@
package server
import (
"context"
"errors"
"fmt"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"errors"
"fmt"
"time"
@ -26,7 +27,6 @@ import (
"github.com/containerd/containerd/log"
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"errors"
"fmt"
"io"
@ -29,7 +30,6 @@ import (
"github.com/containerd/nri"
v1 "github.com/containerd/nri/types/v1"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
cio "github.com/containerd/containerd/pkg/cri/io"

View File

@ -17,10 +17,10 @@
package server
import (
"context"
"fmt"
tasks "github.com/containerd/containerd/api/services/tasks/v1"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -17,11 +17,11 @@
package server
import (
"context"
"fmt"
tasks "github.com/containerd/containerd/api/services/tasks/v1"
"github.com/containerd/containerd/api/types"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
containerstore "github.com/containerd/containerd/pkg/cri/store/container"

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"encoding/json"
"fmt"
@ -24,7 +25,6 @@ import (
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -17,11 +17,11 @@
package server
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
containerstore "github.com/containerd/containerd/pkg/cri/store/container"

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"fmt"
"sync/atomic"
"syscall"
@ -29,7 +30,6 @@ import (
ctrdutil "github.com/containerd/containerd/pkg/cri/util"
"github.com/moby/sys/signal"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -17,11 +17,11 @@
package server
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
containerstore "github.com/containerd/containerd/pkg/cri/store/container"
)

View File

@ -20,6 +20,7 @@
package server
import (
"context"
gocontext "context"
"fmt"
@ -29,7 +30,6 @@ import (
"github.com/containerd/containerd/log"
"github.com/containerd/typeurl"
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
containerstore "github.com/containerd/containerd/pkg/cri/store/container"

View File

@ -17,10 +17,10 @@
package server
import (
"context"
"fmt"
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
criconfig "github.com/containerd/containerd/pkg/cri/config"

View File

@ -20,9 +20,9 @@
package server
import (
"context"
"fmt"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
containerstore "github.com/containerd/containerd/pkg/cri/store/container"

View File

@ -17,10 +17,10 @@
package server
import (
"context"
"fmt"
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
criconfig "github.com/containerd/containerd/pkg/cri/config"

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"errors"
"fmt"
"sync"
@ -34,7 +35,6 @@ import (
"github.com/containerd/typeurl"
gogotypes "github.com/gogo/protobuf/types"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
"k8s.io/utils/clock"
)

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"fmt"
"path"
"path/filepath"
@ -42,7 +43,6 @@ import (
runhcsoptions "github.com/Microsoft/hcsshim/cmd/containerd-shim-runhcs-v1/options"
imagedigest "github.com/opencontainers/go-digest"
"github.com/pelletier/go-toml"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -17,13 +17,13 @@
package server
import (
"context"
"os"
"path/filepath"
"testing"
"time"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
"golang.org/x/sys/unix"
)

View File

@ -17,7 +17,8 @@
package server
import (
"golang.org/x/net/context"
"context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -17,12 +17,12 @@
package server
import (
"context"
"testing"
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
imagestore "github.com/containerd/containerd/pkg/cri/store/image"

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"crypto/tls"
"crypto/x509"
"encoding/base64"
@ -40,7 +41,6 @@ import (
"github.com/containerd/imgcrypt"
"github.com/containerd/imgcrypt/images/encryption"
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
criconfig "github.com/containerd/containerd/pkg/cri/config"

View File

@ -17,12 +17,12 @@
package server
import (
"context"
"fmt"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/images"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"encoding/json"
"fmt"
@ -25,7 +26,6 @@ import (
imagestore "github.com/containerd/containerd/pkg/cri/store/image"
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -17,12 +17,12 @@
package server
import (
"context"
"testing"
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
imagestore "github.com/containerd/containerd/pkg/cri/store/image"

View File

@ -17,10 +17,9 @@
package server
import (
"context"
"time"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -17,12 +17,12 @@
package server
import (
"context"
"testing"
snapshot "github.com/containerd/containerd/snapshots"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
snapshotstore "github.com/containerd/containerd/pkg/cri/store/snapshot"

View File

@ -17,11 +17,11 @@
package server
import (
"context"
"errors"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/log"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
runtime_alpha "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"fmt"
"os"
"path/filepath"
@ -30,7 +31,6 @@ import (
"github.com/containerd/containerd/log"
"github.com/containerd/containerd/platforms"
"github.com/containerd/typeurl"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
cio "github.com/containerd/containerd/pkg/cri/io"

View File

@ -17,9 +17,9 @@
package server
import (
"context"
"time"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox"

View File

@ -17,10 +17,10 @@
package server
import (
"context"
"errors"
"fmt"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox"

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"fmt"
"io"
"net"
@ -24,7 +25,6 @@ import (
"github.com/containerd/containerd/log"
"github.com/containernetworking/plugins/pkg/ns"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -20,11 +20,11 @@
package server
import (
"context"
"fmt"
"io"
"github.com/containerd/containerd/errdefs"
"golang.org/x/net/context"
)
// portForward uses netns to enter the sandbox namespace, and forwards a stream inside the

View File

@ -18,10 +18,10 @@ package server
import (
"bytes"
"context"
"fmt"
"io"
"golang.org/x/net/context"
"k8s.io/utils/exec"
sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox"

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"fmt"
"time"
@ -25,7 +26,6 @@ import (
"github.com/containerd/containerd/log"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"encoding/json"
"errors"
"fmt"
@ -37,7 +38,6 @@ import (
"github.com/containerd/typeurl"
"github.com/davecgh/go-spew/spew"
"github.com/sirupsen/logrus"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
"github.com/containerd/containerd/pkg/cri/annotations"

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"net"
goruntime "runtime"
"testing"
@ -26,7 +27,6 @@ import (
imagespec "github.com/opencontainers/image-spec/specs-go/v1"
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
"github.com/containerd/containerd/pkg/cri/annotations"

View File

@ -17,9 +17,9 @@
package server
import (
"context"
"fmt"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -17,11 +17,11 @@
package server
import (
"context"
"fmt"
"time"
"github.com/containernetworking/plugins/pkg/ns"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
"github.com/containerd/cgroups"

View File

@ -17,10 +17,10 @@
package server
import (
"context"
"fmt"
sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -20,9 +20,9 @@
package server
import (
"context"
"fmt"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
"github.com/containerd/containerd/errdefs"

View File

@ -17,9 +17,9 @@
package server
import (
"context"
"fmt"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
"github.com/containerd/containerd/errdefs"

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"encoding/json"
"fmt"
goruntime "runtime"
@ -25,7 +26,6 @@ import (
"github.com/containerd/containerd/errdefs"
cni "github.com/containerd/go-cni"
runtimespec "github.com/opencontainers/runtime-spec/specs-go"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox"

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"errors"
"fmt"
"syscall"
@ -25,7 +26,6 @@ import (
eventtypes "github.com/containerd/containerd/api/events"
"github.com/containerd/containerd/errdefs"
"github.com/containerd/containerd/log"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox"

View File

@ -17,11 +17,11 @@
package server
import (
"context"
"testing"
"time"
"github.com/stretchr/testify/assert"
"golang.org/x/net/context"
sandboxstore "github.com/containerd/containerd/pkg/cri/store/sandbox"
)

View File

@ -17,12 +17,12 @@
package server
import (
"context"
"encoding/json"
"fmt"
goruntime "runtime"
"github.com/containerd/containerd/log"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"fmt"
"net"
"os"
@ -25,7 +26,6 @@ import (
"text/template"
"github.com/containerd/containerd/log"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
)

View File

@ -17,6 +17,7 @@
package server
import (
"context"
"errors"
"os"
"path/filepath"
@ -24,7 +25,6 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
criconfig "github.com/containerd/containerd/pkg/cri/config"

View File

@ -17,8 +17,9 @@
package server
import (
"context"
"github.com/containerd/containerd/version"
"golang.org/x/net/context"
runtime "k8s.io/cri-api/pkg/apis/runtime/v1"
runtime_alpha "k8s.io/cri-api/pkg/apis/runtime/v1alpha2"

View File

@ -17,10 +17,10 @@
package util
import (
"context"
"time"
"github.com/containerd/containerd/namespaces"
"golang.org/x/net/context"
"github.com/containerd/containerd/pkg/cri/constants"
)

View File

@ -29,7 +29,6 @@ import (
"github.com/containerd/containerd/log"
remoteserrors "github.com/containerd/containerd/remotes/errors"
"github.com/containerd/containerd/version"
"golang.org/x/net/context/ctxhttp"
)
var (
@ -115,7 +114,7 @@ func FetchTokenWithOAuth(ctx context.Context, client *http.Client, headers http.
form.Set("access_type", "offline")
}
req, err := http.NewRequest("POST", to.Realm, strings.NewReader(form.Encode()))
req, err := http.NewRequestWithContext(ctx, "POST", to.Realm, strings.NewReader(form.Encode()))
if err != nil {
return nil, err
}
@ -127,7 +126,7 @@ func FetchTokenWithOAuth(ctx context.Context, client *http.Client, headers http.
req.Header.Set("User-Agent", "containerd/"+version.Version)
}
resp, err := ctxhttp.Do(ctx, client, req)
resp, err := client.Do(req)
if err != nil {
return nil, err
}
@ -162,7 +161,7 @@ type FetchTokenResponse struct {
// FetchToken fetches a token using a GET request
func FetchToken(ctx context.Context, client *http.Client, headers http.Header, to TokenOptions) (*FetchTokenResponse, error) {
req, err := http.NewRequest("GET", to.Realm, nil)
req, err := http.NewRequestWithContext(ctx, "GET", to.Realm, nil)
if err != nil {
return nil, err
}
@ -194,7 +193,7 @@ func FetchToken(ctx context.Context, client *http.Client, headers http.Header, t
req.URL.RawQuery = reqParams.Encode()
resp, err := ctxhttp.Do(ctx, client, req)
resp, err := client.Do(req)
if err != nil {
return nil, err
}

View File

@ -36,7 +36,6 @@ import (
digest "github.com/opencontainers/go-digest"
ocispec "github.com/opencontainers/image-spec/specs-go/v1"
"github.com/sirupsen/logrus"
"golang.org/x/net/context/ctxhttp"
)
var (
@ -524,7 +523,7 @@ type request struct {
func (r *request) do(ctx context.Context) (*http.Response, error) {
u := r.host.Scheme + "://" + r.host.Host + r.path
req, err := http.NewRequest(r.method, u, nil)
req, err := http.NewRequestWithContext(ctx, r.method, u, nil)
if err != nil {
return nil, err
}
@ -566,7 +565,7 @@ func (r *request) do(ctx context.Context) (*http.Response, error) {
}
}
resp, err := ctxhttp.Do(ctx, client, req)
resp, err := client.Do(req)
if err != nil {
return nil, fmt.Errorf("failed to do request: %w", err)
}