Search in sources :

Example 1 with TagReference

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);
            }
        }
    }
}
Also used : ImageStreamSpec(io.fabric8.openshift.api.model.ImageStreamSpec) TagReference(io.fabric8.openshift.api.model.TagReference)

Example 2 with TagReference

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;
}
Also used : ImageStreamBuilder(io.fabric8.openshift.api.model.ImageStreamBuilder) ObjectReference(io.fabric8.kubernetes.api.model.ObjectReference) ImageStream(io.fabric8.openshift.api.model.ImageStream) TagReference(io.fabric8.openshift.api.model.TagReference) ImageLookupPolicyBuilder(io.fabric8.openshift.api.model.ImageLookupPolicyBuilder)

Example 3 with TagReference

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();
}
Also used : ArrayList(java.util.ArrayList) TagReference(io.fabric8.openshift.api.model.TagReference)

Aggregations

TagReference (io.fabric8.openshift.api.model.TagReference)3 ObjectReference (io.fabric8.kubernetes.api.model.ObjectReference)1 ImageLookupPolicyBuilder (io.fabric8.openshift.api.model.ImageLookupPolicyBuilder)1 ImageStream (io.fabric8.openshift.api.model.ImageStream)1 ImageStreamBuilder (io.fabric8.openshift.api.model.ImageStreamBuilder)1 ImageStreamSpec (io.fabric8.openshift.api.model.ImageStreamSpec)1 ArrayList (java.util.ArrayList)1