use of com.walmartlabs.concord.imports.Imports in project concord by walmartlabs.
the class ProcessResource method fork.
/**
* Starts a new child process by forking the start of the specified parent process.
*
* @param parentInstanceId
* @param req
* @param sync
* @return
*/
@POST
@ApiOperation("Fork a process")
@javax.ws.rs.Path("/{id}/fork")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
@WithTimer
public StartProcessResponse fork(@ApiParam @PathParam("id") UUID parentInstanceId, @ApiParam Map<String, Object> req, @ApiParam @Deprecated @DefaultValue("false") @QueryParam("sync") boolean sync, @ApiParam @QueryParam("out") String[] out) {
if (sync) {
throw syncIsForbidden();
}
ProcessEntry parent = processQueueManager.get(PartialProcessKey.from(parentInstanceId));
if (parent == null) {
throw new ValidationErrorsException("Unknown parent instance ID: " + parentInstanceId);
}
PartialProcessKey processKey = PartialProcessKey.from(UUID.randomUUID());
ProcessKey parentProcessKey = new ProcessKey(parent.instanceId(), parent.createdAt());
UUID projectId = parent.projectId();
UserPrincipal userPrincipal = UserPrincipal.assertCurrent();
Set<String> handlers = parent.handlers();
Imports imports = queueDao.getImports(parentProcessKey);
Payload payload;
try {
payload = payloadManager.createFork(processKey, parentProcessKey, ProcessKind.DEFAULT, userPrincipal.getId(), userPrincipal.getUsername(), projectId, req, out, handlers, imports);
} catch (IOException e) {
log.error("fork ['{}', '{}'] -> error creating a payload: {}", processKey, parentProcessKey, e);
throw new ConcordApplicationException("Error creating a payload", e);
}
return toResponse(processManager.startFork(payload));
}
use of com.walmartlabs.concord.imports.Imports in project concord by walmartlabs.
the class YamlProjectConverter method convert.
public static ProjectDefinition convert(YamlProject project) throws YamlConverterException {
Map<String, ProcessDefinition> flows = convertFlows(project.getFlows());
Set<String> publicFlows = project.getPublicFlows();
Map<String, FormDefinition> forms = convertForms(project.getForms());
Map<String, Object> cfg = project.getConfiguration();
Map<String, Profile> profiles = convertProfiles(project.getProfiles());
List<Trigger> triggers = YamlTriggersConverter.convert(project.getTriggers());
Imports imports = convertImports(project.getImports());
Resources resources = convertResources(project.getResources());
return new ProjectDefinition(flows, publicFlows, forms, cfg, profiles, triggers, imports, resources);
}
use of com.walmartlabs.concord.imports.Imports in project concord by walmartlabs.
the class ProjectSerializerV2Test method testProcessDefinition.
@Test
public void testProcessDefinition() throws Exception {
Map<String, Form> forms = Collections.singletonMap("form1", Form.builder().name("form1").addFields(FormField.builder().name("field1").type("string").cardinality(com.walmartlabs.concord.forms.FormField.Cardinality.ANY).location(location()).build()).location(location()).build());
Trigger trigger = Trigger.builder().name("github").location(location()).putConfiguration("entryPoint", "www").putConfiguration("useInitiator", true).putConditions("type", "push").putConditions("status", Arrays.asList("opened", "reopened")).putArguments("arg", "arg-value").addActiveProfiles("p1").build();
Imports imports = Imports.of(Collections.singletonList(Import.MvnDefinition.builder().url("http://url").dest("dest").build()));
ProcessDefinitionConfiguration cfg = ProcessDefinitionConfiguration.builder().parallelLoopParallelism(123).build();
ProcessDefinition pd = ProcessDefinition.builder().configuration(cfg).forms(forms).putFlows("flow1", steps()).addPublicFlows("flow1").addTriggers(trigger).imports(imports).build();
String result = toYaml(pd);
assertResult("serializer/processDefinition.yml", result);
}
use of com.walmartlabs.concord.imports.Imports in project concord by walmartlabs.
the class YamlOkParserTest method test007.
// Imports Definition Test
@Test
public void test007() throws Exception {
ProcessDefinition pd = load("007.yml");
Imports imports = pd.imports();
assertNotNull(imports);
assertEquals(4, imports.items().size());
Import i = imports.items().get(0);
assertEquals("git", i.type());
Import.GitDefinition g = (Import.GitDefinition) i;
assertEquals("https://github.com/me/my_private_repo.git", g.url());
assertEquals("test", g.name());
assertEquals("1.2.3", g.version());
assertEquals("/", g.path());
assertEquals("/dest", g.dest());
assertEquals(Arrays.asList("a", "b"), g.exclude());
assertEquals(Import.SecretDefinition.builder().name("my_secret_key").build(), g.secret());
assertEquals("git", imports.items().get(1).type());
assertEquals("mvn", imports.items().get(2).type());
assertEquals("dir", imports.items().get(3).type());
}
use of com.walmartlabs.concord.imports.Imports in project concord by walmartlabs.
the class MessageSerializerTest method testProcessResponse.
@Test
public void testProcessResponse() {
SecretDefinition secret = SecretDefinition.builder().org("secret-org").name("secret-name").password("secret-password").build();
Import item = Import.GitDefinition.builder().url("http://url").version("master").dest("concord").path("path1").secret(secret).build();
Imports imports = Imports.of(Collections.singletonList(item));
ProcessResponse r = new ProcessResponse(123, "sesion-token", UUID.randomUUID(), "org-name", "repo-url", "repo-path", "commit-id", "repo-branch", "secret-name", imports);
// ---
String rSerialized = MessageSerializer.serialize(r);
assertNotNull(rSerialized);
ProcessResponse rDeserialized = MessageSerializer.deserialize(rSerialized);
assertEquals(r.getMessageType(), MessageType.PROCESS_RESPONSE);
assertEquals(r.getSessionToken(), rDeserialized.getSessionToken());
assertEquals(r.getProcessId(), rDeserialized.getProcessId());
assertEquals(r.getCorrelationId(), rDeserialized.getCorrelationId());
assertEquals("repo-branch", rDeserialized.getRepoBranch());
}
Aggregations