Validate items to run are valid.
fixes gh-40
This commit is contained in:
@@ -215,6 +215,21 @@ public class DeployerThread extends Thread {
|
||||
|
||||
DeployerProperties properties = context.getBean(DeployerProperties.class);
|
||||
|
||||
ArrayList<String> invalid = new ArrayList<>();
|
||||
// validate that items in deploy, are valid deployables
|
||||
for (String toDeploy : properties.getDeploy()) {
|
||||
if (!properties.getDeployables().containsKey(toDeploy)) {
|
||||
invalid.add(toDeploy);
|
||||
}
|
||||
}
|
||||
|
||||
if (!invalid.isEmpty()) {
|
||||
logger.error("Error starting 'spring cloud'."+"\n\nThe following are not valid: '" +
|
||||
collectionToCommaDelimitedString(invalid) + "'. Please check the name(s) and try again.\n" +
|
||||
"Valid choices are: "+ collectionToCommaDelimitedString(properties.getDeployables().keySet())+".\n");
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<Deployable> deployables = new ArrayList<>(
|
||||
properties.getDeployables().values());
|
||||
OrderComparator.sort(deployables);
|
||||
|
||||
@@ -36,10 +36,15 @@ public class DeployerThreadTests {
|
||||
assertThat(output.toString(), containsString("configserver"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testNonOptionArgsPassedDown() throws Exception {
|
||||
new DeployerThread(DeployerThread.class.getClassLoader(), "--launcher.list=true", "--spring.profiles.active=test").run();
|
||||
assertThat(output.toString(), containsString("foo"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testInvalidDeployableFails() throws Exception {
|
||||
new DeployerThread(DeployerThread.class.getClassLoader(), "--launcher.deploy=foo,bar").run();
|
||||
assertThat(output.toString(), containsString("The following are not valid: 'foo,bar'"));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user