Update flow for deleting deployments
This commit is contained in:
parent
5be10b6b0a
commit
6dcee29487
@ -1222,37 +1222,28 @@ export class Service {
|
||||
},
|
||||
});
|
||||
|
||||
// Compare deployer in DNS while deleting
|
||||
|
||||
if (deployment && deployment.applicationDeploymentRecordId) {
|
||||
// If deployment is current, remove deployment for project subdomain as well
|
||||
if (deployment.isCurrent) {
|
||||
const currentDeploymentURL = `https://${(deployment.project.name).toLowerCase()}.${deployment.deployer.baseDomain}`;
|
||||
const dnsDeployment = await this.db.getDeployment({
|
||||
where: {
|
||||
projectId: deployment.project.id,
|
||||
deployer: deployment.deployer,
|
||||
isDNS: true
|
||||
}
|
||||
})
|
||||
|
||||
// TODO: Store the latest DNS deployment record
|
||||
const deploymentRecords =
|
||||
await this.laconicRegistry.getDeploymentRecordsByFilter({
|
||||
application: deployment.applicationRecordId,
|
||||
url: currentDeploymentURL,
|
||||
});
|
||||
|
||||
if (!deploymentRecords.length) {
|
||||
log(
|
||||
`No ApplicationDeploymentRecord found for URL ${currentDeploymentURL} and ApplicationDeploymentRecord id ${deployment.applicationDeploymentRecordId}`,
|
||||
);
|
||||
if (!dnsDeployment) {
|
||||
log(`DNS deployment for deployment with id ${deployment.id} not found`);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Multiple records are fetched, take the latest record
|
||||
const latestRecord = deploymentRecords
|
||||
.sort((a, b) => new Date(b.createTime).getTime() - new Date(a.createTime).getTime())[0];
|
||||
|
||||
await this.laconicRegistry.createApplicationDeploymentRemovalRequest({
|
||||
deploymentId: latestRecord.id,
|
||||
deployerLrn: deployment.deployer.deployerLrn,
|
||||
auctionId: deployment.project.auctionId,
|
||||
payment: deployment.project.txHash
|
||||
deploymentId: dnsDeployment.id,
|
||||
deployerLrn: dnsDeployment.deployer.deployerLrn,
|
||||
auctionId: dnsDeployment.project.auctionId,
|
||||
payment: dnsDeployment.project.txHash
|
||||
});
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user