-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check if file exists when executable path is passed in through jib dockerClient.executable #3744
Conversation
…ockerClient.executable
* | ||
* @return {@code true} if Docker is installed on the user's system and accessible | ||
*/ | ||
public static boolean isDefaultDockerInstalled() { | ||
return isDockerInstalled(DEFAULT_DOCKER_CLIENT); | ||
try { | ||
new ProcessBuilder(DEFAULT_DOCKER_CLIENT.toString()).start(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some background of this change: Checking for existence of the default docker command when it is on PATH has been a little tricky. There can be several places where docker could be installed on a system and this also differs from OS to OS. For checking whether the path passed through jib.dockerClient.executable
is installed correctly, however, we no longer run executable itself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, that's a good idea.
Kudos, SonarCloud Quality Gate passed! |
* | ||
* @return {@code true} if Docker is installed on the user's system and accessible | ||
*/ | ||
public static boolean isDefaultDockerInstalled() { | ||
return isDockerInstalled(DEFAULT_DOCKER_CLIENT); | ||
try { | ||
new ProcessBuilder(DEFAULT_DOCKER_CLIENT.toString()).start(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh, that's a good idea.
Thank you for the review @elefeint! Changes also succeeded on continuous build. The integration tests cover both scenarios: when default docker is installed and when docker executable is provided. Will be merging this PR. |
Currently, in order to verify if the docker path provided (either default or specified by the user) is installed correctly, we actually run the executable. The side effect of this is that any arbitrary executable can be executed by Jib.
This PR avoids the need to run the executable by using Files.isExecutable which verifies if the path provided exists and the JVM has the correct permissions to execute the path. However in the case of verifying whether docker is on PATH, running the
docker
command seems unavoidable at the moment. Reasoning in #3744 (comment)Verified with
./gradlew jib-gradle-plugin:integrationTest