|
@@ -11,7 +11,6 @@ import java.io.*;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author reghao
|
|
* @author reghao
|
|
@@ -180,24 +179,28 @@ public class Sftp {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public List<RemoteHost> getRemoteHost(String filePath) {
|
|
public List<RemoteHost> getRemoteHost(String filePath) {
|
|
|
- return textFile.read(filePath).stream().map(line -> {
|
|
|
|
|
|
|
+ List<String> list = textFile.read(filePath);
|
|
|
|
|
+ List<RemoteHost> remoteHosts = new ArrayList<>();
|
|
|
|
|
+ for (int i = 1; i < list.size(); i++) {
|
|
|
|
|
+ // 从 csv 文件的第二行开始读, 第一行为注释
|
|
|
|
|
+ String line = list.get(i);
|
|
|
String[] arr = line.split(",");
|
|
String[] arr = line.split(",");
|
|
|
if (arr.length == 4) {
|
|
if (arr.length == 4) {
|
|
|
String host = arr[0];
|
|
String host = arr[0];
|
|
|
int port = Integer.parseInt(arr[1]);
|
|
int port = Integer.parseInt(arr[1]);
|
|
|
String username = arr[2];
|
|
String username = arr[2];
|
|
|
String password = arr[3];
|
|
String password = arr[3];
|
|
|
- return new RemoteHost(host, port, username, password, null);
|
|
|
|
|
|
|
+ remoteHosts.add(new RemoteHost(host, port, username, password, null));
|
|
|
} else if (arr.length == 5) {
|
|
} else if (arr.length == 5) {
|
|
|
String host = arr[0];
|
|
String host = arr[0];
|
|
|
int port = Integer.parseInt(arr[1]);
|
|
int port = Integer.parseInt(arr[1]);
|
|
|
String username = arr[2];
|
|
String username = arr[2];
|
|
|
String prikeyPath = arr[4];
|
|
String prikeyPath = arr[4];
|
|
|
- return new RemoteHost(host, port, username, null, prikeyPath);
|
|
|
|
|
|
|
+ remoteHosts.add(new RemoteHost(host, port, username, null, prikeyPath));
|
|
|
}
|
|
}
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
- return null;
|
|
|
|
|
- }).filter(Objects::nonNull).collect(Collectors.toList());
|
|
|
|
|
|
|
+ return remoteHosts;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void deploy(String localDir, String remoteDir, RemoteHost remoteHost) throws Exception {
|
|
public void deploy(String localDir, String remoteDir, RemoteHost remoteHost) throws Exception {
|