Search in sources :

Example 6 with Imports

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));
}
Also used : PartialProcessKey(com.walmartlabs.concord.server.sdk.PartialProcessKey) ConcordApplicationException(com.walmartlabs.concord.server.sdk.ConcordApplicationException) PartialProcessKey(com.walmartlabs.concord.server.sdk.PartialProcessKey) ProcessKey(com.walmartlabs.concord.server.sdk.ProcessKey) Imports(com.walmartlabs.concord.imports.Imports) ValidationErrorsException(org.sonatype.siesta.ValidationErrorsException) UserPrincipal(com.walmartlabs.concord.server.security.UserPrincipal) WithTimer(com.walmartlabs.concord.server.sdk.metrics.WithTimer) ApiOperation(io.swagger.annotations.ApiOperation)

Example 7 with Imports

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);
}
Also used : ProcessDefinition(io.takari.bpm.model.ProcessDefinition) Imports(com.walmartlabs.concord.imports.Imports) YamlImportConverter.convertImports(com.walmartlabs.concord.project.yaml.YamlImportConverter.convertImports) Profile(com.walmartlabs.concord.project.model.Profile) YamlProfile(com.walmartlabs.concord.project.yaml.model.YamlProfile) ProjectDefinition(com.walmartlabs.concord.project.model.ProjectDefinition) Trigger(com.walmartlabs.concord.project.model.Trigger) Resources(com.walmartlabs.concord.project.model.Resources) FormDefinition(io.takari.bpm.model.form.FormDefinition)

Example 8 with Imports

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);
}
Also used : Imports(com.walmartlabs.concord.imports.Imports) Test(org.junit.jupiter.api.Test) AbstractParserTest(com.walmartlabs.concord.project.runtime.v2.parser.AbstractParserTest)

Example 9 with Imports

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());
}
Also used : Import(com.walmartlabs.concord.imports.Import) Imports(com.walmartlabs.concord.imports.Imports) Test(org.junit.jupiter.api.Test)

Example 10 with Imports

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());
}
Also used : Import(com.walmartlabs.concord.imports.Import) Imports(com.walmartlabs.concord.imports.Imports) SecretDefinition(com.walmartlabs.concord.imports.Import.SecretDefinition) Test(org.junit.jupiter.api.Test)

Aggregations

Imports (com.walmartlabs.concord.imports.Imports)10 Test (org.junit.jupiter.api.Test)3 Import (com.walmartlabs.concord.imports.Import)2 ProjectDefinition (com.walmartlabs.concord.project.model.ProjectDefinition)2 Resources (com.walmartlabs.concord.project.model.Resources)2 Snapshot (com.walmartlabs.concord.repository.Snapshot)2 YamlParserV2 (com.walmartlabs.concord.runtime.v2.parser.YamlParserV2)2 PartialProcessKey (com.walmartlabs.concord.server.sdk.PartialProcessKey)2 ProcessKey (com.walmartlabs.concord.server.sdk.ProcessKey)2 SecretDefinition (com.walmartlabs.concord.imports.Import.SecretDefinition)1 Profile (com.walmartlabs.concord.project.model.Profile)1 Trigger (com.walmartlabs.concord.project.model.Trigger)1 AbstractParserTest (com.walmartlabs.concord.project.runtime.v2.parser.AbstractParserTest)1 YamlImportConverter.convertImports (com.walmartlabs.concord.project.yaml.YamlImportConverter.convertImports)1 YamlProfile (com.walmartlabs.concord.project.yaml.model.YamlProfile)1 ExclusiveMode (com.walmartlabs.concord.runtime.v2.model.ExclusiveMode)1 ProcessQueueEntry (com.walmartlabs.concord.server.process.queue.ProcessQueueEntry)1 ProcessResponse (com.walmartlabs.concord.server.queueclient.message.ProcessResponse)1 ConcordApplicationException (com.walmartlabs.concord.server.sdk.ConcordApplicationException)1 ProcessStatus (com.walmartlabs.concord.server.sdk.ProcessStatus)1