diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ddec17..8af44c4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [Unreleased] + +### Fixed + +- Simplify the path evaluation for docker + ## [0.1.0] - 2024-11-07 ### Added diff --git a/src/main/kotlin/dev/codebandits/container/gradle/tasks/Commands.kt b/src/main/kotlin/dev/codebandits/container/gradle/tasks/Commands.kt deleted file mode 100644 index f9d2027..0000000 --- a/src/main/kotlin/dev/codebandits/container/gradle/tasks/Commands.kt +++ /dev/null @@ -1,21 +0,0 @@ -package dev.codebandits.container.gradle.tasks - -import kotlin.io.bufferedReader -import kotlin.io.readText -import kotlin.io.use -import kotlin.text.trim - -internal object Commands { - val dockerPath: String = getCommandPath("docker") - - private fun getCommandPath(command: String): String { - val processBuilder = ProcessBuilder("which", "docker") - val process = processBuilder.start() - val output = process.inputStream.bufferedReader().use { it.readText() } - val exitCode = process.waitFor() - return when (exitCode) { - 0 -> output.trim() - else -> throw IllegalStateException("$command not found in system path.") - } - } -} diff --git a/src/main/kotlin/dev/codebandits/container/gradle/tasks/ContainerRunTask.kt b/src/main/kotlin/dev/codebandits/container/gradle/tasks/ContainerRunTask.kt index 418390c..e2ff3c3 100644 --- a/src/main/kotlin/dev/codebandits/container/gradle/tasks/ContainerRunTask.kt +++ b/src/main/kotlin/dev/codebandits/container/gradle/tasks/ContainerRunTask.kt @@ -46,7 +46,7 @@ public abstract class ContainerRunTask : ContainerExecTask() { actionSteps.add( ExecutionStep( execAction = { - executable = Commands.dockerPath + executable = "docker" args(*dockerArgs) val dockerHost = spec.dockerHost.orNull if (dockerHost != null) { diff --git a/src/main/kotlin/dev/codebandits/container/gradle/tasks/TaskImages.kt b/src/main/kotlin/dev/codebandits/container/gradle/tasks/TaskImages.kt index c7f46ea..c203fbd 100644 --- a/src/main/kotlin/dev/codebandits/container/gradle/tasks/TaskImages.kt +++ b/src/main/kotlin/dev/codebandits/container/gradle/tasks/TaskImages.kt @@ -24,7 +24,7 @@ public abstract class TaskImages(private val task: Task) { execAction = { val file = imageIdentifierFileProvider.get().asFile file.parentFile.mkdirs() - executable = Commands.dockerPath + executable = "docker" args("inspect", "--format", "{{.Id}}", imageReference) standardOutput = imageIdentifierFileProvider.get().asFile.outputStream() errorOutput = OutputStream.nullOutputStream() @@ -57,7 +57,7 @@ public abstract class TaskImages(private val task: Task) { execAction = { val file = imageIdentifierFileProvider.get().asFile file.parentFile.mkdirs() - this.executable = Commands.dockerPath + executable = "docker" args("manifest", "inspect", imageReference) standardOutput = file.outputStream() isIgnoreExitValue = true