Class KubeResourceManager

java.lang.Object
io.skodjob.testframe.resources.KubeResourceManager

public class KubeResourceManager extends Object
Manages Kubernetes resources for testing purposes.
  • Constructor Details

    • KubeResourceManager

      public KubeResourceManager()
  • Method Details

    • getInstance

      public static KubeResourceManager getInstance()
      Retrieves the singleton instance of KubeResourceManager.
      Returns:
      The singleton instance of KubeResourceManager.
    • getKubeClient

      public static KubeClient getKubeClient()
      Retrieves the Kubernetes client.
      Returns:
      The Kubernetes client.
    • getKubeCmdClient

      public static KubeCmdClient getKubeCmdClient()
      Retrieves the Kubernetes command-line client.
      Returns:
      The Kubernetes command-line client.
    • setTestContext

      public static void setTestContext(org.junit.jupiter.api.extension.ExtensionContext context)
      Sets the test context.
      Parameters:
      context - The extension context.
    • getTestContext

      public static org.junit.jupiter.api.extension.ExtensionContext getTestContext()
      Retrieves the test context.
      Returns:
      The extension context.
    • setResourceTypes

      public final void setResourceTypes(ResourceType... types)
      Sets the resource types.
      Parameters:
      types - The resource types implementing ResourceType
    • readResourcesFromFile

      public List<io.fabric8.kubernetes.api.model.HasMetadata> readResourcesFromFile(Path file) throws IOException
      Reads Kubernetes resources from a file at the specified path.
      Parameters:
      file - The path to the file containing Kubernetes resources.
      Returns:
      A list of HasMetadata resources defined in the file.
      Throws:
      IOException - If an I/O error occurs reading from the file.
    • readResourcesFromFile

      public List<io.fabric8.kubernetes.api.model.HasMetadata> readResourcesFromFile(InputStream is) throws IOException
      Reads Kubernetes resources from an InputStream.
      Parameters:
      is - The InputStream containing Kubernetes resources.
      Returns:
      A list of HasMetadata resources defined in the stream.
      Throws:
      IOException - If an I/O error occurs.
    • pushToStack

      public final void pushToStack(ResourceItem item)
      Pushes a resource item to the stack.
      Parameters:
      item - The resource item to push.
    • pushToStack

      public final <T extends io.fabric8.kubernetes.api.model.HasMetadata> void pushToStack(T resource)
      Pushes a resource to the stack.
      Type Parameters:
      T - The type of the resource.
      Parameters:
      resource - The resource to push.
    • createResourceWithoutWait

      @SafeVarargs public final <T extends io.fabric8.kubernetes.api.model.HasMetadata> void createResourceWithoutWait(T... resources)
      Creates resources without waiting for readiness.
      Type Parameters:
      T - The type of the resources.
      Parameters:
      resources - The resources to create.
    • createResourceWithWait

      @SafeVarargs public final <T extends io.fabric8.kubernetes.api.model.HasMetadata> void createResourceWithWait(T... resources)
      Creates resources and waits for readiness.
      Type Parameters:
      T - The type of the resources.
      Parameters:
      resources - The resources to create.
    • deleteResource

      @SafeVarargs public final <T extends io.fabric8.kubernetes.api.model.HasMetadata> void deleteResource(T... resources)
      Deletes resources.
      Type Parameters:
      T - The type of the resources.
      Parameters:
      resources - The resources to delete.
    • updateResource

      @SafeVarargs public final <T extends io.fabric8.kubernetes.api.model.HasMetadata> void updateResource(T... resources)
      Updates resources.
      Type Parameters:
      T - The type of the resources.
      Parameters:
      resources - The resources to update.
    • waitResourceCondition

      public final <T extends io.fabric8.kubernetes.api.model.HasMetadata> boolean waitResourceCondition(T resource, ResourceCondition<T> condition)
      Waits for a resource condition to be fulfilled.
      Type Parameters:
      T - The type of the resource.
      Parameters:
      resource - The resource to wait for.
      condition - The condition to fulfill.
      Returns:
      True if the condition is fulfilled, false otherwise.
    • deleteResources

      public void deleteResources()
      Deletes all stored resources.