Skip to content

Commit f4940cf

Browse files
committed
Staticcheck: vendor/k8s.io/kubectl/pkg/scale|describe/versioned|cmd/top|cmd/util/editor|cmd/top
1 parent 0f13c5c commit f4940cf

File tree

7 files changed

+8
-26
lines changed

7 files changed

+8
-26
lines changed

hack/.staticcheck_failures

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -104,9 +104,4 @@ vendor/k8s.io/kubectl/pkg/cmd/rollingupdate
104104
vendor/k8s.io/kubectl/pkg/cmd/scale
105105
vendor/k8s.io/kubectl/pkg/cmd/set
106106
vendor/k8s.io/kubectl/pkg/cmd/testing
107-
vendor/k8s.io/kubectl/pkg/cmd/top
108-
vendor/k8s.io/kubectl/pkg/cmd/util/editor
109-
vendor/k8s.io/kubectl/pkg/cmd/wait
110-
vendor/k8s.io/kubectl/pkg/describe/versioned
111-
vendor/k8s.io/kubectl/pkg/scale
112107
vendor/k8s.io/metrics/pkg/client/custom_metrics

staging/src/k8s.io/kubectl/pkg/cmd/top/top_node.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ func (o TopNodeOptions) RunTopNode() error {
180180

181181
metricsAPIAvailable := SupportedMetricsAPIVersionAvailable(apiGroups)
182182

183-
metrics := &metricsapi.NodeMetricsList{}
183+
var metrics *metricsapi.NodeMetricsList
184184
if metricsAPIAvailable {
185185
metrics, err = getNodeMetricsFromMetricsAPI(o.MetricsClient, o.ResourceName, selector)
186186
if err != nil {

staging/src/k8s.io/kubectl/pkg/cmd/top/top_pod.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ func (o TopPodOptions) RunTopPod() error {
174174

175175
metricsAPIAvailable := SupportedMetricsAPIVersionAvailable(apiGroups)
176176

177-
metrics := &metricsapi.PodMetricsList{}
177+
var metrics *metricsapi.PodMetricsList
178178
if metricsAPIAvailable {
179179
metrics, err = getMetricsFromMetricsAPI(o.MetricsClient, o.Namespace, o.ResourceName, o.AllNamespaces, selector)
180180
if err != nil {

staging/src/k8s.io/kubectl/pkg/cmd/util/editor/editoptions.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ import (
3737
"k8s.io/apimachinery/pkg/api/meta"
3838
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
3939
"k8s.io/apimachinery/pkg/runtime"
40-
"k8s.io/apimachinery/pkg/runtime/schema"
4140
"k8s.io/apimachinery/pkg/types"
4241
"k8s.io/apimachinery/pkg/util/mergepatch"
4342
"k8s.io/apimachinery/pkg/util/strategicpatch"
@@ -731,19 +730,13 @@ func (h *editHeader) writeTo(w io.Writer, editMode EditMode) error {
731730
return nil
732731
}
733732

734-
func (h *editHeader) flush() {
735-
h.reasons = []editReason{}
736-
}
737-
738733
// editResults capture the result of an update
739734
type editResults struct {
740735
header editHeader
741736
retryable int
742737
notfound int
743738
edit []*resource.Info
744739
file string
745-
746-
version schema.GroupVersion
747740
}
748741

749742
func (r *editResults) addError(err error, info *resource.Info) string {

staging/src/k8s.io/kubectl/pkg/cmd/wait/wait.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -426,14 +426,14 @@ func (w ConditionalWait) checkCondition(obj *unstructured.Unstructured) (bool, e
426426
for _, conditionUncast := range conditions {
427427
condition := conditionUncast.(map[string]interface{})
428428
name, found, err := unstructured.NestedString(condition, "type")
429-
if !found || err != nil || strings.ToLower(name) != strings.ToLower(w.conditionName) {
429+
if !found || err != nil || !strings.EqualFold(name, w.conditionName) {
430430
continue
431431
}
432432
status, found, err := unstructured.NestedString(condition, "status")
433433
if !found || err != nil {
434434
continue
435435
}
436-
return strings.ToLower(status) == strings.ToLower(w.conditionStatus), nil
436+
return strings.EqualFold(status, w.conditionStatus), nil
437437
}
438438

439439
return false, nil

staging/src/k8s.io/kubectl/pkg/describe/versioned/describe_test.go

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3661,12 +3661,6 @@ Events: <none>` + "\n"
36613661
}
36623662
}
36633663

3664-
// boolPtr returns a pointer to a bool
3665-
func boolPtr(b bool) *bool {
3666-
o := b
3667-
return &o
3668-
}
3669-
36703664
func TestControllerRef(t *testing.T) {
36713665
var replicas int32 = 1
36723666
f := fake.NewSimpleClientset(

staging/src/k8s.io/kubectl/pkg/scale/scale_test.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func TestReplicationControllerScaleRetry(t *testing.T) {
7878
}
7979
preconditions := ScalePrecondition{3, ""}
8080
scaleFunc = ScaleCondition(scaler, &preconditions, namespace, name, count, nil, rcgvr)
81-
pass, err = scaleFunc()
81+
_, err = scaleFunc()
8282
if err == nil {
8383
t.Errorf("Expected error on precondition failure")
8484
}
@@ -188,7 +188,7 @@ func TestDeploymentScaleRetry(t *testing.T) {
188188
}
189189
preconditions := &ScalePrecondition{3, ""}
190190
scaleFunc = ScaleCondition(scaler, preconditions, namespace, name, count, nil, deploygvr)
191-
pass, err = scaleFunc()
191+
_, err = scaleFunc()
192192
if err == nil {
193193
t.Error("Expected error on precondition failure")
194194
}
@@ -318,7 +318,7 @@ func TestStatefulSetScaleRetry(t *testing.T) {
318318
}
319319
preconditions := &ScalePrecondition{3, ""}
320320
scaleFunc = ScaleCondition(scaler, preconditions, namespace, name, count, nil, stsgvr)
321-
pass, err = scaleFunc()
321+
_, err = scaleFunc()
322322
if err == nil {
323323
t.Error("Expected error on precondition failure")
324324
}
@@ -427,7 +427,7 @@ func TestReplicaSetScaleRetry(t *testing.T) {
427427
}
428428
preconditions := &ScalePrecondition{3, ""}
429429
scaleFunc = ScaleCondition(scaler, preconditions, namespace, name, count, nil, rsgvr)
430-
pass, err = scaleFunc()
430+
_, err = scaleFunc()
431431
if err == nil {
432432
t.Error("Expected error on precondition failure")
433433
}

0 commit comments

Comments
 (0)