Consistently used stdlib context package (#4229)

This commit is contained in:
Roland Bracewell Shoemaker 2019-05-28 11:36:16 -07:00 committed by Daniel McCarney
parent e839042bae
commit 6f93942a04
50 changed files with 70 additions and 81 deletions

View File

@ -1,6 +1,7 @@
package bdns
import (
"context"
"fmt"
"math/rand"
"net"
@ -12,7 +13,6 @@ import (
"github.com/jmhodges/clock"
"github.com/miekg/dns"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/net/context"
"github.com/letsencrypt/boulder/metrics"
)

View File

@ -1,6 +1,7 @@
package bdns
import (
"context"
"errors"
"fmt"
"log"
@ -11,8 +12,6 @@ import (
"testing"
"time"
"golang.org/x/net/context"
"github.com/jmhodges/clock"
"github.com/letsencrypt/boulder/metrics"
"github.com/letsencrypt/boulder/test"
@ -213,7 +212,8 @@ func serveLoopResolver(stopChan chan bool) {
func pollServer() {
backoff := time.Duration(200 * time.Millisecond)
ctx, _ := context.WithTimeout(context.Background(), time.Duration(5*time.Second))
ctx, cancel := context.WithTimeout(context.Background(), time.Duration(5*time.Second))
defer cancel()
ticker := time.NewTicker(backoff)
for {
@ -622,7 +622,8 @@ func TestRetry(t *testing.T) {
}
dr.dnsClient = &testExchanger{errs: []error{isTempErr, isTempErr, nil}}
ctx, _ = context.WithTimeout(context.Background(), -10*time.Hour)
ctx, cancel = context.WithTimeout(context.Background(), -10*time.Hour)
defer cancel()
_, err = dr.LookupTXT(ctx, "example.com")
if err == nil ||
err.Error() != "DNS problem: query timed out looking up TXT for example.com" {

View File

@ -1,13 +1,13 @@
package bdns
import (
"context"
"errors"
"fmt"
"net"
"os"
"github.com/miekg/dns"
"golang.org/x/net/context"
)
// MockDNSClient is a mock

View File

@ -1,11 +1,11 @@
package bdns
import (
"context"
"fmt"
"net"
"github.com/miekg/dns"
"golang.org/x/net/context"
)
// DNSError wraps a DNS error with various relevant information

View File

@ -1,12 +1,12 @@
package bdns
import (
"context"
"errors"
"net"
"testing"
"github.com/miekg/dns"
"golang.org/x/net/context"
)
func TestDNSError(t *testing.T) {

View File

@ -2,6 +2,7 @@ package ca
import (
"bytes"
"context"
"crypto"
"crypto/ecdsa"
"crypto/rand"
@ -27,7 +28,6 @@ import (
cttls "github.com/google/certificate-transparency-go/tls"
"github.com/jmhodges/clock"
"github.com/miekg/pkcs11"
"golang.org/x/net/context"
"github.com/letsencrypt/boulder/ca/config"
caPB "github.com/letsencrypt/boulder/ca/proto"

View File

@ -1,6 +1,7 @@
package ca
import (
"context"
"crypto"
"crypto/ecdsa"
"crypto/elliptic"
@ -26,7 +27,6 @@ import (
"github.com/jmhodges/clock"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/crypto/ocsp"
"golang.org/x/net/context"
"github.com/letsencrypt/boulder/ca/config"
caPB "github.com/letsencrypt/boulder/ca/proto"

View File

@ -1,6 +1,7 @@
package main
import (
"context"
"crypto/x509"
"database/sql"
"flag"
@ -10,7 +11,6 @@ import (
"sort"
"strconv"
"golang.org/x/net/context"
"gopkg.in/go-gorp/gorp.v2"
"github.com/letsencrypt/boulder/cmd"

View File

@ -1,6 +1,7 @@
package main
import (
"context"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
@ -15,7 +16,6 @@ import (
"time"
"github.com/jmhodges/clock"
"golang.org/x/net/context"
"github.com/letsencrypt/boulder/core"
blog "github.com/letsencrypt/boulder/log"

View File

@ -2,6 +2,7 @@ package main
import (
"bytes"
"context"
"crypto/x509"
"errors"
"flag"
@ -16,8 +17,6 @@ import (
"text/template"
"time"
"golang.org/x/net/context"
"github.com/jmhodges/clock"
"gopkg.in/go-gorp/gorp.v2"

View File

@ -1,6 +1,7 @@
package main
import (
"context"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
@ -15,14 +16,7 @@ import (
"text/template"
"time"
"golang.org/x/net/context"
"github.com/jmhodges/clock"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_model/go"
"gopkg.in/go-gorp/gorp.v2"
"gopkg.in/square/go-jose.v2"
"github.com/letsencrypt/boulder/core"
berrors "github.com/letsencrypt/boulder/errors"
blog "github.com/letsencrypt/boulder/log"
@ -32,6 +26,10 @@ import (
"github.com/letsencrypt/boulder/sa/satest"
"github.com/letsencrypt/boulder/test"
"github.com/letsencrypt/boulder/test/vars"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_model/go"
"gopkg.in/go-gorp/gorp.v2"
"gopkg.in/square/go-jose.v2"
)
func bigIntFromB64(b64 string) *big.Int {

View File

@ -1,6 +1,7 @@
package main
import (
"context"
"database/sql"
"errors"
"fmt"
@ -15,7 +16,6 @@ import (
"github.com/letsencrypt/boulder/sa/satest"
"github.com/letsencrypt/boulder/test"
"github.com/letsencrypt/boulder/test/vars"
"golang.org/x/net/context"
)
func TestPurgeAuthzs(t *testing.T) {

View File

@ -1,6 +1,7 @@
package main
import (
"context"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
@ -15,8 +16,6 @@ import (
"testing"
"time"
"golang.org/x/net/context"
"github.com/jmhodges/clock"
"github.com/letsencrypt/boulder/core"
blog "github.com/letsencrypt/boulder/log"

View File

@ -1,6 +1,7 @@
package main
import (
"context"
"crypto/tls"
"crypto/x509"
"database/sql"
@ -22,7 +23,6 @@ import (
"github.com/letsencrypt/boulder/sa"
sapb "github.com/letsencrypt/boulder/sa/proto"
"golang.org/x/crypto/ocsp"
"golang.org/x/net/context"
)
/*

View File

@ -1,6 +1,7 @@
package main
import (
"context"
"errors"
"fmt"
"testing"
@ -18,7 +19,6 @@ import (
"github.com/letsencrypt/boulder/sa/satest"
"github.com/letsencrypt/boulder/test"
"github.com/letsencrypt/boulder/test/vars"
"golang.org/x/net/context"
"gopkg.in/go-gorp/gorp.v2"
)

View File

@ -1,6 +1,7 @@
package main
import (
"context"
"crypto/x509"
"encoding/hex"
"encoding/json"
@ -13,8 +14,6 @@ import (
"strings"
"time"
"golang.org/x/net/context"
"github.com/letsencrypt/boulder/cmd"
"github.com/letsencrypt/boulder/core"
berrors "github.com/letsencrypt/boulder/errors"

View File

@ -1,16 +1,14 @@
package main
import (
"context"
"crypto/x509"
"encoding/hex"
"fmt"
"testing"
"time"
"golang.org/x/net/context"
"github.com/jmhodges/clock"
"github.com/letsencrypt/boulder/core"
berrors "github.com/letsencrypt/boulder/errors"
blog "github.com/letsencrypt/boulder/log"

View File

@ -1,12 +1,12 @@
package core
import (
"context"
"crypto/x509"
"net"
"net/http"
"time"
"golang.org/x/net/context"
jose "gopkg.in/square/go-jose.v2"
caPB "github.com/letsencrypt/boulder/ca/proto"

View File

@ -1,6 +1,6 @@
package core
import "golang.org/x/net/context"
import "context"
// ValidationAuthority defines the public interface for the Boulder VA
type ValidationAuthority interface {

View File

@ -7,10 +7,10 @@
package grpc
import (
"context"
"errors"
"time"
"golang.org/x/net/context"
"google.golang.org/grpc"
caPB "github.com/letsencrypt/boulder/ca/proto"

View File

@ -1,13 +1,13 @@
package creds
import (
"context"
"crypto/tls"
"crypto/x509"
"errors"
"fmt"
"net"
"golang.org/x/net/context"
"google.golang.org/grpc/credentials"
)

View File

@ -1,10 +1,10 @@
package grpc
import (
"context"
"errors"
"strconv"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"

View File

@ -1,12 +1,12 @@
package grpc
import (
"context"
"fmt"
"net"
"testing"
"time"
"golang.org/x/net/context"
"google.golang.org/grpc"
"github.com/jmhodges/clock"

View File

@ -1,13 +1,13 @@
package grpc
import (
"context"
"strconv"
"strings"
"time"
"github.com/jmhodges/clock"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"

View File

@ -1,6 +1,7 @@
package grpc
import (
"context"
"errors"
"log"
"net"
@ -12,7 +13,6 @@ import (
"github.com/jmhodges/clock"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/net/context"
"google.golang.org/grpc"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/metadata"

View File

@ -7,7 +7,7 @@
package grpc
import (
"golang.org/x/net/context"
"context"
"github.com/letsencrypt/boulder/publisher"
pubpb "github.com/letsencrypt/boulder/publisher/proto"

View File

@ -7,10 +7,9 @@
package grpc
import (
"context"
"crypto/x509"
"golang.org/x/net/context"
"github.com/letsencrypt/boulder/core"
corepb "github.com/letsencrypt/boulder/core/proto"
rapb "github.com/letsencrypt/boulder/ra/proto"

View File

@ -7,10 +7,10 @@
package grpc
import (
"context"
"net"
"time"
"golang.org/x/net/context"
"gopkg.in/square/go-jose.v2"
"github.com/letsencrypt/boulder/core"

View File

@ -7,7 +7,8 @@
package grpc
import (
"golang.org/x/net/context"
"context"
ggrpc "google.golang.org/grpc"
"github.com/letsencrypt/boulder/core"

View File

@ -1,12 +1,11 @@
package mocks
import (
"context"
"crypto/x509"
"encoding/pem"
"fmt"
"golang.org/x/net/context"
caPB "github.com/letsencrypt/boulder/ca/proto"
"github.com/letsencrypt/boulder/core"
"github.com/letsencrypt/boulder/revocation"

View File

@ -1,6 +1,7 @@
package mocks
import (
"context"
"crypto/x509"
"encoding/pem"
"errors"
@ -11,7 +12,6 @@ import (
"time"
"github.com/jmhodges/clock"
"golang.org/x/net/context"
"gopkg.in/square/go-jose.v2"
"github.com/letsencrypt/boulder/core"

View File

@ -1,6 +1,7 @@
package publisher
import (
"context"
"crypto/ecdsa"
"crypto/rand"
"crypto/sha256"
@ -22,7 +23,6 @@ import (
"github.com/google/certificate-transparency-go/tls"
cttls "github.com/google/certificate-transparency-go/tls"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/net/context"
"github.com/letsencrypt/boulder/canceled"
"github.com/letsencrypt/boulder/core"

View File

@ -1,6 +1,7 @@
package publisher
import (
"context"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
@ -23,7 +24,6 @@ import (
"time"
ct "github.com/google/certificate-transparency-go"
"golang.org/x/net/context"
blog "github.com/letsencrypt/boulder/log"
"github.com/letsencrypt/boulder/metrics"

View File

@ -1,6 +1,7 @@
package ra
import (
"context"
"crypto/x509"
"fmt"
"net"
@ -38,7 +39,6 @@ import (
"github.com/letsencrypt/boulder/web"
"github.com/prometheus/client_golang/prometheus"
"github.com/weppos/publicsuffix-go/publicsuffix"
"golang.org/x/net/context"
grpc "google.golang.org/grpc"
)

View File

@ -1,6 +1,7 @@
package ra
import (
"context"
"crypto/ecdsa"
"crypto/elliptic"
"crypto/rand"
@ -55,7 +56,6 @@ import (
vaPB "github.com/letsencrypt/boulder/va/proto"
"github.com/prometheus/client_golang/prometheus"
"github.com/weppos/publicsuffix-go/publicsuffix"
"golang.org/x/net/context"
"google.golang.org/grpc"
jose "gopkg.in/square/go-jose.v2"
)

View File

@ -1,12 +1,12 @@
package sa
import (
"context"
"database/sql"
"strings"
"time"
"github.com/weppos/publicsuffix-go/publicsuffix"
"golang.org/x/net/context"
)
// baseDomain returns the eTLD+1 of a domain name for the purpose of rate

View File

@ -1,11 +1,10 @@
package sa
import (
"context"
"fmt"
"testing"
"time"
"golang.org/x/net/context"
)
func TestFasterRateLimit(t *testing.T) {

View File

@ -1,6 +1,7 @@
package sa
import (
"context"
"crypto/sha256"
"crypto/x509"
"database/sql"
@ -13,7 +14,6 @@ import (
"time"
"github.com/jmhodges/clock"
"golang.org/x/net/context"
"gopkg.in/go-gorp/gorp.v2"
jose "gopkg.in/square/go-jose.v2"

View File

@ -2,6 +2,7 @@ package sa
import (
"bytes"
"context"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
@ -18,27 +19,23 @@ import (
"testing"
"time"
"github.com/letsencrypt/boulder/identifier"
"github.com/letsencrypt/boulder/probs"
"golang.org/x/net/context"
"github.com/jmhodges/clock"
gorp "gopkg.in/go-gorp/gorp.v2"
jose "gopkg.in/square/go-jose.v2"
"github.com/letsencrypt/boulder/core"
corepb "github.com/letsencrypt/boulder/core/proto"
berrors "github.com/letsencrypt/boulder/errors"
"github.com/letsencrypt/boulder/features"
bgrpc "github.com/letsencrypt/boulder/grpc"
"github.com/letsencrypt/boulder/identifier"
blog "github.com/letsencrypt/boulder/log"
"github.com/letsencrypt/boulder/metrics"
"github.com/letsencrypt/boulder/probs"
"github.com/letsencrypt/boulder/revocation"
sapb "github.com/letsencrypt/boulder/sa/proto"
"github.com/letsencrypt/boulder/sa/satest"
"github.com/letsencrypt/boulder/test"
"github.com/letsencrypt/boulder/test/vars"
gorp "gopkg.in/go-gorp/gorp.v2"
jose "gopkg.in/square/go-jose.v2"
)
var log = blog.UseMock()

View File

@ -1,13 +1,12 @@
package satest
import (
"context"
"encoding/json"
"net"
"testing"
"time"
"golang.org/x/net/context"
"github.com/letsencrypt/boulder/core"
jose "gopkg.in/square/go-jose.v2"
)

View File

@ -1,6 +1,7 @@
package va
import (
"context"
"encoding/json"
"fmt"
"strings"
@ -12,7 +13,6 @@ import (
"github.com/letsencrypt/boulder/probs"
vapb "github.com/letsencrypt/boulder/va/proto"
"github.com/miekg/dns"
"golang.org/x/net/context"
)
type caaParams struct {

View File

@ -2,6 +2,7 @@ package va
import (
"bytes"
"context"
"crypto/tls"
"encoding/json"
"errors"
@ -28,7 +29,6 @@ import (
"github.com/letsencrypt/boulder/metrics"
"github.com/letsencrypt/boulder/probs"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/net/context"
)
var (

View File

@ -1,6 +1,7 @@
package va
import (
"context"
"crypto/rsa"
"encoding/base64"
"errors"
@ -27,7 +28,6 @@ import (
"github.com/letsencrypt/boulder/probs"
"github.com/letsencrypt/boulder/test"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/net/context"
"gopkg.in/square/go-jose.v2"
)
@ -63,8 +63,12 @@ func dnsi(hostname string) identifier.ACMEIdentifier {
var ctx context.Context
func init() {
ctx, _ = context.WithTimeout(context.Background(), 10*time.Minute)
func TestMain(m *testing.M) {
var cancel context.CancelFunc
ctx, cancel = context.WithTimeout(context.Background(), 10*time.Minute)
ret := m.Run()
cancel()
os.Exit(ret)
}
var accountURIPrefixes = []string{"http://boulder:4000/acme/reg/"}

2
vendor/modules.txt vendored
View File

@ -108,11 +108,11 @@ golang.org/x/crypto/cryptobyte
golang.org/x/crypto/cryptobyte/asn1
golang.org/x/crypto/pkcs12/internal/rc2
# golang.org/x/net v0.0.0-20190415214537-1da14a5a36f2
golang.org/x/net/context
golang.org/x/net/idna
golang.org/x/net/trace
golang.org/x/net/ipv4
golang.org/x/net/ipv6
golang.org/x/net/context
golang.org/x/net/context/ctxhttp
golang.org/x/net/internal/timeseries
golang.org/x/net/http2

View File

@ -1,14 +1,13 @@
package web
import (
"context"
"encoding/json"
"fmt"
"net"
"net/http"
"time"
"golang.org/x/net/context"
blog "github.com/letsencrypt/boulder/log"
)

View File

@ -2,6 +2,7 @@ package wfe
import (
"bytes"
"context"
"crypto/x509"
"encoding/hex"
"encoding/json"
@ -18,7 +19,6 @@ import (
"github.com/jmhodges/clock"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/net/context"
jose "gopkg.in/square/go-jose.v2"
"github.com/letsencrypt/boulder/core"

View File

@ -2,6 +2,7 @@ package wfe
import (
"bytes"
"context"
"crypto/ecdsa"
"crypto/rsa"
"crypto/x509"
@ -20,8 +21,6 @@ import (
"testing"
"time"
"gopkg.in/square/go-jose.v2"
"github.com/jmhodges/clock"
"github.com/letsencrypt/boulder/core"
corepb "github.com/letsencrypt/boulder/core/proto"
@ -41,8 +40,8 @@ import (
"github.com/letsencrypt/boulder/test"
vaPB "github.com/letsencrypt/boulder/va/proto"
"github.com/letsencrypt/boulder/web"
"golang.org/x/net/context"
"google.golang.org/grpc"
"gopkg.in/square/go-jose.v2"
)
const (

View File

@ -1,6 +1,7 @@
package wfe2
import (
"context"
"crypto"
"crypto/ecdsa"
"crypto/elliptic"
@ -9,8 +10,6 @@ import (
"net/http"
"testing"
"golang.org/x/net/context"
"github.com/letsencrypt/boulder/core"
"github.com/letsencrypt/boulder/mocks"
"github.com/letsencrypt/boulder/probs"

View File

@ -2,6 +2,7 @@ package wfe2
import (
"bytes"
"context"
"crypto/x509"
"encoding/hex"
"encoding/json"
@ -33,7 +34,6 @@ import (
sapb "github.com/letsencrypt/boulder/sa/proto"
"github.com/letsencrypt/boulder/web"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/net/context"
jose "gopkg.in/square/go-jose.v2"
)

View File

@ -2,6 +2,7 @@ package wfe2
import (
"bytes"
"context"
"crypto"
"crypto/ecdsa"
"crypto/rand"
@ -23,7 +24,6 @@ import (
"time"
"github.com/jmhodges/clock"
"golang.org/x/net/context"
"gopkg.in/square/go-jose.v2"
"github.com/letsencrypt/boulder/core"