Skip to content

Commit 9faa0c7

Browse files
authored
Merge pull request #403 from FlowCI/feature/1554
Feature/1554
2 parents c165980 + b113c12 commit 9faa0c7

File tree

8 files changed

+41
-3
lines changed

8 files changed

+41
-3
lines changed

core/src/main/java/com/flowci/core/agent/domain/ShellIn.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ public enum ShellType {
5252

5353
private Set<String> secrets;
5454

55+
private Set<String> configs;
56+
5557
public ShellIn() {
5658
super(Type.SHELL);
5759
}

core/src/main/java/com/flowci/core/api/OpenRestController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public Secret getSecret(@PathVariable String name) {
7373

7474
if (secret instanceof RSASecret) {
7575
RSASecret rsa = (RSASecret) secret;
76-
rsa.setPublicKey(null);
76+
rsa.setPrivateKey(null);
7777
}
7878

7979
return secret;

core/src/main/java/com/flowci/core/flow/service/YmlServiceImpl.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818

1919
import com.flowci.core.common.manager.ConditionManager;
2020
import com.flowci.core.common.manager.SpringEventManager;
21+
import com.flowci.core.config.event.GetConfigEvent;
2122
import com.flowci.core.flow.dao.FlowDao;
2223
import com.flowci.core.flow.dao.YmlDao;
2324
import com.flowci.core.flow.domain.Flow;
@@ -51,6 +52,7 @@ public class YmlServiceImpl implements YmlService {
5152

5253
private final List<NodeElementChecker> elementCheckers = ImmutableList.of(
5354
new ConditionChecker(),
55+
new ConfigChecker(),
5456
new PluginChecker(),
5557
new SecretChecker()
5658
);
@@ -206,4 +208,18 @@ public Optional<RuntimeException> apply(NodeTree tree) {
206208
return Optional.empty();
207209
}
208210
}
211+
212+
private class ConfigChecker implements NodeElementChecker {
213+
214+
@Override
215+
public Optional<RuntimeException> apply(NodeTree tree) {
216+
for (String c : tree.getConfigs()) {
217+
GetConfigEvent event = eventManager.publish(new GetConfigEvent(this, c));
218+
if (event.hasError()) {
219+
return Optional.of(event.getError());
220+
}
221+
}
222+
return Optional.empty();
223+
}
224+
}
209225
}

core/src/main/java/com/flowci/core/job/manager/CmdManagerImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ public ShellIn createShellCmd(Job job, Step step, Node node) {
6565
.setTimeout(r.fetchTimeout(job.getTimeout()))
6666
.setRetry(r.fetchRetry(0))
6767
.setSecrets(r.getSecrets())
68+
.setConfigs(r.getConfigs())
6869
.setCache(r.getCache());
6970

7071
if (r.hasPlugin()) {

core/src/main/resources/default/smtp-demo-config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
kind: smtp
2-
name: sendgrid-demo
2+
name: sendgrid_demo
33
smtp:
44
server: smtp.sendgrid.net
55
port: 587

tree/src/main/java/com/flowci/tree/NodeTree.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
@Getter
3030
public final class NodeTree {
3131

32-
private static final int DefaultSize = 20;
32+
private static final int DefaultSize = 10;
3333

3434
private static final int DefaultSizeForPrev = 5;
3535

@@ -57,6 +57,8 @@ public static NodeTree create(FlowNode root) {
5757

5858
private final Set<String> secrets = new HashSet<>(DefaultSize);
5959

60+
private final Set<String> configs = new HashSet<>(DefaultSize);
61+
6062
private int maxHeight = 1;
6163

6264
public NodeTree(FlowNode root) {
@@ -207,6 +209,10 @@ private void buildMetaData() {
207209
if (r.hasSecrets()) {
208210
secrets.addAll(r.getSecrets());
209211
}
212+
213+
if (r.hasConfigs()) {
214+
configs.addAll(r.getConfigs());
215+
}
210216
}
211217

212218
if (node instanceof FlowNode) {

tree/src/main/java/com/flowci/tree/RegularStepNode.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ public final class RegularStepNode extends Node {
5757
*/
5858
private Set<String> secrets = new HashSet<>(0);
5959

60+
/**
61+
* Included config name in the step
62+
*/
63+
private Set<String> configs = new HashSet<>(0);
64+
6065
/**
6166
* Is allow failure
6267
*/
@@ -91,6 +96,11 @@ public boolean hasSecrets() {
9196
return !secrets.isEmpty();
9297
}
9398

99+
@JsonIgnore
100+
public boolean hasConfigs() {
101+
return !configs.isEmpty();
102+
}
103+
94104
@JsonIgnore
95105
public boolean hasTimeout() {
96106
return timeout != null;

tree/src/main/java/com/flowci/tree/yml/StepYml.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,8 @@ public class StepYml extends YmlBase<RegularStepNode> {
6666

6767
private List<String> secrets = new LinkedList<>();
6868

69+
private List<String> configs = new LinkedList<>();
70+
6971
/**
7072
* Only for parallel step, other fields will not valid
7173
*/
@@ -114,6 +116,7 @@ public Node toNode(Node parent, int index) {
114116
step.setAllowFailure(allow_failure != null && allow_failure);
115117
step.setEnvironments(getVariableMap());
116118
step.setSecrets(Sets.newHashSet(secrets));
119+
step.setConfigs(Sets.newHashSet(configs));
117120

118121
setCacheToNode(step);
119122
setDockerToNode(step);

0 commit comments

Comments
 (0)