From 569fafba813cf14f1231401383df1d8dbb45b971 Mon Sep 17 00:00:00 2001 From: Haiyan Meng Date: Sat, 11 Jan 2020 15:32:25 -0800 Subject: [PATCH] Add the Document ID pointing to a kuostomization root into cache to avoid crawl it repeatedly --- api/internal/crawl/crawler/crawler.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api/internal/crawl/crawler/crawler.go b/api/internal/crawl/crawler/crawler.go index 568dfacc0..934a3e4ec 100644 --- a/api/internal/crawl/crawler/crawler.go +++ b/api/internal/crawl/crawler/crawler.go @@ -137,6 +137,14 @@ func doCrawl(ctx context.Context, docsPtr *CrawlSeed, crawlers []Crawler, conv C continue } + // If the Document represents a kustomization root, FetchDcoument will change + // the `filePath` field of the Document by adding `kustomization.yaml` or + // `kustomization.yml` or `kustomization` into the the field. + // Therefore, it is necessary to add the ID of the Document into seen before + // calling FetchDocument. Otherwise, the binary may enter into an infinite loop + // if a kustomization file points to its kustmozation root in its `resources` or + // `bases` field. + seen[tail.ID()] = struct{}{} if err := match.FetchDocument(ctx, tail); err != nil { logger.Printf("FetchDocument failed on %s %s: %v",