in PluginsAndFeatures/azure-toolkit-for-eclipse/com.microsoft.azuretools.container/src/main/java/com/microsoft/azuretools/container/ui/DockerRunDialog.java [251:309]
private void validate() throws InvalidFormDataException {
if (dataModel == null) {
throw new InvalidFormDataException(MISSING_MODEL);
}
// docker file
if (Utils.isEmptyString(dataModel.getDockerFilePath())) {
throw new InvalidFormDataException(INVALID_DOCKER_FILE);
}
File dockerFile = Paths.get(dataModel.getDockerFilePath()).toFile();
if (!dockerFile.exists() || !dockerFile.isFile()) {
throw new InvalidFormDataException(INVALID_DOCKER_FILE);
}
// cert path
if (dataModel.isTlsEnabled()) {
if (Utils.isEmptyString(dataModel.getDockerCertPath())) {
throw new InvalidFormDataException(INVALID_CERT_PATH);
}
File certPath = Paths.get(dataModel.getDockerCertPath()).toFile();
if (!certPath.exists() || !certPath.isDirectory()) {
throw new InvalidFormDataException(INVALID_CERT_PATH);
}
}
String imageName = dataModel.getImageName();
String tagName = dataModel.getTagName();
if (Utils.isEmptyString(imageName) || Utils.isEmptyString(tagName)) {
throw new InvalidFormDataException(MISSING_IMAGE_WITH_TAG);
}
// check repository first
if (imageName.length() < 1 || imageName.length() > REPO_LENGTH) {
throw new InvalidFormDataException(REPO_LENGTH_INVALID);
}
if (imageName.endsWith("/")) {
throw new InvalidFormDataException(CANNOT_END_WITH_SLASH);
}
final String[] repoComponents = imageName.split("/");
for (String component : repoComponents) {
if (!component.matches(REPO_COMPONENTS_REGEX)) {
throw new InvalidFormDataException(
String.format(REPO_COMPONENT_INVALID, component, REPO_COMPONENTS_REGEX));
}
}
// check tag
if (tagName.length() > TAG_LENGTH) {
throw new InvalidFormDataException(TAG_LENGTH_INVALID);
}
if (!tagName.matches(TAG_REGEX)) {
throw new InvalidFormDataException(String.format(TAG_INVALID, tagName, TAG_REGEX));
}
// target package
if (Utils.isEmptyString(dataModel.getTargetName())) {
throw new InvalidFormDataException(MISSING_ARTIFACT);
}
if (!dataModel.getTargetName().matches(ARTIFACT_NAME_REGEX)) {
throw new InvalidFormDataException(String.format(INVALID_ARTIFACT_FILE, dataModel.getTargetName()));
}
}