mirror of
https://github.com/kubernetes/kubectl.git
synced 2026-05-28 04:35:50 -04:00
Merge pull request #116166 from pohly/test-go-vet
fix "go vet" issues, check as part of golangci-lint Kubernetes-commit: ff735dff85367c2a096c4065b8b3c1fbbeecabc4
This commit is contained in:
commit
187e5c1218
7 changed files with 31 additions and 30 deletions
16
go.mod
16
go.mod
|
|
@ -31,10 +31,10 @@ require (
|
|||
golang.org/x/sys v0.5.0
|
||||
gopkg.in/yaml.v2 v2.4.0
|
||||
k8s.io/api v0.0.0-20230303235756-fc1b77c3f4ab
|
||||
k8s.io/apimachinery v0.0.0-20230303235433-5b1cff80ea06
|
||||
k8s.io/cli-runtime v0.0.0-20230304005623-a18cae8f8d12
|
||||
k8s.io/client-go v0.0.0-20230304000202-d39f8291fc57
|
||||
k8s.io/component-base v0.0.0-20230304000858-ddedd087ad1e
|
||||
k8s.io/apimachinery v0.0.0-20230303235435-f357b1fa74b7
|
||||
k8s.io/cli-runtime v0.0.0-20230304005626-589dfd9f4f89
|
||||
k8s.io/client-go v0.0.0-20230304000204-06ad6b391d35
|
||||
k8s.io/component-base v0.0.0-20230304000900-3bf8af940f29
|
||||
k8s.io/component-helpers v0.0.0-20230304001010-94a6fd9a7905
|
||||
k8s.io/klog/v2 v2.90.1
|
||||
k8s.io/kube-openapi v0.0.0-20230303024457-afdc3dddf62d
|
||||
|
|
@ -92,11 +92,11 @@ require (
|
|||
|
||||
replace (
|
||||
k8s.io/api => k8s.io/api v0.0.0-20230303235756-fc1b77c3f4ab
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20230303235433-5b1cff80ea06
|
||||
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20230304005623-a18cae8f8d12
|
||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20230304000202-d39f8291fc57
|
||||
k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20230303235435-f357b1fa74b7
|
||||
k8s.io/cli-runtime => k8s.io/cli-runtime v0.0.0-20230304005626-589dfd9f4f89
|
||||
k8s.io/client-go => k8s.io/client-go v0.0.0-20230304000204-06ad6b391d35
|
||||
k8s.io/code-generator => k8s.io/code-generator v0.0.0-20230303235006-4400d5f574d7
|
||||
k8s.io/component-base => k8s.io/component-base v0.0.0-20230304000858-ddedd087ad1e
|
||||
k8s.io/component-base => k8s.io/component-base v0.0.0-20230304000900-3bf8af940f29
|
||||
k8s.io/component-helpers => k8s.io/component-helpers v0.0.0-20230304001010-94a6fd9a7905
|
||||
k8s.io/metrics => k8s.io/metrics v0.0.0-20230304005443-556c18548e76
|
||||
)
|
||||
|
|
|
|||
16
go.sum
16
go.sum
|
|
@ -533,14 +533,14 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9
|
|||
honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k=
|
||||
k8s.io/api v0.0.0-20230303235756-fc1b77c3f4ab h1:peGI8OxM+LOJxG8FqX/y6BVELxehZ4fDq9cm1a5Qaz0=
|
||||
k8s.io/api v0.0.0-20230303235756-fc1b77c3f4ab/go.mod h1:ihVCDKSD6f+H/yGKVpY9HSgpw4StgSvrI3dbK05M9a8=
|
||||
k8s.io/apimachinery v0.0.0-20230303235433-5b1cff80ea06 h1:d8NkMUaqPq1ghtNIScF2RIPgGhSu+scUUrxsinWDThg=
|
||||
k8s.io/apimachinery v0.0.0-20230303235433-5b1cff80ea06/go.mod h1:jlJwObMa4oKAEOMnAeEaqeiM+Fwd/CbAwNyQ7OaEwS0=
|
||||
k8s.io/cli-runtime v0.0.0-20230304005623-a18cae8f8d12 h1:DkWuB43ljW1vn3TdzCNiSkXuMnVIKmk7FhGDYIvhEhs=
|
||||
k8s.io/cli-runtime v0.0.0-20230304005623-a18cae8f8d12/go.mod h1:MnDsNvMiAsj77VNdmB8sl+ZGymumip5rKXZcmrZsCMc=
|
||||
k8s.io/client-go v0.0.0-20230304000202-d39f8291fc57 h1:1poxm/0OkMXI+YWheufVMRgXiYBW3Kq2PM+/sHDqvvg=
|
||||
k8s.io/client-go v0.0.0-20230304000202-d39f8291fc57/go.mod h1:j1Eg/I6nZcgoThl8TATyMIg+1xoKMW0D3JnR2VnBm6c=
|
||||
k8s.io/component-base v0.0.0-20230304000858-ddedd087ad1e h1:PuygjVw/jQzOBSJ1s6xv1oA7Dc5ZvEDxfpS/5k8ZMHQ=
|
||||
k8s.io/component-base v0.0.0-20230304000858-ddedd087ad1e/go.mod h1:vldhe13R/1pbgyrY1SwSHHwol4MWZNyU0J5mCvBECfA=
|
||||
k8s.io/apimachinery v0.0.0-20230303235435-f357b1fa74b7 h1:YN43Lvs3Pj9iQmuWGojeBiFdz1mkrxe0EZn7Ba3TMpQ=
|
||||
k8s.io/apimachinery v0.0.0-20230303235435-f357b1fa74b7/go.mod h1:jlJwObMa4oKAEOMnAeEaqeiM+Fwd/CbAwNyQ7OaEwS0=
|
||||
k8s.io/cli-runtime v0.0.0-20230304005626-589dfd9f4f89 h1:bciXN3+NGFObUua20Br9ZtwDK6d7d0eBzbTVYkD0VuY=
|
||||
k8s.io/cli-runtime v0.0.0-20230304005626-589dfd9f4f89/go.mod h1:e7I39Im546cUQ8NG19UqCv+EBDTmEFFCSTYRim9Puhk=
|
||||
k8s.io/client-go v0.0.0-20230304000204-06ad6b391d35 h1:9uwNzISbibeQwpbp/a9OFj2Zk98INi4pJfByXGK5nGQ=
|
||||
k8s.io/client-go v0.0.0-20230304000204-06ad6b391d35/go.mod h1:D9bGnWQ1292GhAR0f2uumanvVdOHddJlD+7OlyUorYM=
|
||||
k8s.io/component-base v0.0.0-20230304000900-3bf8af940f29 h1:26PuXs5/GsCX5EPltZN9KjZqkW/EwYHaebfNmIK3Wxc=
|
||||
k8s.io/component-base v0.0.0-20230304000900-3bf8af940f29/go.mod h1:1aFiUfjXiy45a88xJmd/nSkReVCoyShEHbGmWJQbp2Q=
|
||||
k8s.io/component-helpers v0.0.0-20230304001010-94a6fd9a7905 h1:kHWUeYs8Mc9IQpqULpPd2j8G6cqqf/fz5wzvqcYCdSQ=
|
||||
k8s.io/component-helpers v0.0.0-20230304001010-94a6fd9a7905/go.mod h1:IrR1jWfgEwsQ2rBPvbuwL8bmskaLy5lDQ8mIPnPXcbA=
|
||||
k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw=
|
||||
|
|
|
|||
|
|
@ -448,7 +448,7 @@ func TestGeneratePodCopyWithDebugContainer(t *testing.T) {
|
|||
"test": "test",
|
||||
},
|
||||
ResourceVersion: "1",
|
||||
CreationTimestamp: metav1.Time{time.Now()},
|
||||
CreationTimestamp: metav1.Time{Time: time.Now()},
|
||||
},
|
||||
Spec: corev1.PodSpec{
|
||||
Containers: []corev1.Container{
|
||||
|
|
|
|||
|
|
@ -338,7 +338,7 @@ func TestCheckInvalidErr(t *testing.T) {
|
|||
DefaultErrorExitCode,
|
||||
},
|
||||
{
|
||||
&errors.StatusError{metav1.Status{
|
||||
&errors.StatusError{ErrStatus: metav1.Status{
|
||||
Status: metav1.StatusFailure,
|
||||
Code: http.StatusUnprocessableEntity,
|
||||
Reason: metav1.StatusReasonInvalid,
|
||||
|
|
@ -349,7 +349,7 @@ func TestCheckInvalidErr(t *testing.T) {
|
|||
},
|
||||
// invalid error that that includes a message but no details
|
||||
{
|
||||
&errors.StatusError{metav1.Status{
|
||||
&errors.StatusError{ErrStatus: metav1.Status{
|
||||
Status: metav1.StatusFailure,
|
||||
Code: http.StatusUnprocessableEntity,
|
||||
Reason: metav1.StatusReasonInvalid,
|
||||
|
|
@ -361,7 +361,7 @@ func TestCheckInvalidErr(t *testing.T) {
|
|||
},
|
||||
// webhook response that sets code=422 with no reason
|
||||
{
|
||||
&errors.StatusError{metav1.Status{
|
||||
&errors.StatusError{ErrStatus: metav1.Status{
|
||||
Status: "Failure",
|
||||
Message: `admission webhook "my.webhook" denied the request without explanation`,
|
||||
Code: 422,
|
||||
|
|
@ -371,7 +371,7 @@ func TestCheckInvalidErr(t *testing.T) {
|
|||
},
|
||||
// webhook response that sets code=422 with no reason and non-nil details
|
||||
{
|
||||
&errors.StatusError{metav1.Status{
|
||||
&errors.StatusError{ErrStatus: metav1.Status{
|
||||
Status: "Failure",
|
||||
Message: `admission webhook "my.webhook" denied the request without explanation`,
|
||||
Code: 422,
|
||||
|
|
@ -382,7 +382,7 @@ func TestCheckInvalidErr(t *testing.T) {
|
|||
},
|
||||
// source-wrapped webhook response that sets code=422 with no reason
|
||||
{
|
||||
AddSourceToErr("creating", "configmap.yaml", &errors.StatusError{metav1.Status{
|
||||
AddSourceToErr("creating", "configmap.yaml", &errors.StatusError{ErrStatus: metav1.Status{
|
||||
Status: "Failure",
|
||||
Message: `admission webhook "my.webhook" denied the request without explanation`,
|
||||
Code: 422,
|
||||
|
|
@ -392,7 +392,7 @@ func TestCheckInvalidErr(t *testing.T) {
|
|||
},
|
||||
// webhook response that sets reason=Invalid and code=422 and a message
|
||||
{
|
||||
&errors.StatusError{metav1.Status{
|
||||
&errors.StatusError{ErrStatus: metav1.Status{
|
||||
Status: "Failure",
|
||||
Reason: "Invalid",
|
||||
Message: `admission webhook "my.webhook" denied the request without explanation`,
|
||||
|
|
|
|||
|
|
@ -201,11 +201,11 @@ func TestFuncs(t *testing.T) {
|
|||
FuncName: "contains",
|
||||
Source: `{{contains $.haystack $.needle}}`,
|
||||
Context: map[string]any{
|
||||
"needle": schema.GroupVersionKind{"testgroup.k8s.io", "v1", "Kind"},
|
||||
"needle": schema.GroupVersionKind{Group: "testgroup.k8s.io", Version: "v1", Kind: "Kind"},
|
||||
"haystack": []schema.GroupVersionKind{
|
||||
{"randomgroup.k8s.io", "v1", "OtherKind"},
|
||||
{"testgroup.k8s.io", "v1", "OtherKind"},
|
||||
{"testgroup.k8s.io", "v1", "Kind"},
|
||||
{Group: "randomgroup.k8s.io", Version: "v1", Kind: "OtherKind"},
|
||||
{Group: "testgroup.k8s.io", Version: "v1", Kind: "OtherKind"},
|
||||
{Group: "testgroup.k8s.io", Version: "v1", Kind: "Kind"},
|
||||
},
|
||||
},
|
||||
Expect: `true`,
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ func TestViewDeploymentHistory(t *testing.T) {
|
|||
Namespace: "default",
|
||||
UID: types.UID(fmt.Sprintf("00000000-0000-0000-0000-00000000000%d", i)),
|
||||
Labels: map[string]string{"foo": "bar"},
|
||||
OwnerReferences: []metav1.OwnerReference{{"apps/v1", "Deployment", deployment.Name, deployment.UID, &trueVar, nil}},
|
||||
OwnerReferences: []metav1.OwnerReference{{APIVersion: "apps/v1", Kind: "Deployment", Name: deployment.Name, UID: deployment.UID, Controller: &trueVar}},
|
||||
Annotations: map[string]string{
|
||||
"deployment.kubernetes.io/revision": fmt.Sprintf("%d", i),
|
||||
},
|
||||
|
|
@ -219,7 +219,7 @@ func TestViewHistory(t *testing.T) {
|
|||
Name: "moons",
|
||||
Namespace: "default",
|
||||
Labels: map[string]string{"foo": "bar"},
|
||||
OwnerReferences: []metav1.OwnerReference{{"apps/v1", "StatefulSet", "moons", "1993", &trueVar, nil}},
|
||||
OwnerReferences: []metav1.OwnerReference{{APIVersion: "apps/v1", Kind: "StatefulSet", Name: "moons", UID: "1993", Controller: &trueVar}},
|
||||
},
|
||||
Data: runtime.RawExtension{Raw: stsRawData},
|
||||
TypeMeta: metav1.TypeMeta{Kind: "StatefulSet", APIVersion: "apps/v1"},
|
||||
|
|
@ -323,7 +323,7 @@ func TestViewHistory(t *testing.T) {
|
|||
Name: "moons",
|
||||
Namespace: "default",
|
||||
Labels: map[string]string{"foo": "bar"},
|
||||
OwnerReferences: []metav1.OwnerReference{{"apps/v1", "DaemonSet", "moons", "1993", &trueVar, nil}},
|
||||
OwnerReferences: []metav1.OwnerReference{{APIVersion: "apps/v1", Kind: "DaemonSet", Name: "moons", UID: "1993", Controller: &trueVar}},
|
||||
},
|
||||
Data: runtime.RawExtension{Raw: daemonSetRaw},
|
||||
TypeMeta: metav1.TypeMeta{Kind: "StatefulSet", APIVersion: "apps/v1"},
|
||||
|
|
|
|||
|
|
@ -138,6 +138,7 @@ func TestTranslationUsingEnvVar(t *testing.T) {
|
|||
t.Run(test.name, func(t *testing.T) {
|
||||
for _, envVar := range envVarsToBackup {
|
||||
if envVarValue := os.Getenv(envVar); envVarValue != "" {
|
||||
envVarValue, envVar := envVarValue, envVar
|
||||
os.Unsetenv(envVar)
|
||||
// Restore env var at the end
|
||||
defer func() { os.Setenv(envVar, envVarValue) }()
|
||||
|
|
|
|||
Loading…
Reference in a new issue