pkg/controller: fix staticcheck warning

This commit is contained in:
hwdef
2019-11-05 10:21:20 +08:00
parent 2b3540068b
commit 38256df718
7 changed files with 6 additions and 22 deletions

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])
}
}