Remove support for Go 1.13 and older (cont) (#4706)

This commit is contained in:
Easwar Swaminathan 2021-08-25 14:51:41 -07:00 committed by GitHub
parent 498743c19e
commit 712e8d4f57
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
80 changed files with 29 additions and 206 deletions

View File

@ -1,30 +0,0 @@
// +build go1.12
/*
*
* Copyright 2019 gRPC authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package credentials
import "crypto/tls"
// This init function adds cipher suite constants only defined in Go 1.12.
func init() {
cipherSuiteLookup[tls.TLS_AES_128_GCM_SHA256] = "TLS_AES_128_GCM_SHA256"
cipherSuiteLookup[tls.TLS_AES_256_GCM_SHA384] = "TLS_AES_256_GCM_SHA384"
cipherSuiteLookup[tls.TLS_CHACHA20_POLY1305_SHA256] = "TLS_CHACHA20_POLY1305_SHA256"
}

View File

@ -1,5 +1,3 @@
// +build go1.13
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.13
/*
*
* Copyright 2020 gRPC authors.

View File

@ -230,4 +230,7 @@ var cipherSuiteLookup = map[uint16]string{
tls.TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256: "TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256",
tls.TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305",
tls.TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305: "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305",
tls.TLS_AES_128_GCM_SHA256: "TLS_AES_128_GCM_SHA256",
tls.TLS_AES_256_GCM_SHA384: "TLS_AES_256_GCM_SHA384",
tls.TLS_CHACHA20_POLY1305_SHA256: "TLS_CHACHA20_POLY1305_SHA256",
}

View File

@ -1,5 +1,3 @@
// +build go1.13
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.
@ -24,7 +22,6 @@ import (
"context"
"fmt"
"io/ioutil"
"math/big"
"os"
"path"
"testing"
@ -32,7 +29,6 @@ import (
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"google.golang.org/grpc/credentials/tls/certprovider"
"google.golang.org/grpc/internal/grpctest"
"google.golang.org/grpc/internal/testutils"
@ -59,17 +55,15 @@ func Test(t *testing.T) {
}
func compareKeyMaterial(got, want *certprovider.KeyMaterial) error {
// x509.Certificate type defines an Equal() method, but does not check for
// nil. This has been fixed in
// https://github.com/golang/go/commit/89865f8ba64ccb27f439cce6daaa37c9aa38f351,
// but this is only available starting go1.14.
// TODO(easwars): Remove this check once we remove support for go1.13.
if (got.Certs == nil && want.Certs != nil) || (want.Certs == nil && got.Certs != nil) {
if len(got.Certs) != len(want.Certs) {
return fmt.Errorf("keyMaterial certs = %+v, want %+v", got, want)
}
if !cmp.Equal(got.Certs, want.Certs, cmp.AllowUnexported(big.Int{})) {
return fmt.Errorf("keyMaterial certs = %+v, want %+v", got, want)
for i := 0; i < len(got.Certs); i++ {
if !got.Certs[i].Leaf.Equal(want.Certs[i].Leaf) {
return fmt.Errorf("keyMaterial certs = %+v, want %+v", got, want)
}
}
// x509.CertPool contains only unexported fields some of which contain other
// unexported fields. So usage of cmp.AllowUnexported() or
// cmpopts.IgnoreUnexported() does not help us much here. Also, the standard

View File

@ -1,5 +1,3 @@
// +build go1.13
/*
*
* Copyright 2020 gRPC authors.
@ -27,10 +25,11 @@ import (
"errors"
"fmt"
"io/ioutil"
"reflect"
"testing"
"time"
"github.com/google/go-cmp/cmp"
"github.com/google/go-cmp/cmp/cmpopts"
"google.golang.org/grpc/internal/grpctest"
"google.golang.org/grpc/internal/testutils"
"google.golang.org/grpc/testdata"
@ -154,15 +153,23 @@ func readAndVerifyKeyMaterial(ctx context.Context, kmr kmReader, wantKM *KeyMate
}
func compareKeyMaterial(got, want *KeyMaterial) error {
// TODO(easwars): Remove all references to reflect.DeepEqual and use
// cmp.Equal instead. Currently, the later panics because x509.Certificate
// type defines an Equal method, but does not check for nil. This has been
// fixed in
// https://github.com/golang/go/commit/89865f8ba64ccb27f439cce6daaa37c9aa38f351,
// but this is only available starting go1.14. So, once we remove support
// for go1.13, we can make the switch.
if !reflect.DeepEqual(got, want) {
return fmt.Errorf("provider.KeyMaterial() = %+v, want %+v", got, want)
if len(got.Certs) != len(want.Certs) {
return fmt.Errorf("keyMaterial certs = %+v, want %+v", got, want)
}
for i := 0; i < len(got.Certs); i++ {
if !got.Certs[i].Leaf.Equal(want.Certs[i].Leaf) {
return fmt.Errorf("keyMaterial certs = %+v, want %+v", got, want)
}
}
// x509.CertPool contains only unexported fields some of which contain other
// unexported fields. So usage of cmp.AllowUnexported() or
// cmpopts.IgnoreUnexported() does not help us much here. Also, the standard
// library does not provide a way to compare CertPool values. Comparing the
// subjects field of the certs in the CertPool seems like a reasonable
// approach.
if gotR, wantR := got.Roots.Subjects(), want.Roots.Subjects(); !cmp.Equal(gotR, wantR, cmpopts.EquateEmpty()) {
return fmt.Errorf("keyMaterial roots = %v, want %v", gotR, wantR)
}
return nil
}

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -42,7 +42,6 @@ var goroutinesToIgnore = []string{
"runtime_mcall",
"(*loggingT).flushDaemon",
"goroutine in C code",
"httputil.DumpRequestOut", // TODO: Remove this once Go1.13 support is removed. https://github.com/golang/go/issues/37669.
}
// RegisterIgnoreGoroutine appends s into the ignore goroutine list. The

View File

@ -277,18 +277,13 @@ func (d *dnsResolver) lookupSRV() ([]resolver.Address, error) {
return newAddrs, nil
}
var filterError = func(err error) error {
func handleDNSError(err error, lookupType string) error {
if dnsErr, ok := err.(*net.DNSError); ok && !dnsErr.IsTimeout && !dnsErr.IsTemporary {
// Timeouts and temporary errors should be communicated to gRPC to
// attempt another DNS query (with backoff). Other errors should be
// suppressed (they may represent the absence of a TXT record).
return nil
}
return err
}
func handleDNSError(err error, lookupType string) error {
err = filterError(err)
if err != nil {
err = fmt.Errorf("dns: %v record lookup error: %v", lookupType, err)
logger.Info(err)

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2019 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.14
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
* Copyright 2020 gRPC authors.
*

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2021 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2021 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
* Copyright 2019 gRPC authors.
*

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
* Copyright 2020 gRPC authors.
*

View File

@ -1,6 +1,3 @@
//go:build go1.12
// +build go1.12
/*
* Copyright 2019 gRPC authors.
*

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
* Copyright 2021 gRPC authors.
*

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,6 +1,3 @@
//go:build go1.12
// +build go1.12
/*
*
* Copyright 2019 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2021 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2021 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
* Copyright 2019 gRPC authors.
*

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2019 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2021 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
* Copyright 2020 gRPC authors.
*

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
* Copyright 2019 gRPC authors.
*

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2021 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2021 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2021 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,4 +1,3 @@
// +build go1.12
// +build !386
/*

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2019 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2019 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2021 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2021 gRPC authors.

View File

@ -1,4 +1,3 @@
// +build go1.12
// +build !386
/*

View File

@ -1,4 +1,3 @@
// +build go1.12
// +build !386
/*

View File

@ -1,4 +1,3 @@
// +build go1.12
// +build !386
/*

View File

@ -1,4 +1,3 @@
// +build go1.13
// +build !386
/*

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2019 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2019 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2021 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2021 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2019 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2019 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2019 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2019 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2019 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.

View File

@ -1,5 +1,3 @@
// +build go1.12
/*
*
* Copyright 2020 gRPC authors.