Update method name to get record by Id
All checks were successful
Lint / lint (20.x) (pull_request) Successful in 4m40s
All checks were successful
Lint / lint (20.x) (pull_request) Successful in 4m40s
This commit is contained in:
parent
f318a95641
commit
a17386eb68
@ -442,9 +442,9 @@ export class Registry {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetch deployment DNS record by Id
|
* Fetch record by Id
|
||||||
*/
|
*/
|
||||||
async getDNSRecordById(id: string): Promise<DNSRecord[]> {
|
async getRecordById(id: string): Promise<any[]> {
|
||||||
return this.registry.getRecordsByIds([id]);
|
return this.registry.getRecordsByIds([id]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import {
|
|||||||
AppDeploymentRemovalRecord,
|
AppDeploymentRemovalRecord,
|
||||||
AuctionParams,
|
AuctionParams,
|
||||||
DeployerRecord,
|
DeployerRecord,
|
||||||
|
DNSRecord,
|
||||||
DNSRecordAttributes,
|
DNSRecordAttributes,
|
||||||
EnvironmentVariables,
|
EnvironmentVariables,
|
||||||
GitPushEventPayload,
|
GitPushEventPayload,
|
||||||
@ -200,61 +201,61 @@ export class Service {
|
|||||||
if (!deployment.project) {
|
if (!deployment.project) {
|
||||||
log(`Project ${deployment.projectId} not found`);
|
log(`Project ${deployment.projectId} not found`);
|
||||||
return;
|
return;
|
||||||
} else {
|
}
|
||||||
const dnsRecord = (await this.laconicRegistry.getDNSRecordById(record.attributes.dns))[0];
|
|
||||||
|
|
||||||
const dnsRecordData: DNSRecordAttributes = {
|
const dnsRecord: DNSRecord = (await this.laconicRegistry.getRecordById(record.attributes.dns))[0];
|
||||||
name: dnsRecord.attributes.name,
|
|
||||||
request: dnsRecord.attributes.request,
|
|
||||||
resourceType: dnsRecord.attributes.resourceType,
|
|
||||||
value: dnsRecord.attributes.value,
|
|
||||||
version: dnsRecord.attributes.version,
|
|
||||||
}
|
|
||||||
|
|
||||||
deployment.applicationDeploymentRecordId = record.id;
|
const dnsRecordData: DNSRecordAttributes = {
|
||||||
deployment.applicationDeploymentRecordData = record.attributes;
|
name: dnsRecord.attributes.name,
|
||||||
deployment.url = record.attributes.url;
|
request: dnsRecord.attributes.request,
|
||||||
deployment.status = DeploymentStatus.Ready;
|
resourceType: dnsRecord.attributes.resourceType,
|
||||||
deployment.isCurrent = deployment.environment === Environment.Production;
|
value: dnsRecord.attributes.value,
|
||||||
deployment.dnsRecordData = dnsRecordData;
|
version: dnsRecord.attributes.version,
|
||||||
|
}
|
||||||
|
|
||||||
if (deployment.isDNS) {
|
deployment.applicationDeploymentRecordId = record.id;
|
||||||
// Delete previous DNS deployment
|
deployment.applicationDeploymentRecordData = record.attributes;
|
||||||
const oldDNSDeployment = await this.db.getDeployment({
|
deployment.url = record.attributes.url;
|
||||||
where: {
|
deployment.status = DeploymentStatus.Ready;
|
||||||
projectId: deployment.project.id,
|
deployment.isCurrent = deployment.environment === Environment.Production;
|
||||||
deployer: deployment.deployer,
|
deployment.dnsRecordData = dnsRecordData;
|
||||||
isDNS: true,
|
|
||||||
isCurrent: true,
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (oldDNSDeployment) {
|
if (deployment.isDNS) {
|
||||||
await this.db.deleteDeploymentById(oldDNSDeployment.id);
|
// Delete previous DNS deployment
|
||||||
if (oldDNSDeployment.domain) {
|
const oldDNSDeployment = await this.db.getDeployment({
|
||||||
await this.db.updateDeploymentById(deployment.id, { domain: oldDNSDeployment.domain })
|
where: {
|
||||||
}
|
projectId: deployment.project.id,
|
||||||
|
deployer: deployment.deployer,
|
||||||
|
isDNS: true,
|
||||||
|
isCurrent: true,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
if (oldDNSDeployment) {
|
||||||
|
await this.db.deleteDeploymentById(oldDNSDeployment.id);
|
||||||
|
if (oldDNSDeployment.domain) {
|
||||||
|
await this.db.updateDeploymentById(deployment.id, { domain: oldDNSDeployment.domain })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await this.db.updateDeploymentById(deployment.id, deployment);
|
|
||||||
|
|
||||||
// Release deployer funds on successful deployment
|
|
||||||
if (!deployment.project.fundsReleased) {
|
|
||||||
const fundsReleased = await this.releaseDeployerFundsByProjectId(deployment.projectId);
|
|
||||||
|
|
||||||
// Return remaining amount to owner
|
|
||||||
await this.returnUserFundsByProjectId(deployment.projectId, true);
|
|
||||||
|
|
||||||
await this.db.updateProjectById(deployment.projectId, {
|
|
||||||
fundsReleased,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
log(
|
|
||||||
`Updated deployment ${deployment.id} with URL ${record.attributes.url}`,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
await this.db.updateDeploymentById(deployment.id, deployment);
|
||||||
|
|
||||||
|
// Release deployer funds on successful deployment
|
||||||
|
if (!deployment.project.fundsReleased) {
|
||||||
|
const fundsReleased = await this.releaseDeployerFundsByProjectId(deployment.projectId);
|
||||||
|
|
||||||
|
// Return remaining amount to owner
|
||||||
|
await this.returnUserFundsByProjectId(deployment.projectId, true);
|
||||||
|
|
||||||
|
await this.db.updateProjectById(deployment.projectId, {
|
||||||
|
fundsReleased,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
log(
|
||||||
|
`Updated deployment ${deployment.id} with URL ${record.attributes.url}`,
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
await Promise.all(deploymentUpdatePromises);
|
await Promise.all(deploymentUpdatePromises);
|
||||||
|
Loading…
Reference in New Issue
Block a user