Skip to content

Commit

Permalink
Skip the directory entry when creating xDS resources at server startup (
Browse files Browse the repository at this point in the history
line#1020)

Motivation:
`Repository.find(...)` fetches not just files but for directories. We should skip the directories when creating xDS resources.
  • Loading branch information
minwoox authored Aug 20, 2024
1 parent df9c1fb commit de33ce6
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@

import com.linecorp.centraldogma.common.Change;
import com.linecorp.centraldogma.common.Entry;
import com.linecorp.centraldogma.common.EntryType;
import com.linecorp.centraldogma.common.RepositoryNotFoundException;
import com.linecorp.centraldogma.common.Revision;
import com.linecorp.centraldogma.server.metadata.MetadataService;
Expand Down Expand Up @@ -85,6 +86,9 @@ protected void init() {
logger.info("Creating xDS resources from {} at revision: {}", groupName, normalizedRevision);
final Map<String, Entry<?>> entries = repository.find(normalizedRevision, pathPattern()).join();
for (Entry<?> entry : entries.values()) {
if (entry.type() != EntryType.JSON || !entry.hasContent()) {
continue;
}
final String path = entry.path();
final String contentAsText = entry.contentAsText();
try {
Expand All @@ -105,7 +109,7 @@ protected void init() {
private void watchDogmaRepository() {
final Repository dogmaRepository = xdsProject.repos().get(Project.REPO_DOGMA);
// TODO(minwoox): Use different file because metadata.json contains other information than repo's names.
dogmaRepository.addListener(RepositoryListener.of(MetadataService.METADATA_JSON, entries -> {
dogmaRepository.addListener(RepositoryListener.of(MetadataService.METADATA_JSON, unused -> {
executor().execute(() -> {
for (Repository repo : xdsProject.repos().list().values()) {
final String groupName = repo.name();
Expand Down

0 comments on commit de33ce6

Please sign in to comment.