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);
}
}
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);
}
}
}
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);
}
}
}
}
Aggregations