Skip to content
Permalink
Browse files

Merge pull request #87403 from gavinfish/kubectl_pkg

Staticcheck: vendor/k8s.io/kubectl/pkg/scale etc.
  • Loading branch information
k8s-ci-robot committed Feb 12, 2020
2 parents 460fdc7 + 527de3b commit de9bbcc9cd6413cf0c5719d746bea52eaa03ff1d
@@ -103,9 +103,4 @@ vendor/k8s.io/kubectl/pkg/cmd/rollingupdate
vendor/k8s.io/kubectl/pkg/cmd/scale
vendor/k8s.io/kubectl/pkg/cmd/set
vendor/k8s.io/kubectl/pkg/cmd/testing
vendor/k8s.io/kubectl/pkg/cmd/top
vendor/k8s.io/kubectl/pkg/cmd/util/editor
vendor/k8s.io/kubectl/pkg/cmd/wait
vendor/k8s.io/kubectl/pkg/describe/versioned
vendor/k8s.io/kubectl/pkg/scale
vendor/k8s.io/metrics/pkg/client/custom_metrics
@@ -181,7 +181,7 @@ func (o TopNodeOptions) RunTopNode() error {

metricsAPIAvailable := SupportedMetricsAPIVersionAvailable(apiGroups)

metrics := &metricsapi.NodeMetricsList{}
var metrics *metricsapi.NodeMetricsList
if metricsAPIAvailable {
metrics, err = getNodeMetricsFromMetricsAPI(o.MetricsClient, o.ResourceName, selector)
if err != nil {
@@ -175,7 +175,7 @@ func (o TopPodOptions) RunTopPod() error {

metricsAPIAvailable := SupportedMetricsAPIVersionAvailable(apiGroups)

metrics := &metricsapi.PodMetricsList{}
var metrics *metricsapi.PodMetricsList
if metricsAPIAvailable {
metrics, err = getMetricsFromMetricsAPI(o.MetricsClient, o.Namespace, o.ResourceName, o.AllNamespaces, selector)
if err != nil {
@@ -15,7 +15,6 @@ go_library(
"//staging/src/k8s.io/apimachinery/pkg/api/meta:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/apis/meta/v1/unstructured:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/types:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/mergepatch:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/util/strategicpatch:go_default_library",
@@ -37,7 +37,6 @@ import (
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
"k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/apimachinery/pkg/types"
"k8s.io/apimachinery/pkg/util/mergepatch"
"k8s.io/apimachinery/pkg/util/strategicpatch"
@@ -731,19 +730,13 @@ func (h *editHeader) writeTo(w io.Writer, editMode EditMode) error {
return nil
}

func (h *editHeader) flush() {
h.reasons = []editReason{}
}

// editResults capture the result of an update
type editResults struct {
header editHeader
retryable int
notfound int
edit []*resource.Info
file string

version schema.GroupVersion
}

func (r *editResults) addError(err error, info *resource.Info) string {
@@ -426,14 +426,14 @@ func (w ConditionalWait) checkCondition(obj *unstructured.Unstructured) (bool, e
for _, conditionUncast := range conditions {
condition := conditionUncast.(map[string]interface{})
name, found, err := unstructured.NestedString(condition, "type")
if !found || err != nil || strings.ToLower(name) != strings.ToLower(w.conditionName) {
if !found || err != nil || !strings.EqualFold(name, w.conditionName) {
continue
}
status, found, err := unstructured.NestedString(condition, "status")
if !found || err != nil {
continue
}
return strings.ToLower(status) == strings.ToLower(w.conditionStatus), nil
return strings.EqualFold(status, w.conditionStatus), nil
}

return false, nil
@@ -3661,12 +3661,6 @@ Events: <none>` + "\n"
}
}

// boolPtr returns a pointer to a bool
func boolPtr(b bool) *bool {
o := b
return &o
}

func TestControllerRef(t *testing.T) {
var replicas int32 = 1
f := fake.NewSimpleClientset(
@@ -78,7 +78,7 @@ func TestReplicationControllerScaleRetry(t *testing.T) {
}
preconditions := ScalePrecondition{3, ""}
scaleFunc = ScaleCondition(scaler, &preconditions, namespace, name, count, nil, rcgvr)
pass, err = scaleFunc()
_, err = scaleFunc()
if err == nil {
t.Errorf("Expected error on precondition failure")
}
@@ -188,7 +188,7 @@ func TestDeploymentScaleRetry(t *testing.T) {
}
preconditions := &ScalePrecondition{3, ""}
scaleFunc = ScaleCondition(scaler, preconditions, namespace, name, count, nil, deploygvr)
pass, err = scaleFunc()
_, err = scaleFunc()
if err == nil {
t.Error("Expected error on precondition failure")
}
@@ -318,7 +318,7 @@ func TestStatefulSetScaleRetry(t *testing.T) {
}
preconditions := &ScalePrecondition{3, ""}
scaleFunc = ScaleCondition(scaler, preconditions, namespace, name, count, nil, stsgvr)
pass, err = scaleFunc()
_, err = scaleFunc()
if err == nil {
t.Error("Expected error on precondition failure")
}
@@ -427,7 +427,7 @@ func TestReplicaSetScaleRetry(t *testing.T) {
}
preconditions := &ScalePrecondition{3, ""}
scaleFunc = ScaleCondition(scaler, preconditions, namespace, name, count, nil, rsgvr)
pass, err = scaleFunc()
_, err = scaleFunc()
if err == nil {
t.Error("Expected error on precondition failure")
}

0 comments on commit de9bbcc

Please sign in to comment.
You can’t perform that action at this time.