Changes to CF hints provider to return empty list of services
This commit is contained in:
@@ -11,7 +11,6 @@
|
||||
package org.springframework.ide.vscode.manifest.yaml;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
@@ -40,13 +39,13 @@ public abstract class AbstractCFHintsProvider implements Callable<Collection<YVa
|
||||
|
||||
@Override
|
||||
public Collection<YValueHint> call() throws Exception {
|
||||
Collection<YValueHint> hints = new ArrayList<>();
|
||||
|
||||
try {
|
||||
List<CFTarget> targets = targetCache.getOrCreate();
|
||||
Collection<YValueHint> resolvedHints = getHints(targets);
|
||||
if (resolvedHints != null) {
|
||||
hints.addAll(resolvedHints);
|
||||
}
|
||||
|
||||
// Do NOT wrap the results in another list. Allow null values to return
|
||||
// as the reconcile framework expects null if hints failed to be resolved
|
||||
return getHints(targets);
|
||||
} catch (Throwable e) {
|
||||
// Convert any error into something readable to the user as it may
|
||||
// appear in the content assist
|
||||
@@ -75,7 +74,6 @@ public abstract class AbstractCFHintsProvider implements Callable<Collection<YVa
|
||||
}
|
||||
}
|
||||
}
|
||||
return hints;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -28,11 +28,13 @@ public class ManifestYamlCFBuildpacksProvider extends AbstractCFHintsProvider {
|
||||
|
||||
@Override
|
||||
public Collection<YValueHint> getHints(List<CFTarget> targets) throws Exception {
|
||||
|
||||
List<YValueHint> hints = new ArrayList<>();
|
||||
|
||||
for (CFTarget cfTarget : targets) {
|
||||
|
||||
List<CFBuildpack> buildpacks = cfTarget.getBuildpacks();
|
||||
if (buildpacks != null && !buildpacks.isEmpty()) {
|
||||
List<YValueHint> hints = new ArrayList<>();
|
||||
|
||||
for (CFBuildpack buildpack : buildpacks) {
|
||||
String name = buildpack.getName();
|
||||
@@ -45,9 +47,12 @@ public class ManifestYamlCFBuildpacksProvider extends AbstractCFHintsProvider {
|
||||
return hints;
|
||||
}
|
||||
}
|
||||
// Return null if no hints an be resolved rather than empty list (seems to be
|
||||
// what is expected for parsing for reconciler)
|
||||
return null;
|
||||
// Contract for the reconciler: return null if values cannot be
|
||||
// resolved. Otherwise
|
||||
// return non-empty list of buildpacks. For CF targets, a non-empty list
|
||||
// of buildpacks is
|
||||
// typically expected.
|
||||
return !hints.isEmpty() ? hints : null;
|
||||
}
|
||||
|
||||
protected String getBuildpackLabel(CFTarget target, CFBuildpack buildpack) {
|
||||
|
||||
@@ -29,10 +29,16 @@ public class ManifestYamlCFServicesProvider extends AbstractCFHintsProvider {
|
||||
@Override
|
||||
public Collection<YValueHint> getHints(List<CFTarget> targets) throws Exception {
|
||||
|
||||
// NOTE: empty list of services is a VALID result. A CF target may have
|
||||
// no service instances
|
||||
// created, so if empty list is returned from the client, then RETURN empty list. don't
|
||||
// return null
|
||||
// for empty services cases
|
||||
List<YValueHint> hints = new ArrayList<>();
|
||||
|
||||
for (CFTarget cfTarget : targets) {
|
||||
List<CFServiceInstance> services = cfTarget.getServices();
|
||||
if (services != null && !services.isEmpty()) {
|
||||
List<YValueHint> hints = new ArrayList<>();
|
||||
|
||||
for (CFServiceInstance service : services) {
|
||||
String name = service.getName();
|
||||
@@ -45,9 +51,8 @@ public class ManifestYamlCFServicesProvider extends AbstractCFHintsProvider {
|
||||
return hints;
|
||||
}
|
||||
}
|
||||
// Return null if no hints an be resolved rather than empty list (seems to be
|
||||
// what is expected for parsing for reconciler)
|
||||
return null;
|
||||
|
||||
return hints;
|
||||
}
|
||||
|
||||
private String getServiceLabel(CFTarget cfClientTarget, CFServiceInstance service) {
|
||||
|
||||
@@ -790,7 +790,6 @@ public class ManifestYamlEditorTest {
|
||||
editor.assertProblems("bogus|Unknown property");
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void reconcileShowsWarningOnUnknownService() throws Exception {
|
||||
ClientRequests cfClient = cfClientFactory.client;
|
||||
@@ -811,7 +810,6 @@ public class ManifestYamlEditorTest {
|
||||
assertEquals(DiagnosticSeverity.Warning, problem.getSeverity());
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test
|
||||
public void reconcileShowsWarningOnNoService() throws Exception {
|
||||
ClientRequests cfClient = cfClientFactory.client;
|
||||
|
||||
Reference in New Issue
Block a user