Merge pull request #84763 from hwdef/fix-staticcheck6

pkg/controller: fix staticcheck warning
This commit is contained in:
Kubernetes Prow Robot 2019-11-07 09:05:17 -08:00 committed by GitHub
commit 06a7e9a1f3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 6 additions and 22 deletions

View File

@ -435,7 +435,7 @@ func TestDeploymentController_cleanupDeployment(t *testing.T) {
gotDeletions := 0
for _, action := range fake.Actions() {
if "delete" == action.GetVerb() {
if action.GetVerb() == "delete" {
gotDeletions++
}
}

View File

@ -714,7 +714,7 @@ func (dc *DisruptionController) buildDisruptedPodMap(pods []*v1.Pod, pdb *policy
result := make(map[string]metav1.Time)
var recheckTime *time.Time
if disruptedPods == nil || len(disruptedPods) == 0 {
if disruptedPods == nil {
return result, recheckTime
}
for _, pod := range pods {

View File

@ -69,8 +69,7 @@ func (s endpointSet) Has(item *discovery.Endpoint) bool {
// Returns an endpoint matching the hash if contained in the set.
func (s endpointSet) Get(item *discovery.Endpoint) *discovery.Endpoint {
got, _ := s[hashEndpoint(item)]
return got
return s[hashEndpoint(item)]
}
// UnsortedList returns the slice with contents in random order.

View File

@ -66,7 +66,6 @@ type GarbageCollector struct {
dependencyGraphBuilder *GraphBuilder
// GC caches the owners that do not exist according to the API server.
absentOwnerCache *UIDCache
sharedInformers controller.InformerFactory
workerLock sync.RWMutex
}

View File

@ -83,7 +83,7 @@ func (n *node) markObserved() {
func (n *node) isObserved() bool {
n.virtualLock.RLock()
defer n.virtualLock.RUnlock()
return n.virtual == false
return !n.virtual
}
func (n *node) markDeletingDependents() {

View File

@ -138,7 +138,7 @@ func (d *namespacedResourcesDeleter) Delete(nsName string) error {
}
// we have removed content, so mark it finalized by us
namespace, err = d.retryOnConflictError(namespace, d.finalizeNamespace)
_, err = d.retryOnConflictError(namespace, d.finalizeNamespace)
if err != nil {
// in normal practice, this should not be possible, but if a deployment is running
// two controllers to do namespace deletion that share a common finalizer token it's
@ -188,20 +188,6 @@ func (d *namespacedResourcesDeleter) initOpCache() {
}
}
// Deletes the given namespace.
func (d *namespacedResourcesDeleter) deleteNamespace(namespace *v1.Namespace) error {
var opts *metav1.DeleteOptions
uid := namespace.UID
if len(uid) > 0 {
opts = &metav1.DeleteOptions{Preconditions: &metav1.Preconditions{UID: &uid}}
}
err := d.nsClient.Delete(namespace.Name, opts)
if err != nil && !errors.IsNotFound(err) {
return err
}
return nil
}
// ResourcesRemainingError is used to inform the caller that all resources are not yet fully removed from the namespace.
type ResourcesRemainingError struct {
Estimate int64

View File

@ -82,7 +82,7 @@ func TestFinalizeNamespaceFunc(t *testing.T) {
if len(finalizers) != 1 {
t.Errorf("There should be a single finalizer remaining")
}
if "other" != string(finalizers[0]) {
if string(finalizers[0]) != "other" {
t.Errorf("Unexpected finalizer value, %v", finalizers[0])
}
}