Search in sources :

Example 31 with ImageStream

use of io.fabric8.openshift.api.model.ImageStream in project syndesis-qe by syndesisio.

the class CamelK method resetState.

public void resetState() {
    try {
        new File(LOCAL_ARCHIVE_EXTRACT_DIRECTORY + "/kamel").setExecutable(true);
        Runtime.getRuntime().exec(LOCAL_ARCHIVE_EXTRACT_DIRECTORY + "/kamel reset").waitFor();
        List<ImageStream> iss = OpenShiftUtils.getInstance().imageStreams().inNamespace(TestConfiguration.openShiftNamespace()).list().getItems().stream().filter(imageStream -> imageStream.getMetadata().getName().contains("camel-k-ctx")).collect(Collectors.toList());
        OpenShiftUtils.getInstance().pods().delete(OpenShiftUtils.getInstance().pods().list().getItems().stream().filter(pod -> pod.getMetadata().getName().startsWith("camel-k-ctx")).collect(Collectors.toList()));
        OpenShiftUtils.getInstance().imageStreams().delete(iss);
    } catch (Exception e) {
        fail("Unable to invoke kamel binary", e);
    }
}
Also used : BufferedInputStream(java.io.BufferedInputStream) ArchiveEntry(org.apache.commons.compress.archivers.ArchiveEntry) TarArchiveInputStream(org.apache.commons.compress.archivers.tar.TarArchiveInputStream) URL(java.net.URL) CustomResourceDefinitionContext(io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext) Image(io.syndesis.qe.image.Image) Map(java.util.Map) OpenShift(cz.xtf.core.openshift.OpenShift) Path(java.nio.file.Path) GzipCompressorInputStream(org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream) ImageStream(io.fabric8.openshift.api.model.ImageStream) TestConfiguration(io.syndesis.qe.TestConfiguration) InfraFail(io.syndesis.qe.test.InfraFail) Assumptions.assumeThat(org.assertj.core.api.Assumptions.assumeThat) Files(java.nio.file.Files) FileUtils(org.apache.commons.io.FileUtils) IOException(java.io.IOException) OpenShiftUtils(io.syndesis.qe.utils.OpenShiftUtils) Collectors(java.util.stream.Collectors) File(java.io.File) StandardCharsets(java.nio.charset.StandardCharsets) TestSupport(io.syndesis.qe.endpoints.TestSupport) Resource(io.syndesis.qe.resource.Resource) IOUtils(org.apache.commons.io.IOUtils) List(java.util.List) CustomResourceDefinition(io.fabric8.kubernetes.api.model.apiextensions.CustomResourceDefinition) Slf4j(lombok.extern.slf4j.Slf4j) Assertions.fail(org.assertj.core.api.Assertions.fail) TestUtils(io.syndesis.qe.utils.TestUtils) Paths(java.nio.file.Paths) ResourceFactory(io.syndesis.qe.resource.ResourceFactory) OpenShiftWaitUtils(io.syndesis.qe.wait.OpenShiftWaitUtils) ImageStream(io.fabric8.openshift.api.model.ImageStream) File(java.io.File) IOException(java.io.IOException)

Example 32 with ImageStream

use of io.fabric8.openshift.api.model.ImageStream in project fabric8 by jboss-fuse.

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)

Example 33 with ImageStream

use of io.fabric8.openshift.api.model.ImageStream in project fabric8 by jboss-fuse.

the class Controller method copyAllImageStreamTags.

protected void copyAllImageStreamTags(ImageStream from, ImageStream to) {
    ImageStreamSpec toSpec = to.getSpec();
    if (toSpec == null) {
        toSpec = new ImageStreamSpec();
        to.setSpec(toSpec);
    }
    List<TagReference> toTags = toSpec.getTags();
    if (toTags == null) {
        toTags = new ArrayList<>();
        toSpec.setTags(toTags);
    }
    ImageStreamSpec fromSpec = from.getSpec();
    if (fromSpec != null) {
        List<TagReference> fromTags = fromSpec.getTags();
        if (fromTags != null) {
            // lets remove all the tags with these names first
            for (TagReference tag : fromTags) {
                removeTagByName(toTags, tag.getName());
            }
            // now lets add them all in case 2 tags have the same name
            for (TagReference tag : fromTags) {
                toTags.add(tag);
            }
        }
    }
}
Also used : ImageStreamSpec(io.fabric8.openshift.api.model.ImageStreamSpec) TagReference(io.fabric8.openshift.api.model.TagReference)

Aggregations

ImageStream (io.fabric8.openshift.api.model.ImageStream)21 IOException (java.io.IOException)11 BuildConfig (io.fabric8.openshift.api.model.BuildConfig)9 DeploymentConfig (io.fabric8.openshift.api.model.DeploymentConfig)9 Service (io.fabric8.kubernetes.api.model.Service)7 KubernetesClientException (io.fabric8.kubernetes.client.KubernetesClientException)7 Test (org.junit.Test)7 ConfigMap (io.fabric8.kubernetes.api.model.ConfigMap)6 Secret (io.fabric8.kubernetes.api.model.Secret)5 File (java.io.File)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)4 HasMetadata (io.fabric8.kubernetes.api.model.HasMetadata)4 ServiceAccount (io.fabric8.kubernetes.api.model.ServiceAccount)4 DoneableImageStream (io.fabric8.openshift.api.model.DoneableImageStream)4 OpenShiftClient (io.fabric8.openshift.client.OpenShiftClient)4 Reconciliation (io.strimzi.controller.cluster.Reconciliation)4 KafkaConnectS2ICluster (io.strimzi.controller.cluster.model.KafkaConnectS2ICluster)4 BuildConfigOperator (io.strimzi.controller.cluster.operator.resource.BuildConfigOperator)4 ConfigMapOperator (io.strimzi.controller.cluster.operator.resource.ConfigMapOperator)4 DeploymentConfigOperator (io.strimzi.controller.cluster.operator.resource.DeploymentConfigOperator)4