use of org.eclipse.che.api.workspace.server.wsplugins.model.Volume in project che-server by eclipse-che.
the class ChePluginsVolumeApplier method provisionPVCPodVolume.
private io.fabric8.kubernetes.api.model.Volume provisionPVCPodVolume(Volume volume, KubernetesEnvironment.PodData pod, KubernetesEnvironment k8sEnv) {
String pvcName = volume.getName();
if (!k8sEnv.getPersistentVolumeClaims().containsKey(pvcName)) {
final PersistentVolumeClaim pvc = newPVC(pvcName, pvcAccessMode, pvcQuantity, pvcStorageClassName);
k8sEnv.getPersistentVolumeClaims().put(pvcName, pvc);
}
PodSpec podSpec = pod.getSpec();
Optional<io.fabric8.kubernetes.api.model.Volume> volumeOpt = podSpec.getVolumes().stream().filter(vm -> vm.getPersistentVolumeClaim() != null && pvcName.equals(vm.getPersistentVolumeClaim().getClaimName())).findAny();
io.fabric8.kubernetes.api.model.Volume podVolume;
if (volumeOpt.isPresent()) {
podVolume = volumeOpt.get();
} else {
podVolume = newVolume(pvcName, pvcName);
podSpec.getVolumes().add(podVolume);
}
return podVolume;
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.Volume in project che-server by eclipse-che.
the class ChePluginsVolumeApplier method applyVolumes.
public void applyVolumes(KubernetesEnvironment.PodData pod, Container container, Collection<Volume> volumes, KubernetesEnvironment k8sEnv) {
for (Volume volume : volumes) {
String podVolumeName = provisionPodVolume(volume, pod, k8sEnv);
container.getVolumeMounts().add(newVolumeMount(podVolumeName, volume.getMountPath(), ""));
}
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.Volume in project che-server by eclipse-che.
the class KubernetesPluginsToolingApplierTest method createContainer.
private CheContainer createContainer(String name, Command... commands) {
CheContainer cheContainer = new CheContainer();
cheContainer.setImage(TEST_IMAGE);
cheContainer.setName(name);
cheContainer.setEnv(singletonList(new EnvVar().name(ENV_VAR).value(ENV_VAR_VALUE)));
cheContainer.setVolumes(singletonList(new Volume().name(VOLUME_NAME).mountPath(VOLUME_MOUNT_PATH)));
cheContainer.setCommands(Arrays.asList(commands));
return cheContainer;
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.Volume in project che-server by eclipse-che.
the class KubernetesPluginsToolingApplierTest method addsMachinesWithVolumesToAllToolingContainer.
@Test
public void addsMachinesWithVolumesToAllToolingContainer() throws Exception {
// given
ChePlugin chePluginWithNonDefaultVolume = createChePlugin();
String anotherVolumeName = VOLUME_NAME + "1";
String anotherVolumeMountPath = VOLUME_MOUNT_PATH + "/something";
List<Volume> volumes = singletonList(new Volume().name(anotherVolumeName).mountPath(anotherVolumeMountPath));
CheContainer toolingContainer = chePluginWithNonDefaultVolume.getContainers().get(0);
toolingContainer.setVolumes(volumes);
ChePlugin chePlugin = createChePlugin();
// when
applier.apply(runtimeIdentity, internalEnvironment, asList(chePlugin, chePluginWithNonDefaultVolume));
// then
Collection<InternalMachineConfig> machineConfigs = getNonUserMachines(internalEnvironment);
assertEquals(machineConfigs.size(), 2);
verify(chePluginsVolumeApplier).applyVolumes(any(PodData.class), any(Container.class), eq(chePlugin.getContainers().get(0).getVolumes()), eq(internalEnvironment));
}
use of org.eclipse.che.api.workspace.server.wsplugins.model.Volume in project devspaces-images by redhat-developer.
the class KubernetesPluginsToolingApplierTest method addsMachinesWithVolumesToAllToolingContainer.
@Test
public void addsMachinesWithVolumesToAllToolingContainer() throws Exception {
// given
ChePlugin chePluginWithNonDefaultVolume = createChePlugin();
String anotherVolumeName = VOLUME_NAME + "1";
String anotherVolumeMountPath = VOLUME_MOUNT_PATH + "/something";
List<Volume> volumes = singletonList(new Volume().name(anotherVolumeName).mountPath(anotherVolumeMountPath));
CheContainer toolingContainer = chePluginWithNonDefaultVolume.getContainers().get(0);
toolingContainer.setVolumes(volumes);
ChePlugin chePlugin = createChePlugin();
// when
applier.apply(runtimeIdentity, internalEnvironment, asList(chePlugin, chePluginWithNonDefaultVolume));
// then
Collection<InternalMachineConfig> machineConfigs = getNonUserMachines(internalEnvironment);
assertEquals(machineConfigs.size(), 2);
verify(chePluginsVolumeApplier).applyVolumes(any(PodData.class), any(Container.class), eq(chePlugin.getContainers().get(0).getVolumes()), eq(internalEnvironment));
}
Aggregations