Skip to content

Commit 28f1c72

Browse files
authored
Merge pull request #347 from FlowCI/develop
2 parents 2ac6a25 + b9c76d7 commit 28f1c72

File tree

142 files changed

+1528
-1057
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

142 files changed

+1528
-1057
lines changed

core/debug.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
- "27017:27017"
1111

1212
zk:
13-
image: zookeeper:3.4
13+
image: zookeeper:3.6
1414
container_name: flowci-debug-zk
1515
restart: always
1616
ports:

core/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -129,11 +129,6 @@
129129
<artifactId>springfox-swagger-ui</artifactId>
130130
</dependency>
131131

132-
<dependency>
133-
<groupId>org.apache.velocity</groupId>
134-
<artifactId>velocity-engine-core</artifactId>
135-
</dependency>
136-
137132
<dependency>
138133
<groupId>com.cronutils</groupId>
139134
<artifactId>cron-utils</artifactId>

core/src/main/java/com/flowci/core/agent/config/AgentConfig.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,8 @@ public Settings baseSettings() {
5353
Settings.RabbitMQ mq = new Settings.RabbitMQ();
5454
mq.setUri(getRabbitUri());
5555
mq.setCallback(rabbitProperties.getCallbackQueue());
56-
mq.setLogsExchange(rabbitProperties.getLoggingExchange());
56+
mq.setShellLogEx(rabbitProperties.getShellLogEx());
57+
mq.setTtyLogEx(rabbitProperties.getTtyLogEx());
5758

5859
Settings settings = new Settings();
5960
settings.setZookeeper(zk);

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
package com.flowci.core.agent.domain;
1919

20+
import com.google.common.collect.ImmutableList;
21+
22+
import java.util.List;
23+
2024
public abstract class AgentAction {
2125

2226
public static final String GET = "get_agent";
@@ -27,10 +31,10 @@ public abstract class AgentAction {
2731

2832
public static final String DELETE = "delete_agent";
2933

30-
public static final String[] ALL = {
34+
public static final List<String> ALL = ImmutableList.of(
3135
GET,
3236
LIST,
3337
CREATE_UPDATE,
3438
DELETE
35-
};
39+
);
3640
}

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

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616

1717
package com.flowci.core.agent.domain;
1818

19+
import com.google.common.collect.ImmutableList;
20+
21+
import java.util.List;
22+
1923
public abstract class AgentHostAction {
2024

2125
public static final String GET = "get_agent_host";
@@ -26,11 +30,10 @@ public abstract class AgentHostAction {
2630

2731
public static final String DELETE = "delete_agent_host";
2832

29-
public static final String[] ALL = {
33+
public static final List<String> ALL = ImmutableList.of(
3034
GET,
3135
LIST,
3236
CREATE_UPDATE,
3337
DELETE
34-
};
35-
38+
);
3639
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
package com.flowci.core.agent.domain;
2+
3+
import lombok.Getter;
4+
import lombok.Setter;
5+
6+
@Getter
7+
@Setter
8+
public abstract class CmdIn {
9+
10+
public enum Type {
11+
/**
12+
* Execute shell script
13+
*/
14+
SHELL,
15+
16+
/**
17+
* Kill running shell
18+
*/
19+
KILL,
20+
21+
/**
22+
* TTY cmd
23+
*/
24+
TTY,
25+
26+
/**
27+
* Close agent
28+
*/
29+
CLOSE;
30+
}
31+
32+
protected Type type;
33+
34+
protected CmdIn(Type type) {
35+
this.type = type;
36+
}
37+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.flowci.core.agent.domain;
2+
3+
/**
4+
* Cmd output from callback queue,
5+
* first byte is indicator to indicate cmd out type
6+
*
7+
* @author yang
8+
*/
9+
public interface CmdOut {
10+
11+
/**
12+
* ShellOut
13+
*/
14+
byte ShellOutInd = 1;
15+
16+
/**
17+
* TtyOut
18+
*/
19+
byte TtyOutInd = 2;
20+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package com.flowci.core.agent.domain;
2+
3+
import com.flowci.core.common.rabbit.RabbitOperations;
4+
5+
import java.util.Objects;
6+
import java.util.Optional;
7+
8+
public abstract class CmdStdLog {
9+
10+
public static final String ID_HEADER = "id";
11+
12+
public static Optional<String> getId(RabbitOperations.Message message) {
13+
if (!message.hasHeader()) {
14+
return Optional.empty();
15+
}
16+
17+
Object id = message.getHeaders().get(CmdStdLog.ID_HEADER);
18+
if (Objects.isNull(id)) {
19+
return Optional.empty();
20+
}
21+
22+
return Optional.of(id.toString());
23+
}
24+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.flowci.core.agent.domain;
2+
3+
import com.flowci.domain.DockerOption;
4+
import com.flowci.domain.StringVars;
5+
import com.flowci.domain.Vars;
6+
import com.google.common.base.Strings;
7+
import lombok.Getter;
8+
import lombok.Setter;
9+
import lombok.experimental.Accessors;
10+
11+
import java.util.LinkedHashSet;
12+
import java.util.LinkedList;
13+
import java.util.List;
14+
import java.util.Set;
15+
16+
@Getter
17+
@Setter
18+
@Accessors(chain = true)
19+
public final class ShellIn extends CmdIn {
20+
21+
// from ExecutedCmd id
22+
private String id;
23+
24+
private String flowId;
25+
26+
private String jobId;
27+
28+
private boolean allowFailure;
29+
30+
private String plugin;
31+
32+
private DockerOption docker;
33+
34+
private List<String> scripts = new LinkedList<>();
35+
36+
private int timeout = 1800;
37+
38+
private Vars<String> inputs = new StringVars();
39+
40+
private Set<String> envFilters = new LinkedHashSet<>();
41+
42+
public ShellIn() {
43+
super(Type.SHELL);
44+
}
45+
46+
public void addScript(String script) {
47+
if (Strings.isNullOrEmpty(script)) {
48+
return;
49+
}
50+
scripts.add(script);
51+
}
52+
53+
public void addEnvFilters(Set<String> exports) {
54+
this.envFilters.addAll(exports);
55+
}
56+
57+
public void addInputs(StringVars vars) {
58+
inputs.putAll(vars);
59+
}
60+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.flowci.core.agent.domain;
2+
3+
/**
4+
* Kill current executing shell command
5+
*/
6+
public final class ShellKill extends CmdIn {
7+
8+
public ShellKill() {
9+
super(Type.KILL);
10+
}
11+
}

0 commit comments

Comments
 (0)