-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
6c5ef97
commit 4abe88b
Showing
11 changed files
with
254 additions
and
3 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
8 changes: 8 additions & 0 deletions
8
...are/app/xquareinfra/domain/container/adapter/dto/request/CreateGradleDockerfileRequest.kt
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,8 @@ | ||
package xquare.app.xquareinfra.domain.container.adapter.dto.request | ||
|
||
data class CreateGradleDockerfileRequest( | ||
val jdkVersion: Int, | ||
val outputDir: String, | ||
val builder: String = "gradle", | ||
val commands: List<String> = listOf(), | ||
) |
9 changes: 9 additions & 0 deletions
9
...quare/app/xquareinfra/domain/container/adapter/dto/request/CreateNodeDockerfileRequest.kt
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,9 @@ | ||
package xquare.app.xquareinfra.domain.container.adapter.dto.request | ||
|
||
data class CreateNodeDockerfileRequest( | ||
val nodeVersion: String, | ||
val buildCommands: List<String> = emptyList(), | ||
val builder: String = "node", | ||
val command: String, | ||
var port: Int? = null | ||
) |
9 changes: 9 additions & 0 deletions
9
.../xquareinfra/domain/container/adapter/dto/request/CreateNodeWithNginxDockerfileRequest.kt
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,9 @@ | ||
package xquare.app.xquareinfra.domain.container.adapter.dto.request | ||
|
||
data class CreateNodeWithNginxDockerfileRequest( | ||
val nodeVersion: Int, | ||
val commands: List<String> = emptyList(), | ||
val builder: String = "node_with_nginx", | ||
val outputDir: String, | ||
var port: Int? | ||
) |
13 changes: 13 additions & 0 deletions
13
...are/app/xquareinfra/domain/container/application/port/in/CreateGradleDockerfileUseCase.kt
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,13 @@ | ||
package xquare.app.xquareinfra.domain.container.application.port.`in` | ||
|
||
import xquare.app.xquareinfra.domain.container.adapter.dto.request.CreateGradleDockerfileRequest | ||
import xquare.app.xquareinfra.domain.container.domain.ContainerEnvironment | ||
import java.util.UUID | ||
|
||
interface CreateGradleDockerfileUseCase { | ||
fun createGradleDockerfile( | ||
deployId: UUID, | ||
containerEnvironment: ContainerEnvironment, | ||
createGradleDockerfileRequest: CreateGradleDockerfileRequest | ||
) | ||
} |
13 changes: 13 additions & 0 deletions
13
...quare/app/xquareinfra/domain/container/application/port/in/CreateNodeDockerfileUseCase.kt
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,13 @@ | ||
package xquare.app.xquareinfra.domain.container.application.port.`in` | ||
|
||
import xquare.app.xquareinfra.domain.container.adapter.dto.request.CreateNodeDockerfileRequest | ||
import xquare.app.xquareinfra.domain.container.domain.ContainerEnvironment | ||
import java.util.* | ||
|
||
interface CreateNodeDockerfileUseCase { | ||
fun createNodeDockerfile( | ||
deployId: UUID, | ||
containerEnvironment: ContainerEnvironment, | ||
createNodeDockerfileRequest: CreateNodeDockerfileRequest | ||
) | ||
} |
13 changes: 13 additions & 0 deletions
13
.../xquareinfra/domain/container/application/port/in/CreateNodeWithNginxDockerfileUseCase.kt
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,13 @@ | ||
package xquare.app.xquareinfra.domain.container.application.port.`in` | ||
|
||
import xquare.app.xquareinfra.domain.container.adapter.dto.request.CreateNodeWithNginxDockerfileRequest | ||
import xquare.app.xquareinfra.domain.container.domain.ContainerEnvironment | ||
import java.util.* | ||
|
||
interface CreateNodeWithNginxDockerfileUseCase { | ||
fun createNodeWithNginxDockerfile( | ||
deployId: UUID, | ||
containerEnvironment: ContainerEnvironment, | ||
createNodeDockerfileRequest: CreateNodeWithNginxDockerfileRequest | ||
) | ||
} |
3 changes: 1 addition & 2 deletions
3
.../xquare/app/xquareinfra/domain/container/application/port/in/SetContainerConfigUseCase.kt
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
47 changes: 47 additions & 0 deletions
47
...are/app/xquareinfra/domain/container/application/service/CreateGradleDockerfileService.kt
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,47 @@ | ||
package xquare.app.xquareinfra.domain.container.application.service | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import org.springframework.stereotype.Service | ||
import xquare.app.xquareinfra.domain.container.adapter.dto.request.CreateGradleDockerfileRequest | ||
import xquare.app.xquareinfra.domain.container.application.port.`in`.CreateGradleDockerfileUseCase | ||
import xquare.app.xquareinfra.domain.container.application.port.out.FindContainerPort | ||
import xquare.app.xquareinfra.domain.container.domain.ContainerEnvironment | ||
import xquare.app.xquareinfra.domain.deploy.application.port.out.FindDeployPort | ||
import xquare.app.xquareinfra.infrastructure.exception.BusinessLogicException | ||
import xquare.app.xquareinfra.infrastructure.feign.client.github.GithubClient | ||
import xquare.app.xquareinfra.infrastructure.feign.client.github.dto.request.DispatchEventRequest | ||
import xquare.app.xquareinfra.infrastructure.global.env.github.GithubProperties | ||
import java.util.* | ||
|
||
@Service | ||
class CreateGradleDockerfileService( | ||
private val findDeployPort: FindDeployPort, | ||
private val githubClient: GithubClient, | ||
private val findContainerPort: FindContainerPort, | ||
private val githubProperties: GithubProperties, | ||
private val objectMapper: ObjectMapper | ||
) : CreateGradleDockerfileUseCase{ | ||
override fun createGradleDockerfile( | ||
deployId: UUID, | ||
containerEnvironment: ContainerEnvironment, | ||
createGradleDockerfileRequest: CreateGradleDockerfileRequest | ||
) { | ||
val deploy = findDeployPort.findById(deployId) ?: throw BusinessLogicException.DEPLOY_NOT_FOUND | ||
val container = findContainerPort.findByDeployAndEnvironment(deploy, containerEnvironment) | ||
?: throw BusinessLogicException.CONTAINER_NOT_FOUND | ||
|
||
githubClient.dispatchWorkflow( | ||
authorization = "Bearer ${githubProperties.token}", | ||
accept = "application/vnd.github.v3+json", | ||
request = DispatchEventRequest( | ||
event_type = "write-dockerfile", | ||
client_payload = mapOf( | ||
"name" to deploy.deployName, | ||
"environment" to container.containerEnvironment.name, | ||
"template_json" to objectMapper.writeValueAsString(createGradleDockerfileRequest), | ||
"builder" to createGradleDockerfileRequest.builder | ||
) | ||
) | ||
) | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
...quare/app/xquareinfra/domain/container/application/service/CreateNodeDockerfileService.kt
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,49 @@ | ||
package xquare.app.xquareinfra.domain.container.application.service | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import org.springframework.stereotype.Service | ||
import xquare.app.xquareinfra.domain.container.adapter.dto.request.CreateNodeDockerfileRequest | ||
import xquare.app.xquareinfra.domain.container.application.port.`in`.CreateNodeDockerfileUseCase | ||
import xquare.app.xquareinfra.domain.container.application.port.out.FindContainerPort | ||
import xquare.app.xquareinfra.domain.container.domain.ContainerEnvironment | ||
import xquare.app.xquareinfra.domain.deploy.application.port.out.FindDeployPort | ||
import xquare.app.xquareinfra.infrastructure.exception.BusinessLogicException | ||
import xquare.app.xquareinfra.infrastructure.feign.client.github.GithubClient | ||
import xquare.app.xquareinfra.infrastructure.feign.client.github.dto.request.DispatchEventRequest | ||
import xquare.app.xquareinfra.infrastructure.global.env.github.GithubProperties | ||
import java.util.* | ||
|
||
@Service | ||
class CreateNodeDockerfileService( | ||
private val findDeployPort: FindDeployPort, | ||
private val githubClient: GithubClient, | ||
private val findContainerPort: FindContainerPort, | ||
private val githubProperties: GithubProperties, | ||
private val objectMapper: ObjectMapper | ||
) : CreateNodeDockerfileUseCase { | ||
override fun createNodeDockerfile( | ||
deployId: UUID, | ||
containerEnvironment: ContainerEnvironment, | ||
createNodeDockerfileRequest: CreateNodeDockerfileRequest | ||
) { | ||
val deploy = findDeployPort.findById(deployId) ?: throw BusinessLogicException.DEPLOY_NOT_FOUND | ||
val container = findContainerPort.findByDeployAndEnvironment(deploy, containerEnvironment) | ||
?: throw BusinessLogicException.CONTAINER_NOT_FOUND | ||
|
||
createNodeDockerfileRequest.port = container.containerPort | ||
|
||
githubClient.dispatchWorkflow( | ||
authorization = "Bearer ${githubProperties.token}", | ||
accept = "application/vnd.github.v3+json", | ||
request = DispatchEventRequest( | ||
event_type = "write-dockerfile", | ||
client_payload = mapOf( | ||
"name" to deploy.deployName, | ||
"environment" to container.containerEnvironment.name, | ||
"template_json" to objectMapper.writeValueAsString(createNodeDockerfileRequest), | ||
"builder" to createNodeDockerfileRequest.builder | ||
) | ||
) | ||
) | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
.../xquareinfra/domain/container/application/service/CreateNodeWithNginxDockerfileService.kt
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,51 @@ | ||
package xquare.app.xquareinfra.domain.container.application.service | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper | ||
import org.springframework.stereotype.Service | ||
import xquare.app.xquareinfra.domain.container.adapter.dto.request.CreateNodeDockerfileRequest | ||
import xquare.app.xquareinfra.domain.container.adapter.dto.request.CreateNodeWithNginxDockerfileRequest | ||
import xquare.app.xquareinfra.domain.container.application.port.`in`.CreateNodeDockerfileUseCase | ||
import xquare.app.xquareinfra.domain.container.application.port.`in`.CreateNodeWithNginxDockerfileUseCase | ||
import xquare.app.xquareinfra.domain.container.application.port.out.FindContainerPort | ||
import xquare.app.xquareinfra.domain.container.domain.ContainerEnvironment | ||
import xquare.app.xquareinfra.domain.deploy.application.port.out.FindDeployPort | ||
import xquare.app.xquareinfra.infrastructure.exception.BusinessLogicException | ||
import xquare.app.xquareinfra.infrastructure.feign.client.github.GithubClient | ||
import xquare.app.xquareinfra.infrastructure.feign.client.github.dto.request.DispatchEventRequest | ||
import xquare.app.xquareinfra.infrastructure.global.env.github.GithubProperties | ||
import java.util.* | ||
|
||
@Service | ||
class CreateNodeWithNginxDockerfileService( | ||
private val findDeployPort: FindDeployPort, | ||
private val githubClient: GithubClient, | ||
private val findContainerPort: FindContainerPort, | ||
private val githubProperties: GithubProperties, | ||
private val objectMapper: ObjectMapper | ||
) : CreateNodeWithNginxDockerfileUseCase { | ||
override fun createNodeWithNginxDockerfile( | ||
deployId: UUID, | ||
containerEnvironment: ContainerEnvironment, | ||
createNodeDockerfileRequest: CreateNodeWithNginxDockerfileRequest | ||
) { | ||
val deploy = findDeployPort.findById(deployId) ?: throw BusinessLogicException.DEPLOY_NOT_FOUND | ||
val container = findContainerPort.findByDeployAndEnvironment(deploy, containerEnvironment) | ||
?: throw BusinessLogicException.CONTAINER_NOT_FOUND | ||
|
||
createNodeDockerfileRequest.port = container.containerPort | ||
|
||
githubClient.dispatchWorkflow( | ||
authorization = "Bearer ${githubProperties.token}", | ||
accept = "application/vnd.github.v3+json", | ||
request = DispatchEventRequest( | ||
event_type = "write-dockerfile", | ||
client_payload = mapOf( | ||
"name" to deploy.deployName, | ||
"environment" to container.containerEnvironment.name, | ||
"template_json" to objectMapper.writeValueAsString(createNodeDockerfileRequest), | ||
"builder" to createNodeDockerfileRequest.builder | ||
) | ||
) | ||
) | ||
} | ||
} |