Skip to content

Commit 5c5dbc5

Browse files
committed
1
1 parent 7800116 commit 5c5dbc5

File tree

4 files changed

+1
-173
lines changed

4 files changed

+1
-173
lines changed

seatunnel-common/src/main/java/org/apache/seatunnel/common/config/EnvConfigParserUtil.java

+1-58
Original file line numberDiff line numberDiff line change
@@ -17,69 +17,12 @@
1717

1818
package org.apache.seatunnel.common.config;
1919

20-
import org.apache.seatunnel.common.utils.FileUtils;
21-
22-
import java.nio.file.Path;
2320
import java.util.HashMap;
2421
import java.util.Map;
2522

2623
public class EnvConfigParserUtil {
2724

2825
public static Map<String, String> parseEnvConfig() {
29-
Path path = Common.configDir();
30-
String os = System.getProperty("os.name").toLowerCase();
31-
32-
if (os.startsWith("win")) {
33-
String envScript = "seatunnel-env.cmd";
34-
Path envScriptPath = path.resolve(envScript);
35-
if (envScriptPath.toFile().exists()) {
36-
String content = FileUtils.readFileToStr(envScriptPath);
37-
Map<String, String> config = new HashMap<>();
38-
String[] lines = content.split("\\r?\\n");
39-
for (String line : lines) {
40-
line = line.trim();
41-
if (line.startsWith("if") && line.contains("set")) {
42-
int setIndex = line.indexOf("set");
43-
if (setIndex != -1) {
44-
String assignment = line.substring(setIndex + 4).trim();
45-
String[] keyValue = assignment.split("=");
46-
if (keyValue.length == 2) {
47-
String key = keyValue[0].replace("\"", "").trim();
48-
String value = keyValue[1].replace("\"", "").trim();
49-
config.put(key, value);
50-
}
51-
}
52-
}
53-
}
54-
return config;
55-
}
56-
57-
} else {
58-
String envScript = "seatunnel-env.sh";
59-
Path envScriptPath = path.resolve(envScript);
60-
if (envScriptPath.toFile().exists()) {
61-
String content = FileUtils.readFileToStr(envScriptPath);
62-
Map<String, String> config = new HashMap<>();
63-
String[] lines = content.split("\\r?\\n");
64-
for (String line : lines) {
65-
line = line.trim();
66-
if (line.contains("=") && !line.startsWith("#")) {
67-
String[] keyValue = line.split("=", 2);
68-
if (keyValue.length == 2) {
69-
String key = keyValue[0].trim();
70-
String value = keyValue[1].trim();
71-
if (value.startsWith("${") && value.contains(":-")) {
72-
value =
73-
value.substring(
74-
value.indexOf(":-") + 2, value.length() - 1);
75-
}
76-
config.put(key, value);
77-
}
78-
}
79-
}
80-
return config;
81-
}
82-
}
83-
return null;
26+
return new HashMap<>(System.getenv());
8427
}
8528
}

seatunnel-common/src/test/java/org/apache/seatunnel/common/config/EnvConfigParserUtilTest.java

-72
This file was deleted.

seatunnel-common/src/test/resources/home/config/seatunnel-env.cmd

-21
This file was deleted.

seatunnel-common/src/test/resources/home/config/seatunnel-env.sh

-22
This file was deleted.

0 commit comments

Comments
 (0)