-
-
Notifications
You must be signed in to change notification settings - Fork 217
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
60 changed files
with
562 additions
and
875 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
src/main/java/tech/jhipster/lite/common/domain/ProjectFilesReader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package tech.jhipster.lite.common.domain; | ||
|
||
public interface ProjectFilesReader { | ||
String read(String path); | ||
} |
14 changes: 8 additions & 6 deletions
14
.../generator/module/domain/FilesReader.java → ...condary/FileSystemProjectFilesReader.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
src/main/java/tech/jhipster/lite/generator/docker/application/DockerApplicationService.java
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
src/main/java/tech/jhipster/lite/generator/docker/domain/DockerDomainService.java
This file was deleted.
Oops, something went wrong.
14 changes: 14 additions & 0 deletions
14
src/main/java/tech/jhipster/lite/generator/docker/domain/DockerImage.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package tech.jhipster.lite.generator.docker.domain; | ||
|
||
import tech.jhipster.lite.error.domain.Assert; | ||
|
||
public record DockerImage(String imageName, String version) { | ||
public DockerImage { | ||
Assert.notNull("imageName", imageName); | ||
Assert.notNull("version", version); | ||
} | ||
|
||
public String fullName() { | ||
return imageName() + ":" + version(); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/java/tech/jhipster/lite/generator/docker/domain/DockerImageName.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package tech.jhipster.lite.generator.docker.domain; | ||
|
||
import tech.jhipster.lite.error.domain.Assert; | ||
|
||
public record DockerImageName(String imageName) { | ||
public DockerImageName(String imageName) { | ||
Assert.notBlank("imageName", imageName); | ||
|
||
this.imageName = imageName.toLowerCase(); | ||
} | ||
|
||
public String get() { | ||
return imageName(); | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
src/main/java/tech/jhipster/lite/generator/docker/domain/DockerImages.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package tech.jhipster.lite.generator.docker.domain; | ||
|
||
public interface DockerImages { | ||
/** | ||
* Get docker image information | ||
* | ||
* @param imageName | ||
* name of the image to get information for | ||
* @return The docker image with this name | ||
* @throws UnknownDockerImageException | ||
* if the image can't be found | ||
*/ | ||
DockerImage get(DockerImageName imageName); | ||
|
||
/** | ||
* Get docker image information | ||
* | ||
* @param imageName | ||
* name of the image to get information for | ||
* @return The docker image with this name | ||
* @throws UnknownDockerImageException | ||
* if the image can't be found | ||
*/ | ||
default DockerImage get(String imageName) { | ||
return get(new DockerImageName(imageName)); | ||
} | ||
} |
9 changes: 0 additions & 9 deletions
9
src/main/java/tech/jhipster/lite/generator/docker/domain/DockerService.java
This file was deleted.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
src/main/java/tech/jhipster/lite/generator/docker/domain/UnknownDockerImageException.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package tech.jhipster.lite.generator.docker.domain; | ||
|
||
import tech.jhipster.lite.error.domain.GeneratorException; | ||
|
||
public class UnknownDockerImageException extends GeneratorException { | ||
|
||
public UnknownDockerImageException(DockerImageName imageName) { | ||
super("Can't find image " + imageName.get() + ", forgot to add it to src/main/resources/generator/dependencies/Dockerfile?"); | ||
} | ||
} |
15 changes: 0 additions & 15 deletions
15
.../jhipster/lite/generator/docker/infrastructure/configuration/DockerBeanConfiguration.java
This file was deleted.
Oops, something went wrong.
53 changes: 53 additions & 0 deletions
53
...ster/lite/generator/docker/infrastructure/secondary/FileSystemDockerImagesRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package tech.jhipster.lite.generator.docker.infrastructure.secondary; | ||
|
||
import java.util.function.Function; | ||
import java.util.function.Predicate; | ||
import java.util.stream.Stream; | ||
import org.springframework.stereotype.Repository; | ||
import tech.jhipster.lite.common.domain.ProjectFilesReader; | ||
import tech.jhipster.lite.error.domain.Assert; | ||
import tech.jhipster.lite.generator.docker.domain.DockerImage; | ||
import tech.jhipster.lite.generator.docker.domain.DockerImageName; | ||
import tech.jhipster.lite.generator.docker.domain.DockerImages; | ||
import tech.jhipster.lite.generator.docker.domain.UnknownDockerImageException; | ||
|
||
@Repository | ||
class FileSystemDockerImagesRepository implements DockerImages { | ||
|
||
private static final String DOCKER_FROM = "from "; | ||
|
||
private final ProjectFilesReader files; | ||
|
||
public FileSystemDockerImagesRepository(ProjectFilesReader files) { | ||
this.files = files; | ||
} | ||
|
||
@Override | ||
public DockerImage get(DockerImageName imageName) { | ||
Assert.notNull("imageName", imageName); | ||
|
||
return Stream | ||
.of(files.read("/generator/dependencies/Dockerfile").split("[\r\n]")) | ||
.map(String::trim) | ||
.map(String::toLowerCase) | ||
.filter(imageLine(imageName)) | ||
.findFirst() | ||
.map(toDockerImage()) | ||
.orElseThrow(() -> new UnknownDockerImageException(imageName)); | ||
} | ||
|
||
private Predicate<String> imageLine(DockerImageName imageName) { | ||
return line -> line.startsWith(DOCKER_FROM + imageName.get() + ":"); | ||
} | ||
|
||
private Function<String, DockerImage> toDockerImage() { | ||
return line -> { | ||
int versionSeparatorIndex = line.lastIndexOf(":"); | ||
|
||
return new DockerImage( | ||
line.substring(DOCKER_FROM.length(), versionSeparatorIndex), | ||
line.substring(versionSeparatorIndex + 1, line.length()) | ||
); | ||
}; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.