Search in sources :

Example 16 with KubectlException

use of io.kubernetes.client.extended.kubectl.exception.KubectlException 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

KubectlException (io.kubernetes.client.extended.kubectl.exception.KubectlException)16 ApiException (io.kubernetes.client.openapi.ApiException)14 KubernetesObject (io.kubernetes.client.common.KubernetesObject)3 IOException (java.io.IOException)3 KubernetesListObject (io.kubernetes.client.common.KubernetesListObject)2 V1Patch (io.kubernetes.client.custom.V1Patch)2 V1Pod (io.kubernetes.client.openapi.models.V1Pod)2 BeanCreationException (org.springframework.beans.factory.BeanCreationException)2 Copy (io.kubernetes.client.Copy)1 Exec (io.kubernetes.client.Exec)1 PodLogs (io.kubernetes.client.PodLogs)1 PortForward (io.kubernetes.client.PortForward)1 AppsV1Api (io.kubernetes.client.openapi.apis.AppsV1Api)1 V1ObjectMeta (io.kubernetes.client.openapi.models.V1ObjectMeta)1 V1ReplicaSet (io.kubernetes.client.openapi.models.V1ReplicaSet)1 V1Status (io.kubernetes.client.openapi.models.V1Status)1 KubectlApply (io.kubernetes.client.spring.extended.manifests.annotation.KubectlApply)1 KubectlCreate (io.kubernetes.client.spring.extended.manifests.annotation.KubectlCreate)1 CopyNotSupportedException (io.kubernetes.client.util.exception.CopyNotSupportedException)1 GenericKubernetesApi (io.kubernetes.client.util.generic.GenericKubernetesApi)1