Update rollback flow to handle multiple custom domains
This commit is contained in:
parent
5c9437bf1a
commit
4476de6faf
@ -756,24 +756,7 @@ export class Service {
|
||||
true,
|
||||
);
|
||||
|
||||
let dns;
|
||||
// If a custom domain is present then use that as the DNS in the deployment request
|
||||
// Only deployers with version > 1 support multiple custom domains
|
||||
if (deployer!.version && Number(deployer!.version) >= 1) {
|
||||
const customDomains = await this.db.getDomainsByProjectId(
|
||||
data.project.id!,
|
||||
);
|
||||
|
||||
dns =
|
||||
customDomains.length > 0
|
||||
? customDomains.map((d) => d.name).join(',')
|
||||
: `${canonicalDeployment.project.name}`;
|
||||
} else {
|
||||
const domain = await this.db.getOldestDomainByProjectId(
|
||||
canonicalDeployment.project.id,
|
||||
);
|
||||
dns = domain?.name ?? `${canonicalDeployment.project.name}`;
|
||||
}
|
||||
const dns = await this.getDnsForDeployerByProjectId(data.project.id!, deployer!.version, canonicalDeployment.project.name)
|
||||
|
||||
// On deleting deployment later, project canonical deployment is also deleted
|
||||
// So publish project canonical deployment first so that ApplicationDeploymentRecord for the same is available when deleting deployment later
|
||||
@ -1349,13 +1332,9 @@ export class Service {
|
||||
const applicationDeploymentRequestData =
|
||||
newCurrentDeployment.applicationDeploymentRequestData;
|
||||
|
||||
const customDomains = await this.db.getDomainsByProjectId(projectId);
|
||||
const dns = await this.getDnsForDeployerByProjectId(projectId, newCurrentDeployment.deployer!.version, newCurrentDeployment.project.name)
|
||||
|
||||
if (customDomains.length > 0 && applicationDeploymentRequestData) {
|
||||
applicationDeploymentRequestData.dns = customDomains
|
||||
.map((d) => d.name)
|
||||
.join(',');
|
||||
}
|
||||
applicationDeploymentRequestData!.dns = dns
|
||||
|
||||
// Create a canonical deployment for the new current deployment
|
||||
const canonicalDeployment = await this.createDeploymentFromData(
|
||||
@ -1764,4 +1743,27 @@ export class Service {
|
||||
|
||||
return amount === amountSent && sender === senderAddress && recipient === recipientAddress;
|
||||
}
|
||||
|
||||
async getDnsForDeployerByProjectId(projectId: string, deployerVersion: string | undefined | null, projectName: string): Promise<string> {
|
||||
let dns;
|
||||
// If a custom domain is present then use that as the DNS in the deployment request
|
||||
// Only deployers with version > 1 support multiple custom domains
|
||||
if (deployerVersion && Number(deployerVersion) >= 1) {
|
||||
const customDomains = await this.db.getDomainsByProjectId(
|
||||
projectId,
|
||||
);
|
||||
|
||||
dns =
|
||||
customDomains.length > 0
|
||||
? customDomains.map((d) => d.name).join(',')
|
||||
: `${projectName}`;
|
||||
} else {
|
||||
const domain = await this.db.getOldestDomainByProjectId(
|
||||
projectId
|
||||
);
|
||||
dns = domain?.name ?? `${projectName}`;
|
||||
}
|
||||
|
||||
return dns;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user