public static List < Protos . Volume > buildVolumes ( Option < String > containerVolumes ) { if ( containerVolumes . isEmpty ( ) ) { return Collections . emptyList ( ) ; } else { String [ ] volumeSpecifications = containerVolumes . get ( ) . split ( "," ) ; List < Protos . Volume > volumes = new ArrayList <> ( volumeSpecifications . length ) ; for ( String volumeSpecification : volumeSpecifications ) { if ( ! volumeSpecification . trim ( ) . isEmpty ( ) ) { Protos . Volume . Builder volume = Protos . Volume . newBuilder ( ) ; volume . setMode ( Protos . Volume . Mode . RW ) ; String [ ] parts = volumeSpecification . split ( ":" ) ; switch ( parts . length ) { case 1 : volume . setContainerPath ( parts [ 0 ] ) ; break ; case 2 : try { Protos . Volume . Mode mode = Protos . Volume . Mode . valueOf ( parts [ 1 ] . trim ( ) . toUpperCase ( ) ) ; volume . setMode ( mode ) . setContainerPath ( parts [ 0 ] ) ; } catch ( IllegalArgumentException e ) { volume . setHostPath ( parts [ 0 ] ) . setContainerPath ( parts [ 1 ] ) ; } break ; case 3 : Protos . Volume . Mode mode = Protos . Volume . Mode . valueOf ( parts [ 2 ] . trim ( ) . toUpperCase ( ) ) ; volume . setMode ( mode ) . setHostPath ( parts [ 0 ] ) . setContainerPath ( parts [ 1 ] ) ; break ; default : throw new IllegalArgumentException ( "volume specification is invalid, given: " + volumeSpecification ) ; } volumes . add ( volume . build ( ) ) ; } } return volumes ; } }
Used to build volume specs for mesos . This allows for mounting additional volumes into a container