Search in sources :

Example 1 with DoneableImageStream

use of io.fabric8.openshift.api.model.DoneableImageStream in project fabric8 by fabric8io.

the class Controller method applyImageStream.

public void applyImageStream(ImageStream entity, String sourceName) {
    OpenShiftClient openShiftClient = getOpenShiftClientOrNull();
    if (openShiftClient != null && openShiftClient.supportsOpenShiftAPIGroup(OpenShiftAPIGroups.IMAGE)) {
        String kind = getKind(entity);
        String name = getName(entity);
        String namespace = getNamespace();
        try {
            Resource<ImageStream, DoneableImageStream> resource = openShiftClient.imageStreams().inNamespace(namespace).withName(name);
            ImageStream old = resource.get();
            if (old == null) {
                LOG.info("Creating " + kind + " " + name + " from " + sourceName);
                resource.create(entity);
            } else {
                LOG.info("Updating " + kind + " " + name + " from " + sourceName);
                copyAllImageStreamTags(entity, old);
                resource.replace(old);
            }
            openShiftClient.resource(entity).inNamespace(namespace).apply();
        } catch (Exception e) {
            onApplyError("Failed to create " + kind + " from " + sourceName + ". " + e, e);
        }
    }
}
Also used : OpenShiftClient(io.fabric8.openshift.client.OpenShiftClient) DoneableImageStream(io.fabric8.openshift.api.model.DoneableImageStream) DoneableImageStream(io.fabric8.openshift.api.model.DoneableImageStream) ImageStream(io.fabric8.openshift.api.model.ImageStream) KubernetesClientException(io.fabric8.kubernetes.client.KubernetesClientException) FileNotFoundException(java.io.FileNotFoundException) OpenShiftNotAvailableException(io.fabric8.openshift.client.OpenShiftNotAvailableException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) IOException(java.io.IOException)

Aggregations

JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)1 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)1 DoneableImageStream (io.fabric8.openshift.api.model.DoneableImageStream)1 ImageStream (io.fabric8.openshift.api.model.ImageStream)1 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)1 OpenShiftNotAvailableException (io.fabric8.openshift.client.OpenShiftNotAvailableException)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1