Search in sources :

Example 1 with MountType

use of org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunResourceVolumesVariablesModel.MountType in project linuxtools by eclipse.

the class ContainerDataVolumeDialog method validateInput.

private IStatus validateInput() {
    final String containerPath = model.getContainerPath();
    final MountType mountType = model.getMountType();
    final String hostPath = model.getHostPathMount();
    if (containerPath == null || containerPath.isEmpty()) {
        return ValidationStatus.error(null);
    } else if (mountType == null) {
        return ValidationStatus.error(null);
    } else if (mountType == MountType.HOST_FILE_SYSTEM && (hostPath == null || hostPath.isEmpty())) {
        return ValidationStatus.error(null);
    } else if (mountType == MountType.HOST_FILE_SYSTEM && !new File(hostPath).exists()) {
        return ValidationStatus.warning(// $NON-NLS-1$
        "The specified path does not exist on the host.");
    } else if (mountType == MountType.CONTAINER) {
        final IDockerContainer container = WizardUtils.getContainer(connection, model.getContainerMount());
        if (container == null) {
            // just make sure that the dialog cannot complete
            return ValidationStatus.error(null);
        }
        final IDockerContainerInfo selectedContainerInfo = container.info();
        if (selectedContainerInfo != null && selectedContainerInfo.volumes() != null && !selectedContainerInfo.volumes().containsKey(model.getContainerPath())) {
            return ValidationStatus.warning(WizardMessages.getFormattedString(// $NON-NLS-1$
            "ContainerDataVolumeDialog.volumeWarning", model.getContainerPath()));
        }
    }
    return ValidationStatus.ok();
}
Also used : IDockerContainer(org.eclipse.linuxtools.docker.core.IDockerContainer) MountType(org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunResourceVolumesVariablesModel.MountType) IDockerContainerInfo(org.eclipse.linuxtools.docker.core.IDockerContainerInfo) File(java.io.File)

Aggregations

File (java.io.File)1 IDockerContainer (org.eclipse.linuxtools.docker.core.IDockerContainer)1 IDockerContainerInfo (org.eclipse.linuxtools.docker.core.IDockerContainerInfo)1 MountType (org.eclipse.linuxtools.internal.docker.ui.wizards.ImageRunResourceVolumesVariablesModel.MountType)1