Avoid needless bosh cli execution if target not set
This commit is contained in:
@@ -24,7 +24,6 @@ import org.springframework.ide.vscode.commons.languageserver.util.Settings;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleLanguageServer;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleTextDocumentService;
|
||||
import org.springframework.ide.vscode.commons.languageserver.util.SimpleWorkspaceService;
|
||||
import org.springframework.ide.vscode.commons.util.text.LanguageId;
|
||||
import org.springframework.ide.vscode.commons.util.text.TextDocument;
|
||||
import org.springframework.ide.vscode.commons.yaml.ast.YamlAstCache;
|
||||
import org.springframework.ide.vscode.commons.yaml.completion.SchemaBasedYamlAssistContextProvider;
|
||||
|
||||
@@ -86,6 +86,10 @@ public abstract class BoshCommandBasedModelProvider<T> implements DynamicModelPr
|
||||
}
|
||||
commandAndArgs.add(command);
|
||||
String target = config.getTarget();
|
||||
if (target==null && !StringUtil.hasText(System.getenv("BOSH_ENVIRONMENT"))) {
|
||||
//See https://www.pivotaltracker.com/story/show/150309966
|
||||
return null;
|
||||
}
|
||||
if (target!=null) {
|
||||
commandAndArgs.add("-e");
|
||||
commandAndArgs.add(target);
|
||||
|
||||
@@ -82,13 +82,13 @@ public class BoshCommandStemcellsProviderTest {
|
||||
// verify(provider).executeCommand(eq(new ExternalCommand("bosh", "stemcells", "--json")));
|
||||
// }
|
||||
|
||||
@Test public void obeysCliConfigCommand() throws Exception {
|
||||
@Test public void obeysCliConfigCommandAndTarget() throws Exception {
|
||||
Map<String, Object> settings = ImmutableMap.of("bosh", ImmutableMap.of("cli",
|
||||
ImmutableMap.of(
|
||||
"command", "alternate-command"
|
||||
"command", "alternate-command",
|
||||
"target", "some-target"
|
||||
)
|
||||
));
|
||||
|
||||
cliConfig.handleConfigurationChange(new Settings(settings));
|
||||
assertEquals(ImmutableList.of(
|
||||
new StemcellData("bosh-vsphere-esxi-centos-7-go_agent", "3421.11", "centos-7"),
|
||||
@@ -96,7 +96,7 @@ public class BoshCommandStemcellsProviderTest {
|
||||
),
|
||||
provider.getModel(mock(DynamicSchemaContext.class)).getStemcells()
|
||||
);
|
||||
verify(provider).executeCommand(eq(new ExternalCommand("alternate-command", "stemcells", "--json")));
|
||||
verify(provider).executeCommand(eq(new ExternalCommand("alternate-command", "-e", "some-target", "stemcells", "--json")));
|
||||
}
|
||||
|
||||
@Test public void obeysCliConfigTarget() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user