Skip to content

Commit 25d035d

Browse files
author
Yang Guo
committed
add flow name to env
1 parent ad44e91 commit 25d035d

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

platform-api/src/main/java/com/flow/platform/api/envs/FlowEnvs.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
*/
2626
public enum FlowEnvs implements EnvKey {
2727

28+
FLOW_NAME(true, false, null),
29+
2830
/**
2931
* Indicate flow is configured for git
3032
*/

platform-api/src/main/java/com/flow/platform/api/service/node/NodeServiceImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ public Node createEmptyFlow(final String flowName) {
206206
}
207207

208208
// init env variables
209+
flow.putEnv(FlowEnvs.FLOW_NAME, flowName);
209210
flow.putEnv(FlowEnvs.FLOW_STATUS, StatusValue.PENDING);
210211
flow.putEnv(FlowEnvs.FLOW_YML_STATUS, YmlStatusValue.NOT_FOUND);
211212
flow.putEnv(GitEnvs.FLOW_GIT_WEBHOOK, hooksUrl(flow));

platform-api/src/test/java/com/flow/platform/api/test/service/NodeServiceTest.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ public void should_save_node_env() throws Throwable {
194194
// then:
195195
String webhook = HttpURL.build(apiDomain).append("/hooks/git").append(emptyFlow.getName()).toString();
196196
Node loaded = nodeService.find("flow1").root();
197-
Assert.assertEquals(15, loaded.getEnvs().size());
197+
Assert.assertEquals(16, loaded.getEnvs().size());
198+
Assert.assertEquals("flow1", loaded.getEnv(FlowEnvs.FLOW_NAME));
198199
Assert.assertEquals("hello", loaded.getEnv("FLOW_NEW_1"));
199200
Assert.assertEquals("world", loaded.getEnv("FLOW_NEW_2"));
200201
Assert.assertEquals("done", loaded.getEnv("FLOW_NEW_3"));
@@ -213,7 +214,7 @@ public void should_save_node_env() throws Throwable {
213214

214215
// check env been sync with yml
215216
Node flow = flowDao.get("flow1");
216-
Assert.assertEquals(15, flow.getEnvs().size());
217+
Assert.assertEquals(16, flow.getEnvs().size());
217218
Assert.assertEquals("hello", flow.getEnv("FLOW_NEW_1"));
218219
Assert.assertEquals("world", flow.getEnv("FLOW_NEW_2"));
219220
Assert.assertEquals("done", flow.getEnv("FLOW_NEW_3"));

0 commit comments

Comments
 (0)