Ignore individual target errors for hint providers if there are valid
targets
This commit is contained in:
@@ -121,4 +121,8 @@ public class CFTargetCache {
|
||||
return cfApiUrl;
|
||||
}
|
||||
}
|
||||
|
||||
public CfClientConfig getCfClientConfig() {
|
||||
return cfClientConfig;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.manifest.yaml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
@@ -88,6 +89,31 @@ public abstract class AbstractCFHintsProvider implements Callable<Collection<YVa
|
||||
*
|
||||
* @return non-null list of hints. Return empty if no hints available
|
||||
*/
|
||||
abstract protected Collection<YValueHint> getHints(List<CFTarget> targets) throws Exception;
|
||||
protected Collection<YValueHint> getHints(List<CFTarget> targets) throws Exception {
|
||||
if (targets==null || targets.isEmpty()) {
|
||||
//no targets... means we don't know anything. Indicate this by returning null...
|
||||
// this "don't know" value will suppress bogus warnings in the reconciler.
|
||||
return null;
|
||||
}
|
||||
List<YValueHint> hints = new ArrayList<>();
|
||||
boolean validTargetsPresent = false;
|
||||
for (CFTarget cfTarget : targets) {
|
||||
try {
|
||||
// TODO: check if duplicate proposals can be the list of all hints. Duplicates don't seem to cause duplicate proposals. Verify this!
|
||||
getHints(cfTarget).stream().filter(hint -> !hints.contains(hint)).forEach(hint -> hints.add(hint));
|
||||
validTargetsPresent = true;
|
||||
} catch (Exception e) {
|
||||
// Drop individual target error
|
||||
}
|
||||
}
|
||||
if (validTargetsPresent) {
|
||||
return hints;
|
||||
} else {
|
||||
throw new ConnectionException(
|
||||
targetCache.getCfClientConfig().getClientParamsProvider().getMessages().noNetworkConnection());
|
||||
}
|
||||
}
|
||||
|
||||
abstract Collection<YValueHint> getHints(CFTarget target) throws Exception;
|
||||
|
||||
}
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.manifest.yaml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFBuildpack;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget;
|
||||
@@ -29,32 +30,16 @@ public class ManifestYamlCFBuildpacksProvider extends AbstractCFHintsProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<YValueHint> getHints(List<CFTarget> targets) throws Exception {
|
||||
if (targets==null || targets.isEmpty()) {
|
||||
//no targets... means we don't know anything. Indicate this by returning null...
|
||||
// this "don't know" value will suppress bogus warnings in the reconciler.
|
||||
return null;
|
||||
}
|
||||
List<YValueHint> hints = new ArrayList<>();
|
||||
for (CFTarget cfTarget : targets) {
|
||||
|
||||
List<CFBuildpack> buildpacks = cfTarget.getBuildpacks();
|
||||
public Collection<YValueHint> getHints(CFTarget cfTarget) throws Exception {
|
||||
List<CFBuildpack> buildpacks = cfTarget.getBuildpacks();
|
||||
if (buildpacks == null) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
Renderable targetLabel = Renderables.text(cfTarget.getLabel());
|
||||
|
||||
if (buildpacks != null && !buildpacks.isEmpty()) {
|
||||
|
||||
for (CFBuildpack buildpack : buildpacks) {
|
||||
String name = buildpack.getName();
|
||||
String label = getBuildpackLabel(cfTarget, buildpack);
|
||||
YValueHint hint = new BasicYValueHint(name, label)
|
||||
.setDocumentation(targetLabel);
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint);
|
||||
}
|
||||
}
|
||||
}
|
||||
return buildpacks.stream()
|
||||
.map(buildpack -> new BasicYValueHint(buildpack.getName(), getBuildpackLabel(cfTarget, buildpack)).setDocumentation(targetLabel))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return hints;
|
||||
}
|
||||
|
||||
protected String getBuildpackLabel(CFTarget target, CFBuildpack buildpack) {
|
||||
|
||||
@@ -10,13 +10,15 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.manifest.yaml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFDomain;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTargetCache;
|
||||
import org.springframework.ide.vscode.commons.util.Renderable;
|
||||
import org.springframework.ide.vscode.commons.util.Renderables;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.BasicYValueHint;
|
||||
import org.springframework.ide.vscode.commons.yaml.schema.YValueHint;
|
||||
@@ -28,30 +30,16 @@ public class ManifestYamlCFDomainsProvider extends AbstractCFHintsProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<YValueHint> getHints(List<CFTarget> targets) throws Exception {
|
||||
if (targets==null || targets.isEmpty()) {
|
||||
//no targets... means we don't know anything. Indicate this by returning null...
|
||||
// this "don't know" value will suppress bogus warnings in the reconciler.
|
||||
return null;
|
||||
public Collection<YValueHint> getHints(CFTarget cfTarget) throws Exception {
|
||||
List<CFDomain> domains = cfTarget.getDomains();
|
||||
if (domains == null) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
Renderable targetLabel = Renderables.text(cfTarget.getLabel());
|
||||
return domains.stream()
|
||||
.map(domain -> new BasicYValueHint(domain.getName(), getLabel(cfTarget, domain)).setDocumentation(targetLabel))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
List<YValueHint> hints = new ArrayList<>();
|
||||
for (CFTarget cfTarget : targets) {
|
||||
|
||||
List<CFDomain> domains = cfTarget.getDomains();
|
||||
if (domains != null && !domains.isEmpty()) {
|
||||
|
||||
for (CFDomain domain : domains) {
|
||||
String name = domain.getName();
|
||||
String label = getLabel(cfTarget, domain);
|
||||
YValueHint hint = new BasicYValueHint(name, label)
|
||||
.setDocumentation(Renderables.text(cfTarget.getLabel()));
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return hints;
|
||||
}
|
||||
|
||||
protected String getLabel(CFTarget target, CFDomain domain) {
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.manifest.yaml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFServiceInstance;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget;
|
||||
@@ -29,30 +30,16 @@ public class ManifestYamlCFServicesProvider extends AbstractCFHintsProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<YValueHint> getHints(List<CFTarget> targets) throws Exception {
|
||||
if (targets==null || targets.isEmpty()) {
|
||||
//no targets... means we don't know anything. Indicate this by returning null...
|
||||
// this "don't know" value will suppress bogus warnings in the reconciler.
|
||||
return null;
|
||||
}
|
||||
List<YValueHint> hints = new ArrayList<>();
|
||||
for (CFTarget cfTarget : targets) {
|
||||
List<CFServiceInstance> services = cfTarget.getServices();
|
||||
public Collection<YValueHint> getHints(CFTarget cfTarget) throws Exception {
|
||||
List<CFServiceInstance> services = cfTarget.getServices();
|
||||
if (services == null) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
Renderable targetLabel = Renderables.text(cfTarget.getLabel());
|
||||
if (services != null && !services.isEmpty()) {
|
||||
|
||||
for (CFServiceInstance service : services) {
|
||||
String name = service.getName();
|
||||
String label = getServiceLabel(cfTarget, service);
|
||||
YValueHint hint = new BasicYValueHint(name, label)
|
||||
.setDocumentation(targetLabel);
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint);
|
||||
}
|
||||
}
|
||||
}
|
||||
return services.stream()
|
||||
.map(service -> new BasicYValueHint(service.getName(), getServiceLabel(cfTarget, service)).setDocumentation(targetLabel))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return hints;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -10,9 +10,10 @@
|
||||
*******************************************************************************/
|
||||
package org.springframework.ide.vscode.manifest.yaml;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.CFStack;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.cftarget.CFTarget;
|
||||
@@ -34,30 +35,16 @@ public class ManifestYamlStacksProvider extends AbstractCFHintsProvider {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Collection<YValueHint> getHints(List<CFTarget> targets) throws Exception {
|
||||
if (targets==null || targets.isEmpty()) {
|
||||
//no targets... means we don't know anything. Indicate this by returning null...
|
||||
// this "don't know" value will suppress bogus warnings in the reconciler.
|
||||
return null;
|
||||
}
|
||||
List<YValueHint> hints = new ArrayList<>();
|
||||
for (CFTarget cfTarget : targets) {
|
||||
List<CFStack> stacks = cfTarget.getStacks();
|
||||
protected Collection<YValueHint> getHints(CFTarget cfTarget) throws Exception {
|
||||
List<CFStack> stacks = cfTarget.getStacks();
|
||||
if (stacks == null) {
|
||||
return Collections.emptyList();
|
||||
} else {
|
||||
Renderable targetLabel = Renderables.text(cfTarget.getLabel());
|
||||
if (stacks != null && !stacks.isEmpty()) {
|
||||
for (CFStack s : stacks) {
|
||||
String name = s.getName();
|
||||
String label = name;
|
||||
YValueHint hint = new BasicYValueHint(name, label)
|
||||
.setDocumentation(targetLabel);
|
||||
if (!hints.contains(hint)) {
|
||||
hints.add(hint);
|
||||
}
|
||||
}
|
||||
}
|
||||
return stacks.stream()
|
||||
.map(s -> new BasicYValueHint(s.getName(), s.getName()).setDocumentation(targetLabel))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
return hints;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user