Skip to content

Commit

Permalink
Delete correctly namespaced resoruces type (#53)
Browse files Browse the repository at this point in the history
Signed-off-by: David Kornel <[email protected]>
  • Loading branch information
kornys authored May 7, 2024
1 parent 5067eac commit ee678b8
Showing 1 changed file with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import io.skodjob.testframe.clients.cmdClient.KubeCmdClient;
import io.skodjob.testframe.clients.cmdClient.Kubectl;
import io.skodjob.testframe.clients.cmdClient.Oc;
import io.skodjob.testframe.interfaces.NamespacedResourceType;
import io.skodjob.testframe.interfaces.ResourceType;
import io.skodjob.testframe.wait.Wait;
import org.junit.jupiter.api.extension.ExtensionContext;
Expand Down Expand Up @@ -261,7 +262,12 @@ public final <T extends HasMetadata> void deleteResource(T... resources) {
String.format("Timed out deleting %s/%s in %s", resource.getKind(),
resource.getMetadata().getName(), resource.getMetadata().getNamespace()));
} else {
type.delete(resource.getMetadata().getName());
if (type instanceof NamespacedResourceType<T>) {
((NamespacedResourceType<T>) type).deleteFromNamespace(resource.getMetadata().getNamespace(),
resource.getMetadata().getName());
} else {
type.delete(resource.getMetadata().getName());
}
assertTrue(waitResourceCondition(resource, ResourceCondition.deletion()),
String.format("Timed out deleting %s/%s in %s", resource.getKind(),
resource.getMetadata().getName(), resource.getMetadata().getNamespace()));
Expand Down Expand Up @@ -289,7 +295,12 @@ public final <T extends HasMetadata> void updateResource(T... resources) {
LoggerUtils.logResource("Updating", resource);
ResourceType<T> type = findResourceType(resource);
if (type != null) {
type.update(resource);
if (type instanceof NamespacedResourceType<T>) {
((NamespacedResourceType<T>) type).updateInNamespace(resource.getMetadata().getNamespace(),
resource);
} else {
type.update(resource);
}
} else {
client.getClient().resource(resource).update();
}
Expand Down

0 comments on commit ee678b8

Please sign in to comment.