use of com.walmartlabs.concord.server.events.github.GithubRepoInfo 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