private void discoverFolderMounts() { List<VolumeMount> volumeMounts = zaleniumPod.getSpec().getContainers().get(0).getVolumeMounts(); List<VolumeMount> validMounts = new ArrayList<>(); volumeMounts.stream() .filter(volumeMount -> !Arrays.asList(PROTECTED_NODE_MOUNT_POINTS).contains(volumeMount.getMountPath())) .forEach(validMounts::add); // Look through the volume mounts to see if the shared folder is mounted if (!validMounts.isEmpty()) { List<Volume> volumes = zaleniumPod.getSpec().getVolumes(); for (VolumeMount validMount : validMounts) { volumes.stream() .filter(volume -> validMount.getName().equalsIgnoreCase(volume.getName())) .findFirst() .ifPresent(volume -> mountedSharedFoldersMap.put(validMount, volume)); } } }
public VolumeMountBuilder( VolumeMountFluent<?> fluent , VolumeMount instance ){ this.fluent = fluent; fluent.withMountPath(instance.getMountPath()); fluent.withName(instance.getName()); fluent.withReadOnly(instance.getReadOnly()); } public VolumeMountBuilder( VolumeMount instance ){
public VolumeMountBuilder(VolumeMountFluent<?> fluent,VolumeMount instance,Boolean validationEnabled){ this.fluent = fluent; fluent.withMountPath(instance.getMountPath()); fluent.withName(instance.getName()); fluent.withReadOnly(instance.getReadOnly()); fluent.withSubPath(instance.getSubPath()); this.validationEnabled = validationEnabled; } public VolumeMountBuilder(VolumeMount instance){
public VolumeMountBuilder( VolumeMountFluent<?> fluent ){ this(fluent, new VolumeMount()); } public VolumeMountBuilder( VolumeMountFluent<?> fluent , VolumeMount instance ){
volumeMounts.put(mountPath, new VolumeMount(mountPath, volumeName, false, null)); volumes.put(volumeName, volume.buildVolume(volumeName)); i++; .noneMatch(vm -> vm.getMountPath().equals( c.getWorkingDir() != null ? c.getWorkingDir() : ContainerTemplate.DEFAULT_WORKING_DIR))) .forEach(c -> c.getVolumeMounts().add(getDefaultVolumeMount(c.getWorkingDir())));
private boolean isVolumeMountAlreadyExists(List<VolumeMount> volumes, String volumeName) { for (VolumeMount v : volumes) { if (volumeName.equals(v.getName())) { return true; } } return false; } });
public static boolean volumeMountExists(String path, Iterable<VolumeMount> existingMounts) { for (VolumeMount mount : existingMounts) { if (mount.getMountPath().equals(path)) { return true; } } return false; } }
final VolumeMount volumeMount = new VolumeMount(); volumeMount.setName(DEFAULT_NAME + "-certs"); volumeMount.setReadOnly(true); volumeMount.setMountPath(TILLER_TLS_CERTS_PATH); container.setVolumeMounts(Arrays.asList(volumeMount));
public VolumeMountBuilder( VolumeMountFluent<?> fluent , VolumeMount instance ){ this.fluent = fluent; fluent.withMountPath(instance.getMountPath()); fluent.withName(instance.getName()); fluent.withReadOnly(instance.getReadOnly()); } public VolumeMountBuilder( VolumeMount instance ){
public VolumeMountBuilder(VolumeMount instance,Boolean validationEnabled){ this.fluent = this; this.withMountPath(instance.getMountPath()); this.withName(instance.getName()); this.withReadOnly(instance.getReadOnly()); this.withSubPath(instance.getSubPath()); this.validationEnabled = validationEnabled; }
public VolumeMountBuilder(VolumeMountFluent<?> fluent,Boolean validationEnabled){ this(fluent, new VolumeMount(), validationEnabled); } public VolumeMountBuilder(VolumeMountFluent<?> fluent,VolumeMount instance){
private boolean isVolumeMountAlreadyExists(List<VolumeMount> volumes, String volumeName) { for (VolumeMount v : volumes) { if (volumeName.equals(v.getName())) { return true; } } return false; } });
private void revertVolumeChanges(StatefulSet current, StatefulSet desired) { Container currentKafka = current.getSpec().getTemplate().getSpec().getContainers().stream().filter(c -> c.getName().equals("kafka")).findFirst().get(); Container desiredKafka = desired.getSpec().getTemplate().getSpec().getContainers().stream().filter(c -> c.getName().equals("kafka")).findFirst().get(); desiredKafka.setVolumeMounts(currentKafka.getVolumeMounts()); StatefulSet updated = new StatefulSetBuilder(desired) .editSpec() .editTemplate() .editSpec() .editFirstContainer() .editMatchingEnv(e -> e.getName().equals(KafkaCluster.ENV_VAR_KAFKA_LOG_DIRS)) .withValue(desiredKafka.getVolumeMounts().stream() .filter(vm -> vm.getMountPath().contains(AbstractModel.VOLUME_NAME)) .map(vm -> vm.getMountPath()) .collect(Collectors.joining(","))) .endEnv() .endContainer() .endSpec() .endTemplate() .endSpec() .build(); desired.setSpec(updated.getSpec()); }
final VolumeMount volumeMount = new VolumeMount(); volumeMount.setName(DEFAULT_NAME + "-certs"); volumeMount.setReadOnly(true); volumeMount.setMountPath(TILLER_TLS_CERTS_PATH); container.setVolumeMounts(Arrays.asList(volumeMount));
public VolumeMountBuilder( VolumeMount instance ){ this.fluent = this; this.withMountPath(instance.getMountPath()); this.withName(instance.getName()); this.withReadOnly(instance.getReadOnly()); }
public VolumeMountFluentImpl(VolumeMount instance){ this.withMountPath(instance.getMountPath()); this.withName(instance.getName()); this.withReadOnly(instance.getReadOnly()); this.withSubPath(instance.getSubPath()); }
private String getMountPath(List<Container> containers, String name){ for (Container container : containers) { List<VolumeMount> volumeMounts = container.getVolumeMounts(); if (volumeMounts != null) { for (VolumeMount volumeMount : volumeMounts) { if (name.equals(volumeMount.getName())){ return volumeMount.getMountPath(); } } } } throw new IllegalArgumentException("No matching volume mount found for volume "+ name); }
public VolumeMountBuilder( VolumeMountFluent<?> fluent ){ this(fluent, new VolumeMount()); } public VolumeMountBuilder( VolumeMountFluent<?> fluent , VolumeMount instance ){
protected List<VolumeMount> getVolumeMounts() { List<VolumeMount> volumeMountList = new ArrayList<>(1); volumeMountList.add(createVolumeMount(logAndMetricsConfigVolumeName, logAndMetricsConfigMountPath)); if (trustedCertificates != null && trustedCertificates.size() > 0) { for (CertSecretSource certSecretSource: trustedCertificates) { // skipping if a volume mount with same Secret name was already added if (!volumeMountList.stream().anyMatch(vm -> vm.getName().equals(certSecretSource.getSecretName()))) { volumeMountList.add(createVolumeMount(certSecretSource.getSecretName(), TLS_CERTS_BASE_VOLUME_MOUNT + certSecretSource.getSecretName())); } } } if (tlsAuthCertAndKey != null) { // skipping if a volume mount with same Secret name was already added if (!volumeMountList.stream().anyMatch(vm -> vm.getName().equals(tlsAuthCertAndKey.getSecretName()))) { volumeMountList.add(createVolumeMount(tlsAuthCertAndKey.getSecretName(), TLS_CERTS_BASE_VOLUME_MOUNT + tlsAuthCertAndKey.getSecretName())); } } else if (passwordSecret != null) { volumeMountList.add(createVolumeMount(passwordSecret.getSecretName(), PASSWORD_VOLUME_MOUNT + passwordSecret.getSecretName())); } volumeMountList.addAll(getExternalConfigurationVolumeMounts()); return volumeMountList; }
.map(volumeMount -> volumeMount.getMountPath()).collect(Collectors.joining(",")); varList.add(buildEnvVar(ENV_VAR_KAFKA_LOG_DIRS, logDirs));