-
-
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
63 changed files
with
619 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
29 changes: 29 additions & 0 deletions
29
src/main/java/tech/jhipster/lite/generator/docker/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,29 @@ | ||
package tech.jhipster.lite.generator.docker; | ||
|
||
import org.springframework.stereotype.Service; | ||
import tech.jhipster.lite.generator.docker.application.DockerImagesApplicationService; | ||
import tech.jhipster.lite.generator.docker.domain.DockerImage; | ||
import tech.jhipster.lite.generator.docker.domain.DockerImageName; | ||
|
||
@Service | ||
public class DockerImages { | ||
|
||
private final DockerImagesApplicationService dockerImagesApplicationService; | ||
|
||
public DockerImages(DockerImagesApplicationService dockerImages) { | ||
this.dockerImagesApplicationService = 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 | ||
*/ | ||
public DockerImage get(String imageName) { | ||
return dockerImagesApplicationService.get(new DockerImageName(imageName)).orElseThrow(() -> new UnknownDockerImageException(imageName)); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
src/main/java/tech/jhipster/lite/generator/docker/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; | ||
|
||
import tech.jhipster.lite.error.domain.GeneratorException; | ||
|
||
class UnknownDockerImageException extends GeneratorException { | ||
|
||
public UnknownDockerImageException(String imageName) { | ||
super("Can't find image " + imageName + ", forgot to add it to src/main/resources/generator/dependencies/Dockerfile?"); | ||
} | ||
} |
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.
21 changes: 21 additions & 0 deletions
21
.../java/tech/jhipster/lite/generator/docker/application/DockerImagesApplicationService.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,21 @@ | ||
package tech.jhipster.lite.generator.docker.application; | ||
|
||
import java.util.Optional; | ||
import org.springframework.stereotype.Service; | ||
import tech.jhipster.lite.generator.docker.domain.DockerImage; | ||
import tech.jhipster.lite.generator.docker.domain.DockerImageName; | ||
import tech.jhipster.lite.generator.docker.domain.DockerImagesRepository; | ||
|
||
@Service | ||
public class DockerImagesApplicationService { | ||
|
||
private final DockerImagesRepository dockerImages; | ||
|
||
public DockerImagesApplicationService(DockerImagesRepository dockerImages) { | ||
this.dockerImages = dockerImages; | ||
} | ||
|
||
public Optional<DockerImage> get(DockerImageName imageName) { | ||
return dockerImages.get(imageName); | ||
} | ||
} |
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(); | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
src/main/java/tech/jhipster/lite/generator/docker/domain/DockerImagesRepository.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,7 @@ | ||
package tech.jhipster.lite.generator.docker.domain; | ||
|
||
import java.util.Optional; | ||
|
||
public interface DockerImagesRepository { | ||
Optional<DockerImage> get(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.
15 changes: 0 additions & 15 deletions
15
.../jhipster/lite/generator/docker/infrastructure/configuration/DockerBeanConfiguration.java
This file was deleted.
Oops, something went wrong.
52 changes: 52 additions & 0 deletions
52
...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,52 @@ | ||
package tech.jhipster.lite.generator.docker.infrastructure.secondary; | ||
|
||
import java.util.Optional; | ||
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.DockerImagesRepository; | ||
|
||
@Repository | ||
class FileSystemDockerImagesRepository implements DockerImagesRepository { | ||
|
||
private static final String DOCKER_FROM = "from "; | ||
|
||
private final ProjectFilesReader files; | ||
|
||
public FileSystemDockerImagesRepository(ProjectFilesReader files) { | ||
this.files = files; | ||
} | ||
|
||
@Override | ||
public Optional<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()); | ||
} | ||
|
||
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.