-
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
eb8ff2b
commit e25d800
Showing
10 changed files
with
87 additions
and
10 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
14 changes: 14 additions & 0 deletions
14
...n/xquare/app/xquareinfra/domain/container/adapter/dto/response/SimpleContainerResponse.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,14 @@ | ||
package xquare.app.xquareinfra.domain.container.adapter.dto.response | ||
|
||
import xquare.app.xquareinfra.domain.container.domain.ContainerEnvironment | ||
import xquare.app.xquareinfra.domain.container.domain.ContainerStatus | ||
import java.time.LocalDateTime | ||
|
||
data class SimpleContainerResponse( | ||
val containerName: String, | ||
val containerEnvironment: ContainerEnvironment, | ||
val containerStatus: ContainerStatus, | ||
val repository: String, | ||
val domain: String, | ||
val lastDeploy: LocalDateTime | ||
) |
8 changes: 8 additions & 0 deletions
8
...are/app/xquareinfra/domain/container/application/port/in/GetContainerByDeployIdUseCase.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.application.port.`in` | ||
|
||
import xquare.app.xquareinfra.domain.container.adapter.dto.response.SimpleContainerResponse | ||
import java.util.UUID | ||
|
||
interface GetContainerByDeployIdUseCase { | ||
fun getContainerByDeploy(deployId: UUID): List<SimpleContainerResponse> | ||
} |
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
45 changes: 45 additions & 0 deletions
45
...are/app/xquareinfra/domain/container/application/service/GetContainerByDeployIdService.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,45 @@ | ||
package xquare.app.xquareinfra.domain.container.application.service | ||
|
||
import org.springframework.stereotype.Service | ||
import xquare.app.xquareinfra.domain.container.adapter.dto.response.SimpleContainerResponse | ||
import xquare.app.xquareinfra.domain.container.application.port.`in`.GetContainerByDeployIdUseCase | ||
import xquare.app.xquareinfra.domain.container.application.port.out.FindContainerPort | ||
import xquare.app.xquareinfra.domain.container.domain.Container | ||
import xquare.app.xquareinfra.domain.container.domain.ContainerEnvironment | ||
import xquare.app.xquareinfra.domain.container.domain.ContainerStatus | ||
import xquare.app.xquareinfra.domain.deploy.application.port.out.FindDeployPort | ||
import xquare.app.xquareinfra.infrastructure.exception.BusinessLogicException | ||
import java.util.* | ||
|
||
@Service | ||
class GetContainerByDeployIdService( | ||
private val findDeployPort: FindDeployPort, | ||
private val findContainerPort: FindContainerPort | ||
): GetContainerByDeployIdUseCase { | ||
override fun getContainerByDeploy(deployId: UUID): List<SimpleContainerResponse> { | ||
val deploy = findDeployPort.findById(deployId) ?: throw BusinessLogicException.DEPLOY_NOT_FOUND | ||
val containers = findContainerPort.findAllByDeploy(deploy) | ||
|
||
return containers.map { | ||
SimpleContainerResponse( | ||
containerName = deploy.deployName, | ||
containerEnvironment = it.containerEnvironment, | ||
containerStatus = ContainerStatus.RUNNING, | ||
repository = "${deploy.organization}/${deploy.repository}", | ||
domain = generateDomain(it), | ||
lastDeploy = it.lastDeploy | ||
) | ||
} | ||
} | ||
|
||
private fun generateDomain(container: Container): String { | ||
if(container.subDomain!!.isEmpty()) { | ||
val baseDomain = when (container.containerEnvironment) { | ||
ContainerEnvironment.prod -> "prod-server.xquare.app" | ||
else -> "stag-server.xquare.app" | ||
} | ||
return "https://$baseDomain/${container.deploy.deployName}" | ||
} | ||
return container.subDomain!! | ||
} | ||
} |
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