use of com.walmartlabs.concord.server.org.project.RepositoryEntry in project concord by walmartlabs.
the class RepositoryProcessor method getRepositoryEntry.
private RepositoryEntry getRepositoryEntry(Payload payload) {
UUID projectId = payload.getHeader(Payload.PROJECT_ID);
UUID repoId = payload.getHeader(Payload.REPOSITORY_ID);
if (projectId == null || repoId == null) {
return null;
}
RepositoryEntry repo = repositoryDao.get(projectId, repoId);
if (repo == null) {
return null;
}
Map<String, Object> cfg = payload.getHeader(Payload.CONFIGURATION);
if (cfg != null) {
String commitId = MapUtils.getString(cfg, Constants.Request.REPO_COMMIT_ID, repo.getCommitId());
String branchOrTag = MapUtils.getString(cfg, Constants.Request.REPO_BRANCH_OR_TAG, commitId == null ? repo.getBranch() : null);
repo = new RepositoryEntry(repo, branchOrTag, commitId);
}
return repo;
}
use of com.walmartlabs.concord.server.org.project.RepositoryEntry in project concord by walmartlabs.
the class SecretDaoTest method testOnCascade.
@Test
public void testOnCascade() {
UUID orgId = OrganizationManager.DEFAULT_ORG_ID;
String projectName = "project#" + System.currentTimeMillis();
ProjectDao projectDao = new ProjectDao(getConfiguration(), new ConcordObjectMapper(TestObjectMapper.INSTANCE));
UUID projectId = projectDao.insert(orgId, projectName, "test", null, null, null, null, new byte[0], null, null);
String secretName = "secret#" + System.currentTimeMillis();
SecretDao secretDao = new SecretDao(getConfiguration());
UUID secretId = secretDao.insert(orgId, null, secretName, null, SecretType.KEY_PAIR, SecretEncryptedByType.SERVER_KEY, "concord", SecretVisibility.PUBLIC, INSERT);
secretDao.updateData(secretId, new byte[] { 0, 1, 2 });
secretDao.update(secretId, secretName, UUID.fromString("4b9d496a-c3a0-4e1b-804c-ac3fccddcb27"), null, new byte[0], null, projectId, orgId);
String repoName = "repo#" + System.currentTimeMillis();
RepositoryDao repositoryDao = new RepositoryDao(getConfiguration(), new ConcordObjectMapper(TestObjectMapper.INSTANCE));
UUID repoId = repositoryDao.insert(projectId, repoName, "n/a", null, null, null, secretId, false, null, false);
// ---
secretDao.delete(secretId);
// ---
RepositoryEntry r = repositoryDao.get(projectId, repoId);
assertNotNull(r);
assertNull(r.getSecretName());
}
use of com.walmartlabs.concord.server.org.project.RepositoryEntry in project concord by walmartlabs.
the class ProcessManager method assertRepositoryDisabled.
private void assertRepositoryDisabled(Payload payload) {
UUID repoId = payload.getHeader(Payload.REPOSITORY_ID);
if (repoId == null) {
return;
}
RepositoryEntry repo = repositoryDao.get(repoId);
if (repo.isDisabled()) {
throw new ConcordApplicationException("Repository is disabled -> " + repo.getName());
}
}
use of com.walmartlabs.concord.server.org.project.RepositoryEntry in project concord by walmartlabs.
the class TriggerV2Resource method list.
/**
* List process trigger definitions for the specified type.
*/
@GET
@ApiOperation(value = "List trigger definitions", responseContainer = "list", response = TriggerEntry.class)
@Produces(MediaType.APPLICATION_JSON)
public List<TriggerEntry> list(@ApiParam @QueryParam("type") @ConcordKey String type, @ApiParam @QueryParam("orgId") UUID orgId, @ApiParam @QueryParam("orgName") @ConcordKey String orgName, @ApiParam @QueryParam("projectId") UUID projectId, @ApiParam @QueryParam("projectName") @ConcordKey String projectName, @ApiParam @QueryParam("repoId") UUID repoId, @ApiParam @QueryParam("repoName") @ConcordKey String repoName) {
if (type != null && (type.isEmpty() || type.length() > 128)) {
throw new ValidationErrorsException("Invalid type value: " + type);
}
if (orgId == null && orgName != null) {
orgId = orgDao.getId(orgName);
if (orgId == null) {
throw new ValidationErrorsException("Organization not found: " + orgName);
}
}
if (projectId == null && projectName != null) {
if (orgId == null) {
throw new IllegalArgumentException("Organization ID or name is required");
}
projectId = projectDao.getId(orgId, projectName);
if (projectId == null) {
throw new ValidationErrorsException("Project not found: " + projectName);
}
}
if (repoId == null && repoName != null) {
ProjectEntry p = assertProject(projectId, ResourceAccessLevel.READER, false);
if (p == null) {
throw new IllegalArgumentException("Both organization and project IDs or names are required");
}
RepositoryEntry r = assertRepository(p, repoName);
repoId = r.getId();
}
return triggersDao.list(orgId, projectId, repoId, type);
}
use of com.walmartlabs.concord.server.org.project.RepositoryEntry in project concord by walmartlabs.
the class GithubTriggerEnricher method enrichTriggerConditions.
private Map<String, Object> enrichTriggerConditions(DSLContext tx, UUID repoId, Map<String, Object> conditions) {
if (conditions.containsKey(GITHUB_ORG_KEY) && conditions.containsKey(GITHUB_REPO_KEY) && conditions.containsKey(REPO_BRANCH_KEY)) {
return conditions;
}
RepositoryEntry repo = repositoryDao.get(tx, repoId);
GithubRepoInfo githubRepoInfo = GithubUtils.getRepositoryInfo(repo.getUrl());
if (githubRepoInfo == null) {
return conditions;
}
Map<String, Object> newParams = new HashMap<>(conditions);
newParams.putIfAbsent(GITHUB_ORG_KEY, githubRepoInfo.owner());
newParams.putIfAbsent(GITHUB_REPO_KEY, githubRepoInfo.name());
Object eventType = conditions.get(TYPE_KEY);
if ((PULL_REQUEST_EVENT.equals(eventType) || PUSH_EVENT.equals(eventType)) && (repo.getBranch() != null)) {
newParams.putIfAbsent(REPO_BRANCH_KEY, repo.getBranch());
}
return newParams;
}
Aggregations