use of io.fabric8.openshift.api.model.ImageStream in project strimzi by strimzi.
the class KafkaConnectS2IClusterTest method testGenerateSourceImageStream.
@Test
public void testGenerateSourceImageStream() {
ImageStream is = kc.generateSourceImageStream();
assertEquals(kc.getSourceImageStreamName(), is.getMetadata().getName());
assertEquals(namespace, is.getMetadata().getNamespace());
assertEquals(ResourceUtils.labels(Labels.STRIMZI_CLUSTER_LABEL, cluster, Labels.STRIMZI_TYPE_LABEL, "kafka-connect-s2i", "my-user-label", "cromulent", Labels.STRIMZI_NAME_LABEL, kc.getSourceImageStreamName()), is.getMetadata().getLabels());
assertEquals(false, is.getSpec().getLookupPolicy().getLocal());
assertEquals(1, is.getSpec().getTags().size());
assertEquals(image.substring(image.lastIndexOf(":") + 1), is.getSpec().getTags().get(0).getName());
assertEquals("DockerImage", is.getSpec().getTags().get(0).getFrom().getKind());
assertEquals(image, is.getSpec().getTags().get(0).getFrom().getName());
}
use of io.fabric8.openshift.api.model.ImageStream in project strimzi by strimzi.
the class KafkaConnectS2IClusterTest method testGenerateTargetImageStream.
@Test
public void testGenerateTargetImageStream() {
ImageStream is = kc.generateTargetImageStream();
assertEquals(kc.kafkaConnectClusterName(cluster), is.getMetadata().getName());
assertEquals(namespace, is.getMetadata().getNamespace());
assertEquals(ResourceUtils.labels(Labels.STRIMZI_CLUSTER_LABEL, cluster, Labels.STRIMZI_TYPE_LABEL, "kafka-connect-s2i", "my-user-label", "cromulent", Labels.STRIMZI_NAME_LABEL, kc.kafkaConnectClusterName(cluster)), is.getMetadata().getLabels());
assertEquals(true, is.getSpec().getLookupPolicy().getLocal());
}
use of io.fabric8.openshift.api.model.ImageStream in project vertx-openshift-it by cescoffier.
the class Deployment method deployIfNeeded.
public static String deployIfNeeded(KubernetesClient client, String name, String path) {
if (oc(client).deploymentConfigs().withName(name).get() != null) {
System.out.println("Skipping the creation of dc/" + name);
return name;
}
ImageStream stream = findImageStream(client, name);
ensureThat("the image stream " + name + " exists in the namespace " + client.getNamespace(), () -> assertThat(stream).isNotNull());
File file = filter(Objects.requireNonNull(path), ImmutableMap.of("image", stream.getStatus().getDockerImageRepository()));
String name2 = deployIfNeeded(client, file);
assertThat(name).isEqualTo(name2);
return name;
}
use of io.fabric8.openshift.api.model.ImageStream in project kie-wb-common by kiegroup.
the class OpenShiftClient method createFromUri.
private void createFromUri(String prjName, String uri) throws OpenShiftClientException {
URL url = toUrl(uri);
if (url != null) {
KubernetesList kubeList = delegate.lists().load(url).get();
List<HasMetadata> items = kubeList.getItems();
if (items.size() > 0) {
for (HasMetadata item : items) {
String name = item.getMetadata().getName();
if (item instanceof ServiceAccount) {
if (delegate.serviceAccounts().inNamespace(prjName).withName(name).get() == null) {
setGuvnorAlaGenerated(item);
}
} else if (item instanceof Secret) {
if (delegate.secrets().inNamespace(prjName).withName(name).get() == null) {
setGuvnorAlaGenerated(item);
}
} else if (item instanceof ImageStream) {
if (delegate.imageStreams().inNamespace(prjName).withName(name).get() == null) {
setGuvnorAlaGenerated(item);
}
}
}
delegate.lists().inNamespace(prjName).create(kubeList);
}
}
}
use of io.fabric8.openshift.api.model.ImageStream in project fabric8 by jboss-fuse.
the class Controller method applyEntity.
/**
* Applies the given DTOs onto the Kubernetes master
*/
public void applyEntity(Object dto, String sourceName) throws Exception {
if (dto instanceof Pod) {
applyPod((Pod) dto, sourceName);
} else if (dto instanceof ReplicationController) {
applyReplicationController((ReplicationController) dto, sourceName);
} else if (dto instanceof Service) {
applyService((Service) dto, sourceName);
} else if (dto instanceof Namespace) {
applyNamespace((Namespace) dto);
} else if (dto instanceof Route) {
applyRoute((Route) dto, sourceName);
} else if (dto instanceof BuildConfig) {
applyBuildConfig((BuildConfig) dto, sourceName);
} else if (dto instanceof DeploymentConfig) {
DeploymentConfig resource = (DeploymentConfig) dto;
OpenShiftClient openShiftClient = getOpenShiftClientOrNull();
if (openShiftClient != null && openShiftClient.supportsOpenShiftAPIGroup(OpenShiftAPIGroups.APPS)) {
applyResource(resource, sourceName, openShiftClient.deploymentConfigs());
} else {
LOG.warn("Not connected to OpenShift cluster so cannot apply entity " + dto);
}
} else if (dto instanceof PolicyBinding) {
applyPolicyBinding((PolicyBinding) dto, sourceName);
} else if (dto instanceof RoleBinding) {
applyRoleBinding((RoleBinding) dto, sourceName);
} else if (dto instanceof Role) {
Role resource = (Role) dto;
OpenShiftClient openShiftClient = getOpenShiftClientOrNull();
if (openShiftClient != null && openShiftClient.supportsOpenShiftAPIGroup(OpenShiftAPIGroups.AUTHORIZATION)) {
applyResource(resource, sourceName, openShiftClient.roles());
} else {
LOG.warn("Not connected to OpenShift cluster so cannot apply entity " + dto);
}
} else if (dto instanceof ImageStream) {
applyImageStream((ImageStream) dto, sourceName);
} else if (dto instanceof OAuthClient) {
applyOAuthClient((OAuthClient) dto, sourceName);
} else if (dto instanceof Template) {
applyTemplate((Template) dto, sourceName);
} else if (dto instanceof ServiceAccount) {
applyServiceAccount((ServiceAccount) dto, sourceName);
} else if (dto instanceof Secret) {
applySecret((Secret) dto, sourceName);
} else if (dto instanceof ConfigMap) {
applyResource((ConfigMap) dto, sourceName, kubernetesClient.configMaps());
} else if (dto instanceof DaemonSet) {
applyResource((DaemonSet) dto, sourceName, kubernetesClient.extensions().daemonSets());
} else if (dto instanceof Deployment) {
applyResource((Deployment) dto, sourceName, kubernetesClient.extensions().deployments());
} else if (dto instanceof ReplicaSet) {
applyResource((ReplicaSet) dto, sourceName, kubernetesClient.extensions().replicaSets());
} else if (dto instanceof StatefulSet) {
applyResource((StatefulSet) dto, sourceName, kubernetesClient.apps().statefulSets());
} else if (dto instanceof Ingress) {
applyResource((Ingress) dto, sourceName, kubernetesClient.extensions().ingresses());
} else if (dto instanceof PersistentVolumeClaim) {
applyPersistentVolumeClaim((PersistentVolumeClaim) dto, sourceName);
} else if (dto instanceof HasMetadata) {
HasMetadata entity = (HasMetadata) dto;
try {
String namespace = getNamespace();
String resourceNamespace = getNamespace(entity);
if (Strings.isNotBlank(namespace) && Strings.isNullOrBlank(resourceNamespace)) {
getOrCreateMetadata(entity).setNamespace(namespace);
}
LOG.info("Applying " + getKind(entity) + " " + getName(entity) + " from " + sourceName);
kubernetesClient.resource(entity).inNamespace(namespace).createOrReplace();
} catch (Exception e) {
onApplyError("Failed to create " + getKind(entity) + " from " + sourceName + ". " + e, e);
}
} else {
throw new IllegalArgumentException("Unknown entity type " + dto);
}
}
Aggregations