mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
PY-15476 Untie docker-python from IDEA Docker plugin
This commit is contained in:
@@ -22,13 +22,14 @@ import org.jetbrains.annotations.NotNull;
|
||||
* @author Alexander Koshevoy
|
||||
*/
|
||||
public class DockerCredentialsHolder {
|
||||
public static final String DOCKER_SERVER_NAME = "DOCKER_SERVER_NAME";
|
||||
public static final String DOCKER_REMOTE_API_ADDRESS = "DOCKER_REMOTE_API_ADDRESS";
|
||||
public static final String DOCKER_CERTIFICATES_FOLDER = "DOCKER_CERTIFICATES_FOLDER";
|
||||
public static final String DOCKER_IMAGE_NAME = "DOCKER_IMAGE_NAME";
|
||||
public static final String DOCKER_CONTAINER_NAME = "DOCKER_CONTAINER_NAME";
|
||||
public static final String DOCKER_REMOTE_PROJECT_PATH = "DOCKER_REMOTE_PROJECT_PATH";
|
||||
|
||||
// TODO [Docker] do not store docker server itself but store id or special reference
|
||||
private DockerSupport.DockerServer myDockerServer;
|
||||
private String myRemoteAPIAddress;
|
||||
private String myCertificatesFolder;
|
||||
|
||||
private String myImageName;
|
||||
|
||||
@@ -39,15 +40,24 @@ public class DockerCredentialsHolder {
|
||||
public DockerCredentialsHolder() {
|
||||
}
|
||||
|
||||
public DockerCredentialsHolder(DockerSupport.DockerServer server, String imageName, String containerName, String remoteProjectPath) {
|
||||
myDockerServer = server;
|
||||
public DockerCredentialsHolder(String remoteAPIAddress,
|
||||
String certificatesFolder,
|
||||
String imageName,
|
||||
String containerName,
|
||||
String remoteProjectPath) {
|
||||
myRemoteAPIAddress = remoteAPIAddress;
|
||||
myCertificatesFolder = certificatesFolder;
|
||||
myImageName = imageName;
|
||||
myContainerName = containerName;
|
||||
myRemoteProjectPath = remoteProjectPath;
|
||||
}
|
||||
|
||||
public DockerSupport.DockerServer getDockerServer() {
|
||||
return myDockerServer;
|
||||
public String getRemoteApiUrl() {
|
||||
return myRemoteAPIAddress;
|
||||
}
|
||||
|
||||
public String getCertificatesFolder() {
|
||||
return myCertificatesFolder;
|
||||
}
|
||||
|
||||
public String getImageName() {
|
||||
@@ -63,23 +73,18 @@ public class DockerCredentialsHolder {
|
||||
}
|
||||
|
||||
public void save(@NotNull Element element) {
|
||||
element.setAttribute(DOCKER_REMOTE_API_ADDRESS, myRemoteAPIAddress);
|
||||
element.setAttribute(DOCKER_CERTIFICATES_FOLDER, myCertificatesFolder);
|
||||
element.setAttribute(DOCKER_IMAGE_NAME, myImageName);
|
||||
element.setAttribute(DOCKER_CONTAINER_NAME, myContainerName);
|
||||
element.setAttribute(DOCKER_REMOTE_PROJECT_PATH, myRemoteProjectPath);
|
||||
// TODO [Docker] use better Docker server id than its name
|
||||
if (myDockerServer != null) {
|
||||
element.setAttribute(DOCKER_SERVER_NAME, myDockerServer.getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void load(@NotNull Element element) {
|
||||
myRemoteAPIAddress = element.getAttributeValue(DOCKER_REMOTE_API_ADDRESS);
|
||||
myCertificatesFolder = element.getAttributeValue(DOCKER_CERTIFICATES_FOLDER);
|
||||
myImageName = element.getAttributeValue(DOCKER_IMAGE_NAME);
|
||||
myContainerName = element.getAttributeValue(DOCKER_CONTAINER_NAME);
|
||||
myRemoteProjectPath = element.getAttributeValue(DOCKER_REMOTE_PROJECT_PATH);
|
||||
DockerSupport instance = DockerSupport.getInstance();
|
||||
if (instance != null) {
|
||||
myDockerServer = instance.findDockerServerByName(element.getAttributeValue(DOCKER_SERVER_NAME));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -16,11 +16,8 @@
|
||||
package com.intellij.remote;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author Alexander Koshevoy
|
||||
*/
|
||||
@@ -29,15 +26,4 @@ public abstract class DockerSupport {
|
||||
public static DockerSupport getInstance() {
|
||||
return ServiceManager.getService(DockerSupport.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public abstract List<DockerServer> getDockerServers();
|
||||
|
||||
@Nullable
|
||||
public abstract DockerServer findDockerServerByName(@NotNull String name);
|
||||
|
||||
public interface DockerServer {
|
||||
@NotNull
|
||||
String getName();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1037,7 +1037,6 @@ public class PythonSdkType extends SdkType {
|
||||
|
||||
@Override
|
||||
public void docker(@NotNull DockerCredentialsHolder credentials) {
|
||||
result.set(credentials.getDockerServer() == null);
|
||||
}
|
||||
});
|
||||
return result.get();
|
||||
|
||||
Reference in New Issue
Block a user