Skip to content

Commit

Permalink
concord-server: skip validation of disabled repos during project crea…
Browse files Browse the repository at this point in the history
…tion (#883)
  • Loading branch information
ibodrov authored Mar 23, 2024
1 parent 607b87a commit d1a81d1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,9 @@ private Map<String, ProcessDefinition> loadProcessDefinitions(UUID orgId, UUID p

Map<String, ProcessDefinition> result = new HashMap<>();
for (Map.Entry<String, RepositoryEntry> e : projectEntry.getRepositories().entrySet()) {
if (e.getValue().isDisabled()) {
continue;
}
ProcessDefinition processDefinition = projectRepositoryManager.processDefinition(orgId, projectId, e.getValue());
result.put(e.getKey(), processDefinition);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@

import javax.annotation.Nullable;
import javax.inject.Inject;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
import java.util.*;

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

for (RepositoryEntry re : repos) {
SecretEntry secret = assertSecret(orgId, re);
insertOrUpdate(tx, projectId, null, re, secret, assertProcessDefinition(re.getName(), processDefinitions));
insertOrUpdate(tx, projectId, null, re, secret, processDefinitions.get(re.getName()));
}
}

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

private ProcessDefinition assertProcessDefinition(String name, Map<String, ProcessDefinition> processDefinitions) {
ProcessDefinition result = processDefinitions.get(name);
if (result != null) {
return result;
}
throw new WebApplicationException("Process definition not found: " + name, Response.Status.INTERNAL_SERVER_ERROR);
}

private static String trim(String s) {
if (s == null) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,18 @@ public boolean isTriggersDisabled() {
return triggersDisabled;
}

public RepositoryEntry withBranch(String branch) {
return new RepositoryEntry(id, projectId, name, url, branch, commitId, path, disabled, secretId, secretName, secretStoreType, meta, triggersDisabled);
}

public RepositoryEntry withPath(String path) {
return new RepositoryEntry(id, projectId, name, url, branch, commitId, path, disabled, secretId, secretName, secretStoreType, meta, triggersDisabled);
}

public RepositoryEntry withDisabled(boolean disabled) {
return new RepositoryEntry(id, projectId, name, url, branch, commitId, path, disabled, secretId, secretName, secretStoreType, meta, triggersDisabled);
}

@Override
public String toString() {
return "RepositoryEntry{" +
Expand Down

0 comments on commit d1a81d1

Please sign in to comment.