'Given an array of Docker volumes return a set of volumes and a set of volumeMounts'

@classmethod
def get_k8s_volumes(cls, docker_volumes):

    volumes = []
    volume_mounts = []
    for vol in docker_volumes:
        source = None
        destination = None
        permissions = None
        if (':' in vol):
            pieces = vol.split(':')
            if (len(pieces) == 3):
                (source, destination, permissions) = vol.split(':')
            elif (len(pieces) == 2):
                if (pieces[1] in cls.DOCKER_VOL_PERMISSIONS):
                    (destination, permissions) = vol.split(':')
                else:
                    (source, destination) = vol.split(':')
        else:
            destination = vol
        if destination:
            name = re.sub('\\/', '-', destination)
            name = re.sub('-', '', name, 1)
        if source:
            if re.match('\\$', source):
                continue
            elif re.match('[~./]', source):
                source = os.path.abspath(os.path.normpath(os.path.expanduser(source)))
                volumes.append(dict(name=name, hostPath=dict(path=source)))
            else:
                name = source
                volumes.append(dict(name=name, persistentVolumeClaim=dict(claimName=name)))
        else:
            volumes.append(dict(name=name, emptyDir=dict(medium='')))
        volume_mounts.append(dict(mountPath=destination, name=name, readOnly=(True if (permissions == 'ro') else False)))
    return (volumes, volume_mounts)
