use of io.fabric8.maven.core.config.VolumeConfig in project fabric8-maven-plugin by fabric8io.
the class PodTemplateHandler method getVolumes.
private List<Volume> getVolumes(ResourceConfig config) {
List<VolumeConfig> volumeConfigs = config.getVolumes();
List<Volume> ret = new ArrayList<>();
if (volumeConfigs != null) {
for (VolumeConfig volumeConfig : volumeConfigs) {
VolumeType type = VolumeType.typeFor(volumeConfig.getType());
if (type != null) {
ret.add(type.fromConfig(volumeConfig));
}
}
}
return ret;
}
use of io.fabric8.maven.core.config.VolumeConfig in project docker-maven-plugin by fabric8io.
the class RunService method createVolumesAsPerVolumeBinds.
/**
* Creates a Volume if a volume is referred to during startup in bind mount mapping and
* a VolumeConfiguration exists
*
* @param hub Service hub
* @param binds volume binds present in ImageConfiguration
* @param volumes VolumeConfigs present
* @return List of volumes created
* @throws DockerAccessException
*/
public List<String> createVolumesAsPerVolumeBinds(ServiceHub hub, List<String> binds, List<VolumeConfiguration> volumes) throws DockerAccessException {
Map<String, Integer> indexMap = new HashMap<>();
List<String> volumesCreated = new ArrayList<>();
for (int index = 0; index < volumes.size(); index++) {
indexMap.put(volumes.get(index).getName(), index);
}
for (String bind : binds) {
if (bind.contains(":")) {
String name = bind.substring(0, bind.indexOf(':'));
Integer volumeConfigIndex = indexMap.get(name);
if (volumeConfigIndex != null) {
VolumeConfiguration volumeConfig = volumes.get(volumeConfigIndex);
hub.getVolumeService().createVolume(volumeConfig);
volumesCreated.add(volumeConfig.getName());
}
}
}
return volumesCreated;
}
Aggregations