Skip to content

Commit 1dce076

Browse files
author
yang.guo
authored
Merge pull request #113 from FlowCI/develop
Develop
2 parents 8c6a33f + 7cf0660 commit 1dce076

File tree

48 files changed

+574
-310
lines changed

Some content is hidden

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

48 files changed

+574
-310
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
*.iml
33
.DS_Store
44
deploy.sh
5+
api-doc/
56

67
node_modules/
78
apidoc/

platform-api/src/main/java/com/flow/platform/api/config/AppConfig.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@
3030
import java.nio.file.Files;
3131
import java.nio.file.Path;
3232
import java.nio.file.Paths;
33-
import java.util.concurrent.BlockingQueue;
34-
import java.util.concurrent.LinkedBlockingQueue;
33+
import org.apache.velocity.app.Velocity;
3534
import org.apache.velocity.app.VelocityEngine;
3635
import org.apache.velocity.runtime.RuntimeConstants;
3736
import org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader;
@@ -45,7 +44,7 @@
4544
* @author yang
4645
*/
4746
@Configuration
48-
@Import({DatabaseConfig.class})
47+
@Import({CachingConfig.class, DatabaseConfig.class})
4948
public class AppConfig extends AppConfigBase {
5049

5150
public final static String NAME = "API";
@@ -62,10 +61,6 @@ public class AppConfig extends AppConfigBase {
6261

6362
private final static String THREAD_NAME_PREFIX = "async-task-";
6463

65-
public final static String ALLOW_SUFFIX = "p12,mobileprovision,jks,pem";
66-
67-
public final static long ALLOW_SIZE = 2 * 1024 * 1024;
68-
6964
public final static String DEFAULT_USER_EMAIL = "[email protected]";
7065
public final static String DEFAULT_USER_NAME = "admin";
7166
public final static String DEFAULT_USER_PASSWORD = "123456";
@@ -136,6 +131,11 @@ public VelocityEngine velocityEngine() throws Exception {
136131
VelocityEngine ve = new VelocityEngine();
137132
ve.setProperty(RuntimeConstants.RESOURCE_LOADER, "classpath");
138133
ve.setProperty("classpath.resource.loader.class", ClasspathResourceLoader.class.getName());
134+
135+
ve.setProperty(Velocity.ENCODING_DEFAULT, DEFAULT_CHARSET.name());
136+
ve.setProperty(Velocity.INPUT_ENCODING, DEFAULT_CHARSET.name());
137+
ve.setProperty(Velocity.OUTPUT_ENCODING, DEFAULT_CHARSET.name());
138+
139139
ve.init();
140140
return ve;
141141
}

platform-api/src/main/java/com/flow/platform/api/config/CachingConfig.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ public class CachingConfig {
4040
.expireAfterAccess(EXPIRE_CACHE_SECOND, TimeUnit.SECONDS)
4141
.maximumSize(MAX_CACHE_NUM);
4242

43-
4443
@Bean
4544
public CacheManager cacheManager() {
4645
GuavaCacheManager guavaCacheManager = new GuavaCacheManager();

platform-api/src/main/java/com/flow/platform/api/config/WebConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
"com.flow.platform.api.util",
6565
"com.flow.platform.api.consumer",
6666
"com.flow.platform.api.initializers"})
67-
@Import({AppConfig.class, CachingConfig.class})
67+
@Import({AppConfig.class})
6868
public class WebConfig extends WebMvcConfigurerAdapter {
6969

7070
private final static Gson GSON_CONFIG_FOR_RESPONE = new GsonBuilder()

platform-api/src/main/java/com/flow/platform/api/consumer/CmdLoggingConsumer.java

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

1919
import com.flow.platform.core.http.converter.RawGsonMessageConverter;
2020
import com.flow.platform.domain.CmdType;
21-
import com.flow.platform.domain.Jsonable;
2221
import com.flow.platform.util.Logger;
23-
import com.google.gson.annotations.JsonAdapter;
2422
import java.util.Map;
2523
import org.springframework.beans.factory.annotation.Autowired;
2624
import org.springframework.messaging.simp.SimpMessagingTemplate;
@@ -78,25 +76,19 @@ protected void handleTextMessage(WebSocketSession session, TextMessage message)
7876

7977
if (category.equals(CmdType.SYSTEM_INFO.toString())) {
8078
sendAgentSysInfo(content);
81-
return;
8279
}
8380
}
8481

8582
/**
8683
* send command log
87-
* @param cmdId
88-
* @param content
89-
* @param number
9084
*/
9185
private void sendCmdLog(String cmdId, String content, String number) {
92-
9386
String event = String.format("/topic/cmd/%s", cmdId);
9487
template.convertAndSend(event, "{\"number\": \"" + number + "\", \"content\": \"" + content + "\"}");
9588
}
9689

9790
/**
9891
* send agent sys info
99-
* @param content
10092
*/
10193
private void sendAgentSysInfo(String content) {
10294
Map<String, String> dic = jsonConverter.getGson().fromJson(content, Map.class);

platform-api/src/main/java/com/flow/platform/api/controller/FlowController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ public String getRawYml() {
321321
@WebSecurity(action = Actions.FLOW_YML)
322322
public Node loadRawYmlFromGit() {
323323
Flow root = nodeService.findFlow(currentNodePath.get());
324-
return ymlService.loadYmlContent(root, null);
324+
return ymlService.loadYmlContent(root, null, null);
325325
}
326326

327327
/**

platform-api/src/main/java/com/flow/platform/api/controller/GitWebHookController.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.flow.platform.api.controller;
1818

19+
import com.flow.platform.api.config.AppConfig;
1920
import com.flow.platform.api.domain.envs.FlowEnvs;
2021
import com.flow.platform.api.domain.envs.FlowEnvs.YmlStatusValue;
2122
import com.flow.platform.api.domain.node.Flow;
@@ -65,10 +66,11 @@ public class GitWebHookController extends NodeController {
6566
@PostMapping(path = "/{root}")
6667
public void onEventReceived(@RequestHeader HttpHeaders headers, HttpServletRequest request) {
6768
final String path = currentNodePath.get();
68-
6969
Map<String, String> headerAsMap = headers.toSingleValueMap();
70+
7071
String body;
7172
try {
73+
request.setCharacterEncoding(AppConfig.DEFAULT_CHARSET.name());
7274
body = CharStreams.toString(request.getReader());
7375
} catch (IOException e) {
7476
throw new IllegalStatusException("Cannot read raw body");

platform-api/src/main/java/com/flow/platform/api/controller/JobController.java

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,14 @@
2525
import com.flow.platform.api.service.job.JobSearchService;
2626
import com.flow.platform.api.service.node.YmlService;
2727
import com.flow.platform.api.util.I18nUtil;
28+
import com.flow.platform.core.exception.NotFoundException;
2829
import com.flow.platform.util.Logger;
2930
import com.flow.platform.util.StringUtil;
3031
import com.flow.platform.util.git.model.GitEventType;
3132
import com.google.common.collect.Lists;
3233
import java.util.Collection;
3334
import java.util.Collections;
35+
import java.util.HashMap;
3436
import java.util.LinkedHashMap;
3537
import java.util.List;
3638
import java.util.Map;
@@ -95,9 +97,13 @@ public void setLocale(@RequestParam(required = false) String locale) {
9597
*
9698
*/
9799
@PostMapping(path = "/{root}")
98-
public void create() {
100+
public void create(@RequestBody(required = false) Map<String, String> envs) {
101+
if (envs == null) {
102+
envs = new LinkedHashMap<>();
103+
}
104+
99105
String path = currentNodePath.get();
100-
jobService.createJobAndYmlLoad(path, GitEventType.MANUAL, new LinkedHashMap<>(), currentUser.get(), null);
106+
jobService.createJobAndYmlLoad(path, GitEventType.MANUAL, envs, currentUser.get(), null);
101107
}
102108

103109
/**
@@ -169,7 +175,12 @@ public Job show(@PathVariable Integer buildNumber) {
169175
@GetMapping(path = "/{root}/{buildNumber}/yml")
170176
public String yml(@PathVariable Integer buildNumber) {
171177
String path = currentNodePath.get();
172-
return jobService.findYml(path, buildNumber);
178+
try {
179+
return jobService.findYml(path, buildNumber);
180+
} catch (NotFoundException ignore) {
181+
// ignore job node not found exception since maybe job node created when yml loading
182+
return StringUtil.EMPTY;
183+
}
173184
}
174185

175186
/**

platform-api/src/main/java/com/flow/platform/api/controller/WelcomeController.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public List<PropertySystemInfo> indexAll() {
113113
* system: Java SE,
114114
* version: 1.8.0
115115
* status: RUNNING,
116+
* type: JVM | DB | SERVER | ZK | MQ | CONFIG,
116117
* info: {
117118
* MEMORY: {
118119
* jvm.memory.max: 123123
@@ -150,6 +151,7 @@ public List<SystemInfo> componentInfo(@PathVariable String system) {
150151
* system: Java SE,
151152
* version: 1.8.0
152153
* status: RUNNING,
154+
* type: JVM | DB | SERVER | ZK | MQ | CONFIG,
153155
* info: {
154156
* MEMORY: {
155157
* jvm.memory.max: 123123
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2017 flow.ci
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.flow.platform.api.domain.envs;
18+
19+
/**
20+
* @author yang
21+
*/
22+
public enum AgentEnvs implements EnvKey {
23+
24+
FLOW_AGENT_WORKSPACE
25+
}

0 commit comments

Comments
 (0)