diff --git a/spring-cloud-launcher/spring-cloud-launcher-deployer/src/main/java/org/springframework/cloud/launcher/deployer/DeployerThread.java b/spring-cloud-launcher/spring-cloud-launcher-deployer/src/main/java/org/springframework/cloud/launcher/deployer/DeployerThread.java index 0b57bc3..a3ab1fe 100644 --- a/spring-cloud-launcher/spring-cloud-launcher-deployer/src/main/java/org/springframework/cloud/launcher/deployer/DeployerThread.java +++ b/spring-cloud-launcher/spring-cloud-launcher-deployer/src/main/java/org/springframework/cloud/launcher/deployer/DeployerThread.java @@ -215,6 +215,21 @@ public class DeployerThread extends Thread { DeployerProperties properties = context.getBean(DeployerProperties.class); + ArrayList 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 deployables = new ArrayList<>( properties.getDeployables().values()); OrderComparator.sort(deployables); diff --git a/spring-cloud-launcher/spring-cloud-launcher-deployer/src/test/java/org/springframework/cloud/launcher/deployer/DeployerThreadTests.java b/spring-cloud-launcher/spring-cloud-launcher-deployer/src/test/java/org/springframework/cloud/launcher/deployer/DeployerThreadTests.java index f360666..14217f2 100644 --- a/spring-cloud-launcher/spring-cloud-launcher-deployer/src/test/java/org/springframework/cloud/launcher/deployer/DeployerThreadTests.java +++ b/spring-cloud-launcher/spring-cloud-launcher-deployer/src/test/java/org/springframework/cloud/launcher/deployer/DeployerThreadTests.java @@ -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'")); + } }