Skip to content

Commit 9ba2810

Browse files
committed
1
1 parent 7800116 commit 9ba2810

File tree

3 files changed

+10
-130
lines changed

3 files changed

+10
-130
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-e2e/seatunnel-engine-e2e/connector-seatunnel-e2e-base/src/test/java/org/apache/seatunnel/engine/e2e/RestApiIT.java

+9
Original file line numberDiff line numberDiff line change
@@ -513,6 +513,9 @@ public void testGetRunningJobs() {
513513

514514
@Test
515515
public void testGetJobInfoByJobId() {
516+
String os = System.getProperty("os.name").toLowerCase();
517+
boolean isWindows = os.contains("win");
518+
String sparkHomeValue = isWindows ? "C:\\Program Files\\spark" : "/opt/spark";
516519
Arrays.asList(node2, node1)
517520
.forEach(
518521
instance -> {
@@ -578,6 +581,9 @@ public void testGetJobInfoByJobId() {
578581
.body(
579582
"jobDag.envOptions.'job.mode'",
580583
equalTo("BATCH"))
584+
.body(
585+
"[0].jobDag.envOptions.'SPARK_HOME'",
586+
equalTo(sparkHomeValue))
581587
.body("jobName", equalTo("fake_to_console"))
582588
.body("jobStatus", equalTo("FINISHED"));
583589

@@ -644,6 +650,9 @@ public void testGetJobInfoByJobId() {
644650
.body(
645651
"jobDag.envOptions.'job.mode'",
646652
equalTo("BATCH"))
653+
.body(
654+
"[0].jobDag.envOptions.'SPARK_HOME'",
655+
equalTo(sparkHomeValue))
647656
.body("jobName", equalTo("fake_to_console"))
648657
.body("jobStatus", equalTo("FINISHED"));
649658
});

0 commit comments

Comments
 (0)