Class LocallyRunOperatorExtension

java.lang.Object
io.javaoperatorsdk.operator.junit.AbstractOperatorExtension
io.javaoperatorsdk.operator.junit.LocallyRunOperatorExtension
All Implemented Interfaces:
HasKubernetesClient, org.junit.jupiter.api.extension.AfterAllCallback, org.junit.jupiter.api.extension.AfterEachCallback, org.junit.jupiter.api.extension.BeforeAllCallback, org.junit.jupiter.api.extension.BeforeEachCallback, org.junit.jupiter.api.extension.Extension

public class LocallyRunOperatorExtension extends AbstractOperatorExtension
  • Method Details

    • builder

      public static LocallyRunOperatorExtension.Builder builder()
      Returns:
      the builder.
    • applyCrd

      public static void applyCrd(Class<? extends io.fabric8.kubernetes.api.model.HasMetadata> resourceClass, io.fabric8.kubernetes.client.KubernetesClient client)
    • applyCrd

      public static void applyCrd(String resourceTypeName, io.fabric8.kubernetes.client.KubernetesClient client)
      Applies the CRD associated with the specified resource name to the cluster. Note that the CRD is assumed to have been generated in this case from the Java classes and is therefore expected to be found in the standard location with the default name for such CRDs and assumes a v1 version of the CRD spec is used. This means that, provided a given resourceTypeName, the associated CRD is expected to be found at META-INF/fabric8/resourceTypeName-v1.yml in the project's classpath.
      Parameters:
      resourceTypeName - the standard resource name for CRDs i.e. plural.group
      client - the kubernetes client to use to connect to the cluster
    • applyCrd

      public void applyCrd(Class<? extends io.fabric8.kubernetes.client.CustomResource> crClass)
      Applies the CRD associated with the specified custom resource, first checking if a CRD has been manually specified using LocallyRunOperatorExtension.Builder.withAdditionalCRD(java.lang.String...), otherwise assuming that its CRD should be found in the standard location as explained in applyCrd(String, KubernetesClient)
      Parameters:
      crClass - the custom resource class for which we want to apply the CRD
    • applyCrd

      public void applyCrd(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition customResourceDefinition)
    • applyCrd

      public void applyCrd(String resourceTypeName)
      Applies the CRD associated with the specified resource type name, first checking if a CRD has been manually specified using LocallyRunOperatorExtension.Builder.withAdditionalCRD(java.lang.String...), otherwise assuming that its CRD should be found in the standard location as explained in applyCrd(String, KubernetesClient)
      Parameters:
      resourceTypeName - the resource type name associated with the CRD to be applied, typically, given a resource type, its name would be obtained using ReconcilerUtilsInternal.getResourceTypeName(Class)
    • getReconcilers

      public List<io.javaoperatorsdk.operator.api.reconciler.Reconciler> getReconcilers()
    • getFirstReconciler

      public io.javaoperatorsdk.operator.api.reconciler.Reconciler getFirstReconciler()
    • getReconcilerOfType

      public <T extends io.javaoperatorsdk.operator.api.reconciler.Reconciler> T getReconcilerOfType(Class<T> type)
    • getRegisteredControllerForReconcile

      public io.javaoperatorsdk.operator.RegisteredController getRegisteredControllerForReconcile(Class<? extends io.javaoperatorsdk.operator.api.reconciler.Reconciler> type)
    • getOperator

      public io.javaoperatorsdk.operator.Operator getOperator()
    • before

      protected void before(org.junit.jupiter.api.extension.ExtensionContext context)
      Overrides:
      before in class AbstractOperatorExtension
    • after

      protected void after(org.junit.jupiter.api.extension.ExtensionContext context)
      Overrides:
      after in class AbstractOperatorExtension