com.transferwise.tasks.EnvironmentValidator Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of tw-tasks-core Show documentation
Show all versions of tw-tasks-core Show documentation
Transferwise Tasks Executor - Fire and forget until Alert.
package com.transferwise.tasks;
import com.vdurmont.semver4j.Semver;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
public class EnvironmentValidator implements IEnvironmentValidator {
@Autowired
private TasksProperties tasksProperties;
@Override
public void validate() {
String previousVersion = tasksProperties.getEnvironment().getPreviousVersion();
if (StringUtils.trimToNull(previousVersion) == null) {
throw new IllegalStateException("Previous version has not been specified.");
}
Semver previousSemver = new Semver(previousVersion);
Semver minimumRequiredPreviousSemver = new Semver("1.21.1");
if (previousSemver.compareTo(minimumRequiredPreviousSemver) < 0) {
throw new IllegalStateException("This version requires at least '" + minimumRequiredPreviousSemver + "' to be deployed first.");
}
}
}