Minor refactoring of CF targets in vscode
This commit is contained in:
@@ -15,7 +15,12 @@ import java.util.List;
|
||||
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.ClientRequests;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.CloudFoundryClientFactory;
|
||||
import org.springframework.ide.vscode.commons.cloudfoundry.client.v2.DefaultCloudFoundryClientFactoryV2;
|
||||
|
||||
/**
|
||||
* Creates targets given a client parameters factory and a client factory.
|
||||
*
|
||||
*/
|
||||
public class CFClientTargets {
|
||||
|
||||
private final CFClientParamsFactory paramsFactory;
|
||||
@@ -54,4 +59,10 @@ public class CFClientTargets {
|
||||
}
|
||||
}
|
||||
|
||||
public static CFClientTargets createDefaultV2ClientTargets() {
|
||||
CFClientParamsFactory paramsFactory = CFClientParamsFactory.INSTANCE;
|
||||
CloudFoundryClientFactory clientFactory = DefaultCloudFoundryClientFactoryV2.INSTANCE;
|
||||
return new CFClientTargets(paramsFactory, clientFactory);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -51,6 +51,7 @@ public class CfCliParamsProvider implements Provider<List<CFClientParams>> {
|
||||
Map<String, Object> userData = mapper.readValue(file, Map.class);
|
||||
if (userData != null) {
|
||||
String refreshToken = (String) userData.get(REFRESH_TOKEN);
|
||||
// Only support connecting to CF via refresh token for now
|
||||
if (refreshToken == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -76,6 +77,7 @@ public class CfCliParamsProvider implements Provider<List<CFClientParams>> {
|
||||
}
|
||||
|
||||
private File getConfigJsonFile() throws IOException, InterruptedException {
|
||||
// Support Unix systems for now
|
||||
if (!System.getProperty("os.name").toLowerCase().startsWith("win")) {
|
||||
String homeDir = getUnixHomeDir();
|
||||
if (homeDir != null) {
|
||||
|
||||
@@ -90,11 +90,9 @@ public class ManifestYamlLanguageServer extends SimpleLanguageServer {
|
||||
documents.onHover(hoverEngine ::getHover);
|
||||
}
|
||||
|
||||
private CFClientTargets getCFTargets() {
|
||||
private CFClientTargets getCFTargets() {
|
||||
if (cfClientTargets == null) {
|
||||
CFClientParamsFactory paramsFactory = CFClientParamsFactory.INSTANCE;
|
||||
CloudFoundryClientFactory clientFactory = DefaultCloudFoundryClientFactoryV2.INSTANCE;
|
||||
cfClientTargets = new CFClientTargets(paramsFactory, clientFactory);
|
||||
cfClientTargets = CFClientTargets.createDefaultV2ClientTargets();
|
||||
}
|
||||
return cfClientTargets;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user