com.salesforce.dockerfileimageupdate.utils.PullRequests Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of dockerfile-image-update Show documentation
Show all versions of dockerfile-image-update Show documentation
This tool provides a mechanism to make security updates to docker images at scale.
The tool searches github for declared docker images and sends pull requests to projects that are not using
the desired version of the requested docker image.
package com.salesforce.dockerfileimageupdate.utils;
import com.google.common.collect.*;
import com.salesforce.dockerfileimageupdate.model.*;
import com.salesforce.dockerfileimageupdate.process.*;
import net.sourceforge.argparse4j.inf.*;
import org.kohsuke.github.*;
import org.slf4j.*;
import java.io.*;
import java.util.*;
public class PullRequests {
private static final Logger log = LoggerFactory.getLogger(PullRequests.class);
public void prepareToCreate(final Namespace ns,
GitHubPullRequestSender pullRequestSender,
PagedSearchIterable contentsFoundWithImage,
GitForkBranch gitForkBranch,
DockerfileGitHubUtil dockerfileGitHubUtil,
RateLimiter rateLimiter) throws IOException {
Multimap pathToDockerfilesInParentRepo =
pullRequestSender.forkRepositoriesFoundAndGetPathToDockerfiles(contentsFoundWithImage, gitForkBranch);
List exceptions = new ArrayList<>();
List skippedRepos = new ArrayList<>();
for (String currUserRepo : pathToDockerfilesInParentRepo.keySet()) {
Optional forkWithContentPaths =
pathToDockerfilesInParentRepo.get(currUserRepo).stream().findFirst();
if (forkWithContentPaths.isPresent()) {
try {
dockerfileGitHubUtil.changeDockerfiles(ns,
pathToDockerfilesInParentRepo,
forkWithContentPaths.get(), skippedRepos,
gitForkBranch, rateLimiter);
} catch (IOException | InterruptedException e) {
log.error(String.format("Error changing Dockerfile for %s", forkWithContentPaths.get().getParent().getFullName()), e);
exceptions.add((IOException) e);
}
} else {
log.warn("Didn't find fork for {} so not changing Dockerfiles", currUserRepo);
}
}
ResultsProcessor.processResults(skippedRepos, exceptions, log);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy