Search in sources :

Example 1 with KubectlApply

use of io.kubernetes.client.spring.extended.manifests.annotation.KubectlApply in project java by kubernetes-client.

the class KubernetesKubectlApplyProcessor method postProcessAfterInitialization.

public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
    if (!(bean instanceof KubernetesObject)) {
        // no-op
        return bean;
    }
    KubectlApply apply = beanFactory.findAnnotationOnBean(beanName, KubectlApply.class);
    if (apply == null) {
        return bean;
    }
    Class<? extends KubernetesObject> apiTypeClass = (Class<? extends KubernetesObject>) bean.getClass();
    try {
        log.info("@KubectlApply ensuring resource upon bean {}", beanName);
        return apply(apiTypeClass, bean);
    } catch (KubectlException e) {
        log.error("Failed ensuring resource from @KubectlApply", e);
        throw new BeanCreationException("Failed ensuring resource from @KubectlApply", e);
    }
}
Also used : BeanCreationException(org.springframework.beans.factory.BeanCreationException) KubernetesObject(io.kubernetes.client.common.KubernetesObject) KubectlApply(io.kubernetes.client.spring.extended.manifests.annotation.KubectlApply) KubectlException(io.kubernetes.client.extended.kubectl.exception.KubectlException)

Aggregations

KubernetesObject (io.kubernetes.client.common.KubernetesObject)1 KubectlException (io.kubernetes.client.extended.kubectl.exception.KubectlException)1 KubectlApply (io.kubernetes.client.spring.extended.manifests.annotation.KubectlApply)1 BeanCreationException (org.springframework.beans.factory.BeanCreationException)1