Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pkg/controller: fix staticcheck warning #84763

Merged
merged 1 commit into from Nov 7, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion pkg/controller/deployment/sync_test.go
Expand Up @@ -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++
}
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/disruption/disruption.go
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions pkg/controller/endpointslice/endpointset.go
Expand Up @@ -68,8 +68,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.
Expand Down
1 change: 0 additions & 1 deletion pkg/controller/garbagecollector/garbagecollector.go
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/controller/garbagecollector/graph.go
Expand Up @@ -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() {
Expand Down
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
Expand Up @@ -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])
}
}
Expand Down