Skip to content

Commit

Permalink
feat :: migration to v2
Browse files Browse the repository at this point in the history
  • Loading branch information
HyunSu1768 committed Jul 28, 2024
1 parent 91beb67 commit ba6b04b
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class V1DeployWebAdapter(
private val approveDeployUseCase: ApproveDeployUseCase,
private val getAllDeployInTeamUseCase: GetAllDeployInTeamUseCase,
private val getDeployDetailsUseCase: GetDeployDetailsUseCase,
private val migrationDeployUseCase: MigrationDeployUseCase
private val migrationDeployUseCase: MigrationDeployUseCase,
private val deployMigrationToV2PipelineUseCase: DeployMigrationToV2PipelineUseCase
) {
@PostMapping
fun createDeploy(
Expand Down Expand Up @@ -52,4 +53,10 @@ class V1DeployWebAdapter(

@PostMapping("/migration")
fun migrationDeploy() = migrationDeployUseCase.migrationDeploy()

@PutMapping("/migration/v2")
fun migrateToV2(
@PathVariable("deployId", required = true)
deployId: UUID
) = deployMigrationToV2PipelineUseCase.migrationDeploy(deployId)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package xquare.app.xquareinfra.domain.deploy.application.port.`in`

import java.util.UUID

interface DeployMigrationToV2PipelineUseCase {
fun migrationDeploy(deployId: UUID)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package xquare.app.xquareinfra.domain.deploy.application.service

import org.springframework.stereotype.Service
import org.springframework.transaction.annotation.Transactional
import xquare.app.xquareinfra.domain.container.application.port.out.FindContainerPort
import xquare.app.xquareinfra.domain.deploy.application.port.`in`.DeployMigrationToV2PipelineUseCase
import xquare.app.xquareinfra.domain.deploy.application.port.out.FindDeployPort
import xquare.app.xquareinfra.infrastructure.exception.BusinessLogicException
import xquare.app.xquareinfra.infrastructure.vault.VaultUtil
import java.util.*

@Transactional
@Service
class DeployMigrationToV2PipelineService(
private val findDeployPort: FindDeployPort,
private val findContainerPort: FindContainerPort,
private val vaultUtil: VaultUtil
) : DeployMigrationToV2PipelineUseCase{
override fun migrationDeploy(deployId: UUID) {
val deploy = findDeployPort.findById(deployId) ?: throw BusinessLogicException.DEPLOY_NOT_FOUND
val containers = findContainerPort.findAllByDeploy(deploy)

containers.map {
vaultUtil.addSecret(it.environmentVariable, vaultUtil.getPath(deploy, it))
}

deploy.migrationToV2()
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package xquare.app.xquareinfra.domain.deploy.domain

import org.hibernate.annotations.ColumnDefault
import xquare.app.xquareinfra.domain.BaseUUIDEntity
import xquare.app.xquareinfra.domain.team.domain.Team
import java.util.*
Expand All @@ -18,7 +19,8 @@ class Deploy(
deployStatus: DeployStatus,
deployType: DeployType,
useMysql: Boolean,
useRedis: Boolean
useRedis: Boolean,
isV2: Boolean = false
) : BaseUUIDEntity(id) {
@Column(name = "deploy_name", nullable = false, unique = true)
var deployName: String = deployName
Expand Down Expand Up @@ -67,11 +69,20 @@ class Deploy(
var useMysql = useMysql
protected set

@Column(name = "is_v2", nullable = false)
@ColumnDefault("false")
var isV2 = isV2
protected set

fun updateSecret(secretKey: String) {
this.secretKey = secretKey
}

fun approveDeploy() {
this.deployStatus = DeployStatus.AVAILABLE
}

fun migrationToV2() {
this.isV2 = true
}
}

0 comments on commit ba6b04b

Please sign in to comment.