From 2b98214c5cf63b1797b85b1a16b0c671ad38d05e Mon Sep 17 00:00:00 2001 From: Andre Dietisheim Date: Thu, 11 Jan 2024 14:59:25 +0100 Subject: [PATCH] allow to force delete resources (#572) Signed-off-by: Andre Dietisheim --- .../actions/DeleteResourceAction.kt | 50 ++++++++++++++++--- .../kubernetes/model/ResourceModel.kt | 6 +-- .../kubernetes/model/context/ActiveContext.kt | 8 +-- .../model/context/IActiveContext.kt | 6 ++- .../resource/AbstractResourceOperator.kt | 30 +++++++++-- .../model/resource/IResourceOperator.kt | 2 +- .../NamespacedCustomResourceOperator.kt | 15 +++--- .../NonNamespacedCustomResourceOperator.kt | 16 +++--- .../model/context/KubernetesContextTest.kt | 46 ++++++++++------- .../kubernetes/model/mocks/ClientMocks.kt | 9 ++++ .../intellij/kubernetes/model/mocks/Mocks.kt | 4 +- .../kubernetes/NamespacedPodsOperatorTest.kt | 22 ++++++-- .../NamespacedCustomResourceOperatorTest.kt | 4 +- 13 files changed, 158 insertions(+), 60 deletions(-) diff --git a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/actions/DeleteResourceAction.kt b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/actions/DeleteResourceAction.kt index 4998f9755..91ccd84cf 100644 --- a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/actions/DeleteResourceAction.kt +++ b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/actions/DeleteResourceAction.kt @@ -10,6 +10,7 @@ ******************************************************************************/ package com.redhat.devtools.intellij.kubernetes.actions +import com.intellij.icons.AllIcons import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.diagnostic.logger import com.intellij.openapi.progress.Progressive @@ -23,6 +24,7 @@ import com.redhat.devtools.intellij.kubernetes.telemetry.TelemetryService import com.redhat.devtools.intellij.kubernetes.telemetry.TelemetryService.PROP_RESOURCE_KIND import com.redhat.devtools.intellij.kubernetes.telemetry.TelemetryService.getKinds import io.fabric8.kubernetes.api.model.HasMetadata +import javax.swing.JCheckBox import javax.swing.tree.TreePath class DeleteResourceAction: StructureTreeAction() { @@ -34,7 +36,8 @@ class DeleteResourceAction: StructureTreeAction() { override fun actionPerformed(event: AnActionEvent?, path: Array?, selected: Array?) { val model = getResourceModel() ?: return val toDelete = selected?.map { it.getDescriptor()?.element as HasMetadata} ?: return - if (!userConfirmed(toDelete)) { + val operation = userConfirms(toDelete) + if (operation.isNo) { return } run("Deleting ${toMessage(toDelete, 30)}...", true, @@ -42,7 +45,7 @@ class DeleteResourceAction: StructureTreeAction() { val telemetry = TelemetryService.instance.action("delete resource") .property(PROP_RESOURCE_KIND, getKinds(toDelete)) try { - model.delete(toDelete) + model.delete(toDelete, operation.isForce) Notification().info("Resources Deleted", toMessage(toDelete, 30)) telemetry.success().send() } catch (e: MultiResourceException) { @@ -54,12 +57,18 @@ class DeleteResourceAction: StructureTreeAction() { }) } - private fun userConfirmed(resources: List): Boolean { - val answer = Messages.showYesNoDialog( + private fun userConfirms(resources: List): DeleteOperation { + val answer = Messages.showCheckboxMessageDialog( "Delete ${toMessage(resources, 30)}?", - "Delete resources?", - Messages.getQuestionIcon()) - return answer == Messages.OK + "Delete", + arrayOf(Messages.getYesButton(), Messages.getNoButton()), + "Force (immediate)", + false, + 0, + 0, + AllIcons.General.QuestionDialog, + DeleteOperation.processDialogReturnValue) + return DeleteOperation(answer) } override fun isVisible(selected: Array?): Boolean { @@ -72,4 +81,29 @@ class DeleteResourceAction: StructureTreeAction() { return element != null && !hasDeletionTimestamp(element) } -} \ No newline at end of file + + private class DeleteOperation(private val dialogReturn: Int) { + + companion object { + const val FORCE_MASK = 0b1000000 + + val processDialogReturnValue = { exitCode: Int, checkbox: JCheckBox -> + if (exitCode == -1) { + Messages.CANCEL + } else { + exitCode or (if (checkbox.isSelected) FORCE_MASK else 0) + } + } + } + + val isForce: Boolean + get() { + return (dialogReturn and FORCE_MASK) == FORCE_MASK + } + + val isNo: Boolean + get() { + return (dialogReturn and Messages.NO) == Messages.NO + } + } +} diff --git a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/ResourceModel.kt b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/ResourceModel.kt index 4a2f5ebf1..4b84f4773 100644 --- a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/ResourceModel.kt +++ b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/ResourceModel.kt @@ -52,7 +52,7 @@ interface IResourceModel { fun stopWatch(kind: ResourceKind) fun stopWatch(definition: CustomResourceDefinition) fun invalidate(element: Any?) - fun delete(resources: List) + fun delete(resources: List, force: Boolean) fun canWatchLog(resource: HasMetadata): Boolean fun watchLog(container: Container, resource: HasMetadata, out: OutputStream): LogWatch? fun stopWatch(watch: LogWatch): Boolean @@ -189,8 +189,8 @@ open class ResourceModel : IResourceModel { allContexts.current?.replaced(resource) } - override fun delete(resources: List) { - allContexts.current?.delete(resources) + override fun delete(resources: List, force: Boolean) { + allContexts.current?.delete(resources, force) } override fun canWatchLog(resource: HasMetadata): Boolean { diff --git a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/context/ActiveContext.kt b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/context/ActiveContext.kt index af8eadbd5..2a2351819 100644 --- a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/context/ActiveContext.kt +++ b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/context/ActiveContext.kt @@ -434,14 +434,14 @@ abstract class ActiveContext( .filter { it.namespace == namespace } } - override fun delete(resources: List) { + override fun delete(resources: List, force: Boolean) { logger>().debug("Deleting ${toMessage(resources)}.") val exceptions = resources .distinct() .groupBy { Pair(ResourceKind.create(it), ResourcesIn.valueOf(it, getCurrentNamespace())) } .mapNotNull { try { - delete(it.key.first, it.key.second, it.value) + delete(it.key.first, it.key.second, it.value, force) modelChange.fireModified(it.value) null } catch (e: KubernetesClientException) { @@ -454,7 +454,7 @@ abstract class ActiveContext( } } - private fun delete(kind: ResourceKind, scope: ResourcesIn, resources: List): Collection { + private fun delete(kind: ResourceKind, scope: ResourcesIn, resources: List, force: Boolean): Collection { val operator = getOperator(kind, scope) if (operator == null) { logger>().warn( @@ -463,7 +463,7 @@ abstract class ActiveContext( return emptyList() } try { - val deleted = operator.delete(resources) + val deleted = operator.delete(resources, force) return if (deleted) { resources.forEach { setWillBeDeleted(it) } resources diff --git a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/context/IActiveContext.kt b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/context/IActiveContext.kt index 1366bcd7d..44465e082 100644 --- a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/context/IActiveContext.kt +++ b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/context/IActiveContext.kt @@ -100,10 +100,14 @@ interface IActiveContext: IContext { * Returns `false` otherwise. */ fun isCurrentNamespace(namespace: String): Boolean + /** * Deletes the given resources. + * + * @param resources the resources to delete + * @param force whether deletion should be forced (immediate deletion, no grace period) */ - fun delete(resources: List) + fun delete(resources: List, force: Boolean) /** * Returns all resources of the given kind in the given scope. diff --git a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/AbstractResourceOperator.kt b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/AbstractResourceOperator.kt index da0fe6c8f..21a35a995 100644 --- a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/AbstractResourceOperator.kt +++ b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/AbstractResourceOperator.kt @@ -15,6 +15,10 @@ import com.redhat.devtools.intellij.kubernetes.model.util.isSameResource import io.fabric8.kubernetes.api.model.HasMetadata import io.fabric8.kubernetes.client.Client import io.fabric8.kubernetes.client.KubernetesClient +import io.fabric8.kubernetes.client.PropagationPolicyConfigurable +import io.fabric8.kubernetes.client.dsl.Deletable +import io.fabric8.kubernetes.client.dsl.ListVisitFromServerGetDeleteRecreateWaitApplicable +import io.fabric8.kubernetes.client.dsl.Resource abstract class AbstractResourceOperator(protected val client: C) : IResourceOperator { @@ -77,11 +81,13 @@ abstract class AbstractResourceOperator(protected v return true } - override fun delete(resources: List): Boolean { + override fun delete(resources: List, force: Boolean): Boolean { @Suppress("UNCHECKED_CAST") val toDelete = resources as? List ?: return false - val status = client.adapt(KubernetesClient::class.java) - .resourceList(toDelete) + val resourceList = client.adapt(KubernetesClient::class.java) + .resourceList(toDelete) ?: return false + val status = resourceList + .immediate(force) .delete() return status.size == toDelete.size } @@ -90,7 +96,23 @@ abstract class AbstractResourceOperator(protected v return kind.clazz.isAssignableFrom(resource::class.java) } - override fun close() { + private fun ListVisitFromServerGetDeleteRecreateWaitApplicable.immediate(force: Boolean): PropagationPolicyConfigurable { + return if (force) { + withGracePeriod(0) + } else { + this + } + } + + protected fun Resource?.immediate(force: Boolean): PropagationPolicyConfigurable? { + return if (force) { + this?.withGracePeriod(0) + } else { + this + } + } + + override fun close() { client.close() } } diff --git a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/IResourceOperator.kt b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/IResourceOperator.kt index 0f616bac6..0014c5506 100644 --- a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/IResourceOperator.kt +++ b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/IResourceOperator.kt @@ -27,7 +27,7 @@ interface IResourceOperator: Closeable { fun replaced(resource: HasMetadata): Boolean fun added(resource: HasMetadata): Boolean fun removed(resource: HasMetadata): Boolean - fun delete(resources: List): Boolean + fun delete(resources: List, force: Boolean): Boolean fun replace(resource: HasMetadata): HasMetadata? fun create(resource: HasMetadata): HasMetadata? fun get(resource: HasMetadata): HasMetadata? diff --git a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/kubernetes/custom/NamespacedCustomResourceOperator.kt b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/kubernetes/custom/NamespacedCustomResourceOperator.kt index 3e9bab646..16c6d7ef8 100644 --- a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/kubernetes/custom/NamespacedCustomResourceOperator.kt +++ b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/kubernetes/custom/NamespacedCustomResourceOperator.kt @@ -58,20 +58,23 @@ open class NamespacedCustomResourceOperator( ?.watch(typedWatcher) } - override fun delete(resources: List): Boolean { + override fun delete(resources: List, force: Boolean): Boolean { @Suppress("UNCHECKED_CAST") val toDelete = resources as? List ?: return false return toDelete.stream() - .map { delete(it) } + .map { delete(it, force) } .reduce(false) { thisDelete, thatDelete -> thisDelete || thatDelete } } - private fun delete(resource: HasMetadata): Boolean { + private fun delete(resource: HasMetadata, force: Boolean): Boolean { val inNamespace = resourceNamespaceOrCurrent(resource) - getOperation() + val operation = getOperation() ?.inNamespace(inNamespace) ?.withName(resource.metadata.name) - ?.delete() + ?: return false + operation + .immediate(force) + ?.delete() return true } @@ -103,4 +106,4 @@ open class NamespacedCustomResourceOperator( return client.genericKubernetesResources(context) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/kubernetes/custom/NonNamespacedCustomResourceOperator.kt b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/kubernetes/custom/NonNamespacedCustomResourceOperator.kt index 79c3b2b7f..54bb0f04b 100644 --- a/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/kubernetes/custom/NonNamespacedCustomResourceOperator.kt +++ b/src/main/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/kubernetes/custom/NonNamespacedCustomResourceOperator.kt @@ -49,18 +49,20 @@ class NonNamespacedCustomResourceOperator( ?.watch(typedWatcher) } - override fun delete(resources: List): Boolean { + override fun delete(resources: List, force: Boolean): Boolean { @Suppress("UNCHECKED_CAST") val toDelete = resources as? List ?: return false return toDelete.stream() - .map { delete(it.metadata.name) } + .map { delete(it.metadata.name, force) } .reduce(false ) { thisDelete, thatDelete -> thisDelete || thatDelete } } - private fun delete(name: String): Boolean { - getOperation() - ?.withName(name) - ?.delete() + private fun delete(name: String, force: Boolean): Boolean { + val operation = getOperation() + ?.withName(name) ?: return false + operation + .immediate(force) + ?.delete() return true } @@ -85,4 +87,4 @@ class NonNamespacedCustomResourceOperator( override fun getOperation(): NonNamespacedOperation? { return client.genericKubernetesResources(context) } -} \ No newline at end of file +} diff --git a/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/context/KubernetesContextTest.kt b/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/context/KubernetesContextTest.kt index 1292cc424..062bb88ca 100644 --- a/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/context/KubernetesContextTest.kt +++ b/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/context/KubernetesContextTest.kt @@ -334,9 +334,19 @@ class KubernetesContextTest { // given val toDelete = listOf(POD2) // when - context.delete(toDelete) + context.delete(toDelete, false) // then - verify(namespacedPodsOperator).delete(toDelete) + verify(namespacedPodsOperator).delete(toDelete, false) + } + + @Test + fun `#delete should call operator#delete with force = true`() { + // given + val toDelete = listOf(POD2) + // when + context.delete(toDelete, true) + // then + verify(namespacedPodsOperator).delete(toDelete, true) } @Test @@ -344,9 +354,9 @@ class KubernetesContextTest { // given val toDelete = listOf(resource("lord sith", "ns1", "uid", "v1")) // when - context.delete(toDelete) + context.delete(toDelete, false) // then - verify(namespacedPodsOperator, never()).delete(toDelete) + verify(namespacedPodsOperator, never()).delete(any(), any()) } @Test @@ -354,9 +364,9 @@ class KubernetesContextTest { // given val toDelete = listOf(POD2, POD2) // when - context.delete(toDelete) + context.delete(toDelete, false) // then - verify(namespacedPodsOperator, times(1)).delete(eq(listOf(POD2))) + verify(namespacedPodsOperator, times(1)).delete(eq(listOf(POD2)), eq(false)) } @Test @@ -364,20 +374,20 @@ class KubernetesContextTest { // given val toDelete = listOf(POD2, NAMESPACE2) // when - context.delete(toDelete) + context.delete(toDelete, false) // then - verify(namespacedPodsOperator, times(1)).delete(eq(listOf(POD2))) - verify(namespacesOperator, times(1)).delete(eq(listOf(NAMESPACE2))) + verify(namespacedPodsOperator, times(1)).delete(eq(listOf(POD2)), eq(false)) + verify(namespacesOperator, times(1)).delete(eq(listOf(NAMESPACE2)), eq(false)) } @Test fun `#delete should fire if resource was deleted`() { // given val toDelete = listOf(POD2) - whenever(allPodsOperator.delete(any())) + whenever(allPodsOperator.delete(any(), any())) .thenReturn(true) // when - context.delete(toDelete) + context.delete(toDelete, false) // then verify(modelChange).fireModified(toDelete) } @@ -387,7 +397,7 @@ class KubernetesContextTest { // given val toDelete = listOf(POD2, POD3) // when - context.delete(toDelete) + context.delete(toDelete, false) // then verify(POD2.metadata, atLeastOnce()).deletionTimestamp = any() verify(POD3.metadata, atLeastOnce()).deletionTimestamp = any() @@ -397,10 +407,10 @@ class KubernetesContextTest { fun `#delete should throw if resource was NOT deleted`() { // given val toDelete = listOf(POD2) - whenever(namespacedPodsOperator.delete(any())) + whenever(namespacedPodsOperator.delete(any(), any())) .thenReturn(false) // when - context.delete(toDelete) + context.delete(toDelete, false) // then // expect exception } @@ -409,11 +419,11 @@ class KubernetesContextTest { fun `#delete should throw for operator that failed, not successful ones`() { // given val toDelete = listOf(POD2, NAMESPACE2) - whenever(namespacedPodsOperator.delete(any())) + whenever(namespacedPodsOperator.delete(any(), any())) .thenReturn(false) // when val ex = try { - context.delete(toDelete) + context.delete(toDelete, false) null } catch (e: MultiResourceException) { e @@ -428,11 +438,11 @@ class KubernetesContextTest { fun `#delete should NOT fire if resource was NOT deleted`() { // given val toDelete = listOf(POD2) - whenever(namespacedPodsOperator.delete(any())) + whenever(namespacedPodsOperator.delete(any(), any())) .thenReturn(false) // when try { - context.delete(toDelete) + context.delete(toDelete, false) } catch (e: MultiResourceException) { // ignore expected exception } diff --git a/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/mocks/ClientMocks.kt b/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/mocks/ClientMocks.kt index ea85d7a09..5f3bf468a 100644 --- a/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/mocks/ClientMocks.kt +++ b/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/mocks/ClientMocks.kt @@ -57,6 +57,7 @@ import io.fabric8.kubernetes.client.dsl.NonNamespaceOperation import io.fabric8.kubernetes.client.dsl.PodResource import io.fabric8.kubernetes.client.dsl.Resource import io.fabric8.kubernetes.client.dsl.internal.HasMetadataOperation +import io.fabric8.kubernetes.client.extension.ExtensibleResource import java.net.URL @@ -149,18 +150,26 @@ object ClientMocks { statusDetails: List = statusDetails(1), client: KubernetesClient ) { + val extensibleResource: ExtensibleResource = mock { + on { delete() } doReturn statusDetails + } + val resourceListInNamespaceOp: ListVisitFromServerGetDeleteRecreateWaitApplicable = mock { on { delete() } doReturn statusDetails on { replace() } doReturn resourceList on { create() } doReturn resourceList on { get() } doReturn resourceList + on { withGracePeriod(any()) } doReturn extensibleResource } + /** [KubernetesClient.resourceList] */ val resourceListOperation: NamespaceListVisitFromServerGetDeleteRecreateWaitApplicable = mock { on { inNamespace(any()) } doReturn resourceListInNamespaceOp on { delete() } doReturn statusDetails on { replace() } doReturn resourceList + on { withGracePeriod(any()) } doReturn extensibleResource } + doReturn(resourceListOperation) .whenever(client).resourceList(any>()) } diff --git a/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/mocks/Mocks.kt b/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/mocks/Mocks.kt index f52a97ab9..ab6dbce7c 100644 --- a/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/mocks/Mocks.kt +++ b/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/mocks/Mocks.kt @@ -163,7 +163,7 @@ object Mocks { .whenever(mock).watchAll(any()) doReturn(deleteSuccess) - .whenever(mock).delete(any()) + .whenever(mock).delete(any(), any()) doReturn(getReturnValue) .whenever(mock).get(any()) } @@ -183,7 +183,7 @@ object Mocks { on { watchAll(any()) } doAnswer { invocation -> watchOperation.invoke(invocation.getArgument(0)) } - on { delete(any()) } doReturn deleteSuccess + on { delete(any(), any()) } doReturn deleteSuccess } } diff --git a/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/kubernetes/NamespacedPodsOperatorTest.kt b/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/kubernetes/NamespacedPodsOperatorTest.kt index a21db8a21..7d1a0b62e 100644 --- a/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/kubernetes/NamespacedPodsOperatorTest.kt +++ b/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/kubernetes/NamespacedPodsOperatorTest.kt @@ -322,25 +322,39 @@ class NamespacedPodsOperatorTest { } @Test - fun `#delete(List) deletes given resources`() { + fun `#delete(List, false) deletes given resources`() { // given val toDelete = listOf(POD2) resourceListOperation(resourceList = toDelete, client = client.get()) // when - operator.delete(toDelete) + operator.delete(toDelete, false) // then verify(client.get().adapt(KubernetesClient::class.java) .resourceList(toDelete)) .delete() } + @Test + fun `#delete(List, true) deletes given resources with grace period 0`() { + // given + val toDelete = listOf(POD2) + resourceListOperation(resourceList = toDelete, client = client.get()) + // when + operator.delete(toDelete, true) + // then + verify(client.get().adapt(KubernetesClient::class.java) + .resourceList(toDelete) + .withGracePeriod(0)) + .delete() + } + @Test fun `#delete(List) returns true if client could delete`() { // given val toDelete = listOf(POD2) resourceListOperation(resourceList = toDelete, client = client.get()) // when - val success = operator.delete(toDelete) + val success = operator.delete(toDelete, false) // then assertThat(success).isTrue } @@ -351,7 +365,7 @@ class NamespacedPodsOperatorTest { val toDelete = listOf(POD2) resourceListOperation(resourceList = toDelete, statusDetails = emptyList(), client = client.get()) // when - val success = operator.delete(toDelete) + val success = operator.delete(toDelete, false) // then assertThat(success).isFalse } diff --git a/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/kubernetes/custom/NamespacedCustomResourceOperatorTest.kt b/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/kubernetes/custom/NamespacedCustomResourceOperatorTest.kt index 4f822b1a7..88d714cc9 100644 --- a/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/kubernetes/custom/NamespacedCustomResourceOperatorTest.kt +++ b/src/test/kotlin/com/redhat/devtools/intellij/kubernetes/model/resource/kubernetes/custom/NamespacedCustomResourceOperatorTest.kt @@ -152,7 +152,7 @@ class NamespacedCustomResourceOperatorTest { val namespaceUsed = ArgumentCaptor.forClass(String::class.java) assertThat(operator.namespace).isNotEqualTo(customResource.metadata.namespace) // when - operator.delete(listOf(customResource)) + operator.delete(listOf(customResource), false) // then verify(op).inNamespace(namespaceUsed.capture()) assertThat(namespaceUsed.value).isEqualTo(customResource.metadata.namespace) @@ -166,7 +166,7 @@ class NamespacedCustomResourceOperatorTest { assertThat(operator.namespace).isNotNull() val namespaceUsed = ArgumentCaptor.forClass(String::class.java) // when - operator.delete(listOf(noNamespace)) + operator.delete(listOf(noNamespace), false) // then verify(op).inNamespace(namespaceUsed.capture()) assertThat(namespaceUsed.value).isEqualTo(operator.namespace)