use of io.fabric8.openshift.api.model.TagReference in project fabric8 by fabric8io.
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);
}
}
}
}
use of io.fabric8.openshift.api.model.TagReference in project strimzi by strimzi.
the class KafkaConnectS2ICluster method generateSourceImageStream.
/**
* Generate new source ImageStream
*
* @return Source ImageStream resource definition
*/
public ImageStream generateSourceImageStream() {
ObjectReference image = new ObjectReference();
image.setKind("DockerImage");
image.setName(sourceImageBaseName + ":" + sourceImageTag);
TagReference sourceTag = new TagReference();
sourceTag.setName(sourceImageTag);
sourceTag.setFrom(image);
ImageStream imageStream = new ImageStreamBuilder().withNewMetadata().withName(getSourceImageStreamName()).withNamespace(namespace).withLabels(getLabelsWithName(getSourceImageStreamName())).endMetadata().withNewSpec().withLookupPolicy(new ImageLookupPolicyBuilder().withLocal(false).build()).withTags(sourceTag).endSpec().build();
return imageStream;
}
use of io.fabric8.openshift.api.model.TagReference in project fabric8 by fabric8io.
the class Controller method removeTagByName.
/**
* Removes all the tags with the given name
* @return the number of tags removed
*/
private int removeTagByName(List<TagReference> tags, String tagName) {
List<TagReference> removeTags = new ArrayList<>();
for (TagReference tag : tags) {
if (Objects.equal(tagName, tag.getName())) {
removeTags.add(tag);
}
}
tags.removeAll(removeTags);
return removeTags.size();
}
Aggregations