io.fabric8.kubernetes.client.CustomResourceDoneable Java Examples

The following examples show how to use io.fabric8.kubernetes.client.CustomResourceDoneable. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ControllerUtils.java    From java-operator-sdk with Apache License 2.0 5 votes vote down vote up
public static <T extends CustomResource> Class<? extends CustomResourceDoneable<T>>
getCustomResourceDoneableClass(ResourceController<T> controller) {
    try {
        Class<? extends CustomResource> customResourceClass = getAnnotation(controller).customResourceClass();
        String className = customResourceClass.getPackage().getName() + "." + customResourceClass.getSimpleName() + "CustomResourceDoneable";

        if (doneableClassCache.containsKey(customResourceClass)) {
            return (Class<? extends CustomResourceDoneable<T>>) doneableClassCache.get(customResourceClass);
        }

        ClassPool pool = ClassPool.getDefault();
        pool.appendClassPath(new LoaderClassPath(Thread.currentThread().getContextClassLoader()));

        CtClass superClass = pool.get(CustomResourceDoneable.class.getName());
        CtClass function = pool.get(Function.class.getName());
        CtClass customResource = pool.get(customResourceClass.getName());
        CtClass[] argTypes = {customResource, function};
        CtClass customDoneable = pool.makeClass(className, superClass);
        CtConstructor ctConstructor = CtNewConstructor.make(argTypes, null, "super($1, $2);", customDoneable);
        customDoneable.addConstructor(ctConstructor);

        Class<? extends CustomResourceDoneable<T>> doneableClass;
        if (JAVA_VERSION >= 9) {
            doneableClass = (Class<? extends CustomResourceDoneable<T>>) customDoneable.toClass(customResourceClass);
        } else {
            doneableClass = (Class<? extends CustomResourceDoneable<T>>) customDoneable.toClass();
        }
        doneableClassCache.put(customResourceClass, doneableClass);
        return doneableClass;
    } catch (CannotCompileException | NotFoundException e) {
        throw new IllegalStateException(e);
    }
}
 
Example #2
Source File: ControllerUtilsTest.java    From java-operator-sdk with Apache License 2.0 5 votes vote down vote up
@Test
public void returnsValuesFromControllerAnnotationFinalizer() {
    assertEquals(DEFAULT_FINALIZER, ControllerUtils.getDefaultFinalizer(new TestCustomResourceController(null)));
    assertEquals(TestCustomResource.class, ControllerUtils.getCustomResourceClass(new TestCustomResourceController(null)));
    assertEquals(CRD_NAME, ControllerUtils.getCrdName(new TestCustomResourceController(null)));
    assertEquals(true, ControllerUtils.getGenerationEventProcessing(new TestCustomResourceController(null)));
    assertTrue(CustomResourceDoneable.class.isAssignableFrom(ControllerUtils.getCustomResourceDoneableClass(new TestCustomResourceController(null))));
}
 
Example #3
Source File: Operator.java    From java-operator-sdk with Apache License 2.0 4 votes vote down vote up
public <T extends CustomResource, L extends CustomResourceList<T>, D extends CustomResourceDoneable<T>> CustomResourceOperationsImpl<T, L, D>
getCustomResourceClients(Class<T> customResourceClass) {
    return customResourceClients.get(customResourceClass);
}
 
Example #4
Source File: IntegrationTestSupport.java    From java-operator-sdk with Apache License 2.0 4 votes vote down vote up
public MixedOperation<TestCustomResource, CustomResourceList, CustomResourceDoneable, Resource<TestCustomResource, CustomResourceDoneable>> getCrOperations() {
    return crOperations;
}
 
Example #5
Source File: Crds.java    From strimzi-kafka-operator with Apache License 2.0 4 votes vote down vote up
public static <D extends CustomResourceDoneable<T>, T extends CustomResource> MixedOperation<KafkaConnectS2I, KafkaConnectS2IList, DoneableKafkaConnectS2I, Resource<KafkaConnectS2I, DoneableKafkaConnectS2I>> kafkaConnectS2iOperation(KubernetesClient client) {
    return client.customResources(Crds.kafkaConnectS2I(), KafkaConnectS2I.class, KafkaConnectS2IList.class, DoneableKafkaConnectS2I.class);
}