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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classLocallyRunOperatorExtension.Builder-
Nested classes/interfaces inherited from class io.javaoperatorsdk.operator.junit.AbstractOperatorExtension
AbstractOperatorExtension.AbstractBuilder<T extends AbstractOperatorExtension.AbstractBuilder<T>>
-
-
Field Summary
-
Fields inherited from class io.javaoperatorsdk.operator.junit.AbstractOperatorExtension
CRD_READY_WAIT, DEFAULT_NAMESPACE_DELETE_TIMEOUT, infrastructure, infrastructureTimeout, MAX_NAMESPACE_NAME_LENGTH, namespace, namespaceDeleteTimeout, namespaceNameSupplier, oneNamespacePerClass, perClassNamespaceNameSupplier, preserveNamespaceOnError, waitForNamespaceDeletion
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidafter(org.junit.jupiter.api.extension.ExtensionContext context)static voidapplyCrd(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition crd, io.fabric8.kubernetes.client.KubernetesClient client)static voidapplyCrd(Class<? extends io.fabric8.kubernetes.api.model.HasMetadata> resourceClass, io.fabric8.kubernetes.client.KubernetesClient client)voidapplyCrd(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 usingLocallyRunOperatorExtension.Builder.withAdditionalCRD(String), otherwise assuming that its CRD should be found in the standard location as explained inapplyCrd(String, KubernetesClient)voidapplyCrd(String resourceTypeName)static voidapplyCrd(String resourceTypeName, io.fabric8.kubernetes.client.KubernetesClient client)Applies the CRD associated with the specified resource name to the cluster.protected voidbefore(org.junit.jupiter.api.extension.ExtensionContext context)static LocallyRunOperatorExtension.Builderbuilder()Creates aLocallyRunOperatorExtension.Builderto set up anLocallyRunOperatorExtensioninstance.ReconcilergetFirstReconciler()OperatorgetOperator()<T extends Reconciler>
TgetReconcilerOfType(Class<T> type)List<Reconciler>getReconcilers()RegisteredControllergetRegisteredControllerForReconcile(Class<? extends Reconciler> type)static List<io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition>parseCrds(String path, io.fabric8.kubernetes.client.KubernetesClient client)-
Methods inherited from class io.javaoperatorsdk.operator.junit.AbstractOperatorExtension
afterAll, afterAllImpl, afterEach, afterEachImpl, beforeAll, beforeAllImpl, beforeEach, beforeEachImpl, create, create, delete, delete, deleteOperator, get, getKubernetesClient, getNamespace, replace, replace, resources
-
-
-
-
Method Detail
-
builder
public static LocallyRunOperatorExtension.Builder builder()
Creates aLocallyRunOperatorExtension.Builderto set up anLocallyRunOperatorExtensioninstance.- 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 givenresourceTypeName, the associated CRD is expected to be found atMETA-INF/fabric8/resourceTypeName-v1.ymlin the project's classpath.- Parameters:
resourceTypeName- the standard resource name for CRDs i.e.plural.groupclient- the kubernetes client to use to connect to the cluster
-
applyCrd
public static void applyCrd(io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition crd, io.fabric8.kubernetes.client.KubernetesClient client)
-
parseCrds
public static List<io.fabric8.kubernetes.api.model.apiextensions.v1.CustomResourceDefinition> parseCrds(String path, io.fabric8.kubernetes.client.KubernetesClient client)
-
getReconcilers
public List<Reconciler> getReconcilers()
-
getFirstReconciler
public Reconciler getFirstReconciler()
-
getReconcilerOfType
public <T extends Reconciler> T getReconcilerOfType(Class<T> type)
-
getRegisteredControllerForReconcile
public RegisteredController getRegisteredControllerForReconcile(Class<? extends Reconciler> type)
-
getOperator
public Operator getOperator()
-
before
protected void before(org.junit.jupiter.api.extension.ExtensionContext context)
- Overrides:
beforein classAbstractOperatorExtension
-
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 usingLocallyRunOperatorExtension.Builder.withAdditionalCRD(String), otherwise assuming that its CRD should be found in the standard location as explained inapplyCrd(String, KubernetesClient)- Parameters:
crClass- the custom resource class for which we want to apply the CRD
-
applyCrd
public void applyCrd(String resourceTypeName)
-
after
protected void after(org.junit.jupiter.api.extension.ExtensionContext context)
- Overrides:
afterin classAbstractOperatorExtension
-
-