Skip to content

Commit d1a81d1

Browse files
authored
concord-server: skip validation of disabled repos during project creation (#883)
1 parent 607b87a commit d1a81d1

File tree

3 files changed

+16
-10
lines changed

3 files changed

+16
-10
lines changed

server/impl/src/main/java/com/walmartlabs/concord/server/org/project/ProjectManager.java

+3
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,9 @@ private Map<String, ProcessDefinition> loadProcessDefinitions(UUID orgId, UUID p
213213

214214
Map<String, ProcessDefinition> result = new HashMap<>();
215215
for (Map.Entry<String, RepositoryEntry> e : projectEntry.getRepositories().entrySet()) {
216+
if (e.getValue().isDisabled()) {
217+
continue;
218+
}
216219
ProcessDefinition processDefinition = projectRepositoryManager.processDefinition(orgId, projectId, e.getValue());
217220
result.put(e.getKey(), processDefinition);
218221
}

server/impl/src/main/java/com/walmartlabs/concord/server/org/project/ProjectRepositoryManager.java

+1-10
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141

4242
import javax.annotation.Nullable;
4343
import javax.inject.Inject;
44-
import javax.ws.rs.WebApplicationException;
4544
import javax.ws.rs.core.Response;
4645
import java.util.*;
4746

@@ -120,7 +119,7 @@ public void replace(DSLContext tx, UUID orgId, UUID projectId, Collection<Reposi
120119

121120
for (RepositoryEntry re : repos) {
122121
SecretEntry secret = assertSecret(orgId, re);
123-
insertOrUpdate(tx, projectId, null, re, secret, assertProcessDefinition(re.getName(), processDefinitions));
122+
insertOrUpdate(tx, projectId, null, re, secret, processDefinitions.get(re.getName()));
124123
}
125124
}
126125

@@ -209,14 +208,6 @@ private SecretEntry assertSecret(UUID orgId, RepositoryEntry entry) {
209208
return secretManager.assertAccess(orgId, entry.getSecretId(), entry.getSecretName(), ResourceAccessLevel.READER, false);
210209
}
211210

212-
private ProcessDefinition assertProcessDefinition(String name, Map<String, ProcessDefinition> processDefinitions) {
213-
ProcessDefinition result = processDefinitions.get(name);
214-
if (result != null) {
215-
return result;
216-
}
217-
throw new WebApplicationException("Process definition not found: " + name, Response.Status.INTERNAL_SERVER_ERROR);
218-
}
219-
220211
private static String trim(String s) {
221212
if (s == null) {
222213
return null;

server/impl/src/main/java/com/walmartlabs/concord/server/org/project/RepositoryEntry.java

+12
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,18 @@ public boolean isTriggersDisabled() {
175175
return triggersDisabled;
176176
}
177177

178+
public RepositoryEntry withBranch(String branch) {
179+
return new RepositoryEntry(id, projectId, name, url, branch, commitId, path, disabled, secretId, secretName, secretStoreType, meta, triggersDisabled);
180+
}
181+
182+
public RepositoryEntry withPath(String path) {
183+
return new RepositoryEntry(id, projectId, name, url, branch, commitId, path, disabled, secretId, secretName, secretStoreType, meta, triggersDisabled);
184+
}
185+
186+
public RepositoryEntry withDisabled(boolean disabled) {
187+
return new RepositoryEntry(id, projectId, name, url, branch, commitId, path, disabled, secretId, secretName, secretStoreType, meta, triggersDisabled);
188+
}
189+
178190
@Override
179191
public String toString() {
180192
return "RepositoryEntry{" +

0 commit comments

Comments
 (0)