Improve error when Docker Compose file not found
Fixes gh-35383
This commit is contained in:
@@ -109,8 +109,8 @@ public final class DockerComposeFile {
|
||||
*/
|
||||
public static DockerComposeFile of(File file) {
|
||||
Assert.notNull(file, "File must not be null");
|
||||
Assert.isTrue(file.exists(), () -> "'%s' does not exist".formatted(file));
|
||||
Assert.isTrue(file.isFile(), () -> "'%s' is not a file".formatted(file));
|
||||
Assert.isTrue(file.exists(), () -> "Docker Compose file '%s' does not exist".formatted(file));
|
||||
Assert.isTrue(file.isFile(), () -> "Docker compose file '%s' is not a file".formatted(file));
|
||||
return new DockerComposeFile(file);
|
||||
}
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@ import org.springframework.core.log.LogMessage;
|
||||
* @author Moritz Halbritter
|
||||
* @author Andy Wilkinson
|
||||
* @author Phillip Webb
|
||||
* @author Scott Frederick
|
||||
* @see DockerComposeListener
|
||||
*/
|
||||
class DockerComposeLifecycleManager {
|
||||
@@ -124,7 +125,12 @@ class DockerComposeLifecycleManager {
|
||||
protected DockerComposeFile getComposeFile() {
|
||||
DockerComposeFile composeFile = (this.properties.getFile() != null)
|
||||
? DockerComposeFile.of(this.properties.getFile()) : DockerComposeFile.find(this.workingDirectory);
|
||||
logger.info(LogMessage.format("Found Docker Compose file '%s'", composeFile));
|
||||
if (composeFile == null) {
|
||||
File dir = (this.workingDirectory != null) ? this.workingDirectory : new File(".");
|
||||
throw new IllegalStateException("No Docker Compose file found in directory '%s'"
|
||||
.formatted(dir.toPath().toAbsolutePath().toString()));
|
||||
}
|
||||
logger.info(LogMessage.format("Using Docker Compose file '%s'", composeFile));
|
||||
return composeFile;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user