Package dev.strela.v1

Class KubernetesCrudRepository<R extends io.fabric8.kubernetes.client.CustomResource>

java.lang.Object
dev.strela.v1.KubernetesCrudRepository<R>
Type Parameters:
R - the type of the custom resource
Direct Known Subclasses:
MinecraftDeployments, MinecraftServers, MinecraftServerSets, MinecraftStatefulSets

public abstract class KubernetesCrudRepository<R extends io.fabric8.kubernetes.client.CustomResource> extends Object
A repository for Kubernetes custom resources
  • Field Details

    • customResourceClass

      protected final Class<R extends io.fabric8.kubernetes.client.CustomResource> customResourceClass
    • kubernetesClient

      protected final io.fabric8.kubernetes.client.KubernetesClient kubernetesClient
    • defaultNamespace

      protected final String defaultNamespace
  • Constructor Details

    • KubernetesCrudRepository

      protected KubernetesCrudRepository(Class<R> customResourceClass, io.fabric8.kubernetes.client.KubernetesClient kubernetesClient, String defaultNamespace)
      Creates a new KubernetesCrudRepository
      Parameters:
      customResourceClass - the class of the custom resource
      kubernetesClient - the Kubernetes client
      defaultNamespace - the default namespace
  • Method Details

    • create

      public CompletableFuture<R> create(R resource)
      Creates a new resource
      Parameters:
      resource - the resource to create
      Returns:
      a future that will be completed when the resource is created. The future will contain the created resource
    • create

      public CompletableFuture<R> create(String namespace, R resource)
      Creates a new resource
      Parameters:
      namespace - the namespace to create the resource in
      resource - the resource to create
      Returns:
      a future that will be completed when the resource is created. The future will contain the created resource
    • update

      public CompletableFuture<R> update(R resource)
      Updates a resource
      Parameters:
      resource - the resource to update
      Returns:
      a future that will be completed when the resource is updated. The future will contain the updated resource
    • update

      public CompletableFuture<R> update(String namespace, R resource)
      Updates a resource
      Parameters:
      namespace - the namespace to update the resource in
      resource - the resource to update
      Returns:
      a future that will be completed when the resource is updated. The future will contain the updated resource
    • update

      public CompletableFuture<R> update(String name, Consumer<R> updater)
      Updates a resource
      Parameters:
      name - the name of the resource to update
      updater - a function that will be called with the resource to update
      Returns:
      a future that will be completed when the resource is updated. The future will contain the updated resource
    • update

      public CompletableFuture<R> update(String namespace, String name, Consumer<R> updater)
      Updates a resource
      Parameters:
      namespace - the namespace to update the resource in
      name - the name of the resource to update
      updater - a function that will be called with the resource to update
      Returns:
      a future that will be completed when the resource is updated. The future will contain the updated resource
    • get

      public CompletableFuture<R> get(String name)
      Gets a resource
      Parameters:
      name - the name of the resource to get
      Returns:
      a future that will be completed when the resource is retrieved. The future will contain the resource
    • get

      public CompletableFuture<R> get(String namespace, String name)
      Gets a resource
      Parameters:
      namespace - the namespace to get the resource from
      name - the name of the resource to get
      Returns:
      a future that will be completed when the resource is retrieved. The future will contain the resource
    • list

      public CompletableFuture<List<R>> list()
      Lists all resources
      Returns:
      a future that will be completed when the resources are listed. The future will contain a list of resources
    • list

      public CompletableFuture<List<R>> list(String namespace)
      Lists all resources
      Parameters:
      namespace - the namespace to list the resources from
      Returns:
      a future that will be completed when the resources are listed. The future will contain a list of resources
    • delete

      public CompletableFuture<Void> delete(String name)
      Deletes a resource
      Parameters:
      name - the name of the resource to delete
      Returns:
      a future that will be completed when the resource is deleted
    • delete

      public CompletableFuture<Void> delete(String namespace, String name)
      Deletes a resource
      Parameters:
      namespace - the namespace to delete the resource from
      name - the name of the resource to delete
      Returns:
      a future that will be completed when the resource is deleted
    • createInformer

      Creates an informer builder for a resource in the default namespace
      Returns:
      a builder for the informer
    • createInformer

      public KubernetesCrudRepository<R>.CrudResourceInformerBuilder createInformer(String namespace)
      Creates an informer builder for a resource
      Parameters:
      namespace - the namespace to inform the resource in
      Returns:
      a builder for the informer