From 8d806a741b9935c0ecf023e916c2285ac3b4087a Mon Sep 17 00:00:00 2001 From: Avimanyu Mukhopadhyay Date: Thu, 4 Nov 2021 18:24:53 -0700 Subject: [PATCH] Adding logging, and hash map --- .../dockerfileimageupdate/utils/DockerfileGitHubUtil.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/utils/DockerfileGitHubUtil.java b/dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/utils/DockerfileGitHubUtil.java index 2b5c2b76..98eb31bd 100644 --- a/dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/utils/DockerfileGitHubUtil.java +++ b/dockerfile-image-update/src/main/java/com/salesforce/dockerfileimageupdate/utils/DockerfileGitHubUtil.java @@ -22,6 +22,7 @@ import java.io.*; import java.util.*; +import java.util.HashMap; import java.util.concurrent.TimeUnit; /** @@ -140,6 +141,10 @@ public Optional>> findFilesWithImage( log.warn("Number of search results for a single org {} is above {}! The GitHub Search API will only return around 1000 results - https://developer.github.com/v3/search/#about-the-search-api", orgName, gitApiSearchLimit); } else if (totalCount > gitApiSearchLimit) { + log.info("The number of files returned is greater than the git API search limit" + + " of {}. The orgs with the maximum number of hits will be recursively removed" + + " to reduce the search space. For every org that is excluded, a separate " + + "search will be performed specific to that org.", gitApiSearchLimit); return getSearchResultsExcludingOrgWithMostHits(image, files, orgsToIncludeOrExclude, gitApiSearchLimit); } List> filesList = new ArrayList<>(); @@ -401,7 +406,8 @@ public boolean thisUserIsOwner(GHRepository repo) throws IOException { public Optional>> getGHContents(String org, String img, Integer gitApiSearchLimit) throws IOException, InterruptedException { Optional>> contentsWithImage = Optional.empty(); - Map orgsToIncludeInSearch = Collections.unmodifiableMap(Collections.singletonMap(org, true)); + Map orgsToIncludeInSearch = new HashMap<>(); + orgsToIncludeInSearch.put(org, true); for (int i = 0; i < 5; i++) { contentsWithImage = findFilesWithImage(img, orgsToIncludeInSearch, gitApiSearchLimit); if (contentsWithImage