Merge pull request #99371 from tiloso/staticcheck-apimachinery-util

Fix staticcheck in k8s.io/apimachinery/pkg/util
This commit is contained in:
Kubernetes Prow Robot 2021-05-21 07:38:46 -07:00 committed by GitHub
commit 04a0dcec8d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 18 additions and 11 deletions

View File

@ -1,11 +1,6 @@
cluster/images/etcd/migrate
vendor/k8s.io/apimachinery/pkg/api/apitesting/roundtrip
vendor/k8s.io/apimachinery/pkg/apis/meta/v1/validation
vendor/k8s.io/apimachinery/pkg/util/httpstream/spdy
vendor/k8s.io/apimachinery/pkg/util/net
vendor/k8s.io/apimachinery/pkg/util/sets/types
vendor/k8s.io/apimachinery/pkg/util/strategicpatch
vendor/k8s.io/apimachinery/pkg/util/wait
vendor/k8s.io/apiserver/pkg/endpoints/filters
vendor/k8s.io/apiserver/pkg/endpoints/metrics
vendor/k8s.io/apiserver/pkg/server/dynamiccertificates

View File

@ -183,8 +183,11 @@ func (s *SpdyRoundTripper) dial(req *http.Request) (net.Conn, error) {
return nil, err
}
//lint:ignore SA1019 ignore deprecated httputil.NewProxyClientConn
proxyClientConn := httputil.NewProxyClientConn(proxyDialConn, nil)
_, err = proxyClientConn.Do(&proxyReq)
//lint:ignore SA1019 ignore deprecated httputil.ErrPersistEOF: it might be
// returned from the invocation of proxyClientConn.Do
if err != nil && err != httputil.ErrPersistEOF {
return nil, err
}

View File

@ -113,6 +113,7 @@ func SetOldTransportDefaults(t *http.Transport) *http.Transport {
t.Proxy = NewProxierWithNoProxyCIDR(http.ProxyFromEnvironment)
}
// If no custom dialer is set, use the default context dialer
//lint:file-ignore SA1019 Keep supporting deprecated Dial method of custom transports
if t.DialContext == nil && t.Dial == nil {
t.DialContext = defaultTransport.DialContext
}

View File

@ -20,6 +20,7 @@ limitations under the License.
package types
//go:generate set-gen -i k8s.io/kubernetes/pkg/util/sets/types
//lint:file-ignore U1000 Ignore unused fields
type ReferenceSetTypes struct {
// These types all cause files to be generated.

View File

@ -987,10 +987,10 @@ func validatePatchWithSetOrderList(patchList, setOrderList interface{}, mergeKey
return nil
}
var nonDeleteList, toDeleteList []interface{}
var nonDeleteList []interface{}
var err error
if len(mergeKey) > 0 {
nonDeleteList, toDeleteList, err = extractToDeleteItems(typedPatchList)
nonDeleteList, _, err = extractToDeleteItems(typedPatchList)
if err != nil {
return err
}
@ -1018,7 +1018,6 @@ func validatePatchWithSetOrderList(patchList, setOrderList interface{}, mergeKey
if patchIndex < len(nonDeleteList) && setOrderIndex >= len(typedSetOrderList) {
return fmt.Errorf("The order in patch list:\n%v\n doesn't match %s list:\n%v\n", typedPatchList, setElementOrderDirectivePrefix, setOrderList)
}
typedPatchList = append(nonDeleteList, toDeleteList...)
return nil
}

View File

@ -422,6 +422,7 @@ func TestPollImmediateError(t *testing.T) {
func TestPollForever(t *testing.T) {
ch := make(chan struct{})
errc := make(chan error, 1)
done := make(chan struct{}, 1)
complete := make(chan struct{})
go func() {
@ -436,7 +437,7 @@ func TestPollForever(t *testing.T) {
})
if err := PollInfinite(time.Microsecond, f); err != nil {
t.Fatalf("unexpected error %v", err)
errc <- fmt.Errorf("unexpected error %v", err)
}
close(ch)
@ -451,7 +452,10 @@ func TestPollForever(t *testing.T) {
select {
case _, open := <-ch:
if !open {
t.Fatalf("did not expect channel to be closed")
if len(errc) != 0 {
t.Fatalf("did not expect channel to be closed, %v", <-errc)
}
t.Fatal("did not expect channel to be closed")
}
case <-time.After(ForeverTestTimeout):
t.Fatalf("channel did not return at least once within the poll interval")
@ -467,9 +471,13 @@ func TestPollForever(t *testing.T) {
return
}
}
t.Fatalf("expected closed channel after two iterations")
t.Error("expected closed channel after two iterations")
}()
<-complete
if len(errc) != 0 {
t.Fatal(<-errc)
}
}
func TestWaitFor(t *testing.T) {