VolumeUtils { public static Volume createConfigMapVolume(String name, String configMapName) { String validName = getValidVolumeName(name); ConfigMapVolumeSource configMapVolumeSource = new ConfigMapVolumeSourceBuilder() .withName(configMapName) .build(); Volume volume = new VolumeBuilder() .withName(validName) .withConfigMap(configMapVolumeSource) .build(); log.trace("Created configMap Volume named '{}' with source configMap '{}'", validName, configMapName); return volume; }  static Volume createConfigMapVolume(String name, String configMapName); static Volume createSecretVolume(String name, String secretName, Map<String, String> items, boolean isOpenshift); static Volume createSecretVolume(String name, String secretName, boolean isOpenshift); static Volume createEmptyDirVolume(String name, String sizeLimit); static PersistentVolumeClaim createPersistentVolumeClaimTemplate(String name, PersistentClaimStorage storage); static VolumeMount createVolumeMount(String name, String path); static List<Volume> getDataVolumes(Storage storage); static List<PersistentVolumeClaim> getDataPersistentVolumeClaims(Storage storage); static List<VolumeMount> getDataVolumeMountPaths(Storage storage, String mountPath); static String getVolumePrefix(Integer id); static String getValidVolumeName(String originalName);  }
@Test public void testCreateConfigMapVolumeWithValidName() { Volume volume = VolumeUtils.createConfigMapVolume("oauth-my-cm", "my-cm"); assertThat(volume.getName(), is("oauth-my-cm")); }
@Test public void testCreateConfigMapVolumeWithInvalidName() { Volume volume = VolumeUtils.createConfigMapVolume("oauth-my.cm", "my.cm"); assertThat(volume.getName(), is("oauth-my-cm-62fdd747")); }