mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-02 01:42:19 +00:00
Merge pull request #81947 from RainbowMango/pr_cleanup_staticcheck_for_client_p1
Cleanup client-go static analysis issues-phase 1 Kubernetes-commit: b131b4b4caa8f47df867174ac1eff251c5ad8328
This commit is contained in:
commit
065c7aba1f
2
Godeps/Godeps.json
generated
2
Godeps/Godeps.json
generated
@ -344,7 +344,7 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/api",
|
"ImportPath": "k8s.io/api",
|
||||||
"Rev": "4f4be656afa5"
|
"Rev": "40d3837b7e3d"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"ImportPath": "k8s.io/apimachinery",
|
"ImportPath": "k8s.io/apimachinery",
|
||||||
|
4
go.mod
4
go.mod
@ -26,7 +26,7 @@ require (
|
|||||||
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45
|
||||||
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c
|
golang.org/x/time v0.0.0-20181108054448-85acf8d2951c
|
||||||
google.golang.org/appengine v1.5.0 // indirect
|
google.golang.org/appengine v1.5.0 // indirect
|
||||||
k8s.io/api v0.0.0-20190828234856-4f4be656afa5
|
k8s.io/api v0.0.0-20190829034738-40d3837b7e3d
|
||||||
k8s.io/apimachinery v0.0.0-20190828114620-4147c925140e
|
k8s.io/apimachinery v0.0.0-20190828114620-4147c925140e
|
||||||
k8s.io/klog v0.4.0
|
k8s.io/klog v0.4.0
|
||||||
k8s.io/utils v0.0.0-20190801114015-581e00157fb1
|
k8s.io/utils v0.0.0-20190801114015-581e00157fb1
|
||||||
@ -41,6 +41,6 @@ replace (
|
|||||||
golang.org/x/sys => golang.org/x/sys v0.0.0-20190209173611-3b5209105503
|
golang.org/x/sys => golang.org/x/sys v0.0.0-20190209173611-3b5209105503
|
||||||
golang.org/x/text => golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db
|
golang.org/x/text => golang.org/x/text v0.3.1-0.20181227161524-e6919f6577db
|
||||||
golang.org/x/time => golang.org/x/time v0.0.0-20161028155119-f51c12702a4d
|
golang.org/x/time => golang.org/x/time v0.0.0-20161028155119-f51c12702a4d
|
||||||
k8s.io/api => k8s.io/api v0.0.0-20190828234856-4f4be656afa5
|
k8s.io/api => k8s.io/api v0.0.0-20190829034738-40d3837b7e3d
|
||||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190828114620-4147c925140e
|
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20190828114620-4147c925140e
|
||||||
)
|
)
|
||||||
|
2
go.sum
2
go.sum
@ -178,7 +178,7 @@ gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw=
|
|||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
k8s.io/api v0.0.0-20190828234856-4f4be656afa5/go.mod h1:Ik8tfB+q7IZDY6j3l3XfCxTl8s2knJz66H5FNYIj4oI=
|
k8s.io/api v0.0.0-20190829034738-40d3837b7e3d/go.mod h1:Ik8tfB+q7IZDY6j3l3XfCxTl8s2knJz66H5FNYIj4oI=
|
||||||
k8s.io/apimachinery v0.0.0-20190828114620-4147c925140e/go.mod h1:OOC7vMsHyCzra5xu6r1bRXkXMH76iww9BeHOAAJof4U=
|
k8s.io/apimachinery v0.0.0-20190828114620-4147c925140e/go.mod h1:OOC7vMsHyCzra5xu6r1bRXkXMH76iww9BeHOAAJof4U=
|
||||||
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
|
k8s.io/gengo v0.0.0-20190128074634-0689ccc1d7d6/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0=
|
||||||
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
|
k8s.io/klog v0.0.0-20181102134211-b9b56d5dfc92/go.mod h1:Gq+BEi5rUBO/HRz0bTSXDUcqjScdoY3a9IHpCEIOOfk=
|
||||||
|
@ -439,8 +439,8 @@ func (a ActionImpl) GetSubresource() string {
|
|||||||
return a.Subresource
|
return a.Subresource
|
||||||
}
|
}
|
||||||
func (a ActionImpl) Matches(verb, resource string) bool {
|
func (a ActionImpl) Matches(verb, resource string) bool {
|
||||||
return strings.ToLower(verb) == strings.ToLower(a.Verb) &&
|
return strings.EqualFold(verb, a.Verb) &&
|
||||||
strings.ToLower(resource) == strings.ToLower(a.Resource.Resource)
|
strings.EqualFold(resource, a.Resource.Resource)
|
||||||
}
|
}
|
||||||
func (a ActionImpl) DeepCopy() Action {
|
func (a ActionImpl) DeepCopy() Action {
|
||||||
ret := a
|
ret := a
|
||||||
|
@ -204,7 +204,8 @@ func TestWatchCallMultipleInvocation(t *testing.T) {
|
|||||||
event := <-w.ResultChan()
|
event := <-w.ResultChan()
|
||||||
accessor, err := meta.Accessor(event.Object)
|
accessor, err := meta.Accessor(event.Object)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("unexpected error: %v", err)
|
t.Errorf("unexpected error: %v", err)
|
||||||
|
break
|
||||||
}
|
}
|
||||||
assert.Equal(t, c.op, event.Type, "watch event mismatched")
|
assert.Equal(t, c.op, event.Type, "watch event mismatched")
|
||||||
assert.Equal(t, c.name, accessor.GetName(), "watched object mismatch")
|
assert.Equal(t, c.name, accessor.GetName(), "watched object mismatch")
|
||||||
|
@ -458,7 +458,6 @@ func TestCreateCleanDefaultCluster(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func TestCreateMissingContextNoDefault(t *testing.T) {
|
func TestCreateMissingContextNoDefault(t *testing.T) {
|
||||||
const expectedErrorContains = "Context was not found for specified context"
|
|
||||||
config := createValidTestConfig()
|
config := createValidTestConfig()
|
||||||
clientBuilder := NewNonInteractiveClientConfig(*config, "not-present", &ConfigOverrides{}, nil)
|
clientBuilder := NewNonInteractiveClientConfig(*config, "not-present", &ConfigOverrides{}, nil)
|
||||||
|
|
||||||
|
@ -24,19 +24,6 @@ import (
|
|||||||
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
clientcmdapi "k8s.io/client-go/tools/clientcmd/api"
|
||||||
)
|
)
|
||||||
|
|
||||||
type testLoader struct {
|
|
||||||
ClientConfigLoader
|
|
||||||
|
|
||||||
called bool
|
|
||||||
config *clientcmdapi.Config
|
|
||||||
err error
|
|
||||||
}
|
|
||||||
|
|
||||||
func (l *testLoader) Load() (*clientcmdapi.Config, error) {
|
|
||||||
l.called = true
|
|
||||||
return l.config, l.err
|
|
||||||
}
|
|
||||||
|
|
||||||
type testClientConfig struct {
|
type testClientConfig struct {
|
||||||
rawconfig *clientcmdapi.Config
|
rawconfig *clientcmdapi.Config
|
||||||
config *restclient.Config
|
config *restclient.Config
|
||||||
|
@ -185,9 +185,10 @@ func validateClusterInfo(clusterName string, clusterInfo clientcmdapi.Cluster) [
|
|||||||
}
|
}
|
||||||
if len(clusterInfo.CertificateAuthority) != 0 {
|
if len(clusterInfo.CertificateAuthority) != 0 {
|
||||||
clientCertCA, err := os.Open(clusterInfo.CertificateAuthority)
|
clientCertCA, err := os.Open(clusterInfo.CertificateAuthority)
|
||||||
defer clientCertCA.Close()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
validationErrors = append(validationErrors, fmt.Errorf("unable to read certificate-authority %v for %v due to %v", clusterInfo.CertificateAuthority, clusterName, err))
|
validationErrors = append(validationErrors, fmt.Errorf("unable to read certificate-authority %v for %v due to %v", clusterInfo.CertificateAuthority, clusterName, err))
|
||||||
|
} else {
|
||||||
|
defer clientCertCA.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -223,16 +224,18 @@ func validateAuthInfo(authInfoName string, authInfo clientcmdapi.AuthInfo) []err
|
|||||||
|
|
||||||
if len(authInfo.ClientCertificate) != 0 {
|
if len(authInfo.ClientCertificate) != 0 {
|
||||||
clientCertFile, err := os.Open(authInfo.ClientCertificate)
|
clientCertFile, err := os.Open(authInfo.ClientCertificate)
|
||||||
defer clientCertFile.Close()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
validationErrors = append(validationErrors, fmt.Errorf("unable to read client-cert %v for %v due to %v", authInfo.ClientCertificate, authInfoName, err))
|
validationErrors = append(validationErrors, fmt.Errorf("unable to read client-cert %v for %v due to %v", authInfo.ClientCertificate, authInfoName, err))
|
||||||
|
} else {
|
||||||
|
defer clientCertFile.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if len(authInfo.ClientKey) != 0 {
|
if len(authInfo.ClientKey) != 0 {
|
||||||
clientKeyFile, err := os.Open(authInfo.ClientKey)
|
clientKeyFile, err := os.Open(authInfo.ClientKey)
|
||||||
defer clientKeyFile.Close()
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
validationErrors = append(validationErrors, fmt.Errorf("unable to read client-key %v for %v due to %v", authInfo.ClientKey, authInfoName, err))
|
validationErrors = append(validationErrors, fmt.Errorf("unable to read client-key %v for %v due to %v", authInfo.ClientKey, authInfoName, err))
|
||||||
|
} else {
|
||||||
|
defer clientKeyFile.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -376,6 +376,9 @@ func TestGetPortsReturnsDynamicallyAssignedLocalPort(t *testing.T) {
|
|||||||
<-pf.Ready
|
<-pf.Ready
|
||||||
|
|
||||||
ports, err := pf.GetPorts()
|
ports, err := pf.GetPorts()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatalf("Failed to get ports. error: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
if len(ports) != 1 {
|
if len(ports) != 1 {
|
||||||
t.Fatalf("expected 1 port, got %d", len(ports))
|
t.Fatalf("expected 1 port, got %d", len(ports))
|
||||||
|
@ -35,7 +35,6 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
type fakePod struct {
|
type fakePod struct {
|
||||||
name string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (obj *fakePod) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKind }
|
func (obj *fakePod) GetObjectKind() schema.ObjectKind { return schema.EmptyObjectKind }
|
||||||
|
@ -37,7 +37,6 @@ type Parser struct {
|
|||||||
Name string
|
Name string
|
||||||
Root *ListNode
|
Root *ListNode
|
||||||
input string
|
input string
|
||||||
cur *ListNode
|
|
||||||
pos int
|
pos int
|
||||||
start int
|
start int
|
||||||
width int
|
width int
|
||||||
@ -186,8 +185,7 @@ func (p *Parser) parseInsideAction(cur *ListNode) error {
|
|||||||
func (p *Parser) parseRightDelim(cur *ListNode) error {
|
func (p *Parser) parseRightDelim(cur *ListNode) error {
|
||||||
p.pos += len(rightDelim)
|
p.pos += len(rightDelim)
|
||||||
p.consumeText()
|
p.consumeText()
|
||||||
cur = p.Root
|
return p.parseText(p.Root)
|
||||||
return p.parseText(cur)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// parseIdentifier scans build-in keywords, like "range" "end"
|
// parseIdentifier scans build-in keywords, like "range" "end"
|
||||||
@ -231,7 +229,7 @@ func (p *Parser) parseRecursive(cur *ListNode) error {
|
|||||||
func (p *Parser) parseNumber(cur *ListNode) error {
|
func (p *Parser) parseNumber(cur *ListNode) error {
|
||||||
r := p.peek()
|
r := p.peek()
|
||||||
if r == '+' || r == '-' {
|
if r == '+' || r == '-' {
|
||||||
r = p.next()
|
p.next()
|
||||||
}
|
}
|
||||||
for {
|
for {
|
||||||
r = p.next()
|
r = p.next()
|
||||||
|
Loading…
Reference in New Issue
Block a user