Store DNS record data for deployments
This commit is contained in:
parent
534871a7ae
commit
c202554002
@ -60,7 +60,7 @@ export class Database {
|
|||||||
// Hotfix for updating old DB data
|
// Hotfix for updating old DB data
|
||||||
if (organizations[0].slug === 'snowball-tools-1') {
|
if (organizations[0].slug === 'snowball-tools-1') {
|
||||||
const [orgEntity] = await getEntities(path.resolve(__dirname, ORGANIZATION_DATA_PATH));
|
const [orgEntity] = await getEntities(path.resolve(__dirname, ORGANIZATION_DATA_PATH));
|
||||||
|
|
||||||
await this.updateOrganization(
|
await this.updateOrganization(
|
||||||
organizations[0].id,
|
organizations[0].id,
|
||||||
{
|
{
|
||||||
|
@ -14,7 +14,7 @@ import { Project } from './Project';
|
|||||||
import { Domain } from './Domain';
|
import { Domain } from './Domain';
|
||||||
import { User } from './User';
|
import { User } from './User';
|
||||||
import { Deployer } from './Deployer';
|
import { Deployer } from './Deployer';
|
||||||
import { AppDeploymentRecordAttributes, AppDeploymentRemovalRecordAttributes } from '../types';
|
import { AppDeploymentRecordAttributes, AppDeploymentRemovalRecordAttributes, DNSRecordAttributes } from '../types';
|
||||||
|
|
||||||
export enum Environment {
|
export enum Environment {
|
||||||
Production = 'Production',
|
Production = 'Production',
|
||||||
@ -126,6 +126,9 @@ export class Deployment {
|
|||||||
@Column('simple-json', { nullable: true })
|
@Column('simple-json', { nullable: true })
|
||||||
applicationDeploymentRemovalRecordData!: AppDeploymentRemovalRecordAttributes | null;
|
applicationDeploymentRemovalRecordData!: AppDeploymentRemovalRecordAttributes | null;
|
||||||
|
|
||||||
|
@Column('simple-json', { nullable: true })
|
||||||
|
dnsRecordData!: DNSRecordAttributes | null;
|
||||||
|
|
||||||
@ManyToOne(() => Deployer)
|
@ManyToOne(() => Deployer)
|
||||||
@JoinColumn({ name: 'deployerLrn' })
|
@JoinColumn({ name: 'deployerLrn' })
|
||||||
deployer!: Deployer;
|
deployer!: Deployer;
|
||||||
|
@ -16,7 +16,7 @@ import {
|
|||||||
ApplicationDeploymentRequest,
|
ApplicationDeploymentRequest,
|
||||||
ApplicationDeploymentRemovalRequest
|
ApplicationDeploymentRemovalRequest
|
||||||
} from './entity/Deployment';
|
} from './entity/Deployment';
|
||||||
import { AppDeploymentRecord, AppDeploymentRemovalRecord, AuctionParams, DeployerRecord } from './types';
|
import { AppDeploymentRecord, AppDeploymentRemovalRecord, AuctionParams, DeployerRecord, DNSRecordAttributes } from './types';
|
||||||
import { getConfig, getRepoDetails, registryTransactionWithRetry, sleep } from './utils';
|
import { getConfig, getRepoDetails, registryTransactionWithRetry, sleep } from './utils';
|
||||||
|
|
||||||
const log = debug('snowball:registry');
|
const log = debug('snowball:registry');
|
||||||
@ -27,7 +27,8 @@ const APP_DEPLOYMENT_REQUEST_TYPE = 'ApplicationDeploymentRequest';
|
|||||||
const APP_DEPLOYMENT_REMOVAL_REQUEST_TYPE = 'ApplicationDeploymentRemovalRequest';
|
const APP_DEPLOYMENT_REMOVAL_REQUEST_TYPE = 'ApplicationDeploymentRemovalRequest';
|
||||||
const APP_DEPLOYMENT_RECORD_TYPE = 'ApplicationDeploymentRecord';
|
const APP_DEPLOYMENT_RECORD_TYPE = 'ApplicationDeploymentRecord';
|
||||||
const APP_DEPLOYMENT_REMOVAL_RECORD_TYPE = 'ApplicationDeploymentRemovalRecord';
|
const APP_DEPLOYMENT_REMOVAL_RECORD_TYPE = 'ApplicationDeploymentRemovalRecord';
|
||||||
const WEBAPP_DEPLOYER_RECORD_TYPE = 'WebappDeployer'
|
const WEBAPP_DEPLOYER_RECORD_TYPE = 'WebappDeployer';
|
||||||
|
const DNS_RECORD_TYPE = 'DnsRecord';
|
||||||
const SLEEP_DURATION = 1000;
|
const SLEEP_DURATION = 1000;
|
||||||
|
|
||||||
// TODO: Move registry code to registry-sdk/watcher-ts
|
// TODO: Move registry code to registry-sdk/watcher-ts
|
||||||
@ -442,6 +443,19 @@ export class Registry {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Fetch deployment DNS Records by filter
|
||||||
|
*/
|
||||||
|
async getDNSRecordsByFilter(filter: { [key: string]: any }): Promise<DNSRecordAttributes[]> {
|
||||||
|
return this.registry.queryRecords(
|
||||||
|
{
|
||||||
|
type: DNS_RECORD_TYPE,
|
||||||
|
...filter
|
||||||
|
},
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
async createApplicationDeploymentRemovalRequest(data: {
|
async createApplicationDeploymentRemovalRequest(data: {
|
||||||
deploymentId: string;
|
deploymentId: string;
|
||||||
deployerLrn: string;
|
deployerLrn: string;
|
||||||
|
@ -22,6 +22,7 @@ import {
|
|||||||
AppDeploymentRemovalRecord,
|
AppDeploymentRemovalRecord,
|
||||||
AuctionParams,
|
AuctionParams,
|
||||||
DeployerRecord,
|
DeployerRecord,
|
||||||
|
DNSRecordAttributes,
|
||||||
EnvironmentVariables,
|
EnvironmentVariables,
|
||||||
GitPushEventPayload,
|
GitPushEventPayload,
|
||||||
} from './types';
|
} from './types';
|
||||||
@ -200,11 +201,24 @@ export class Service {
|
|||||||
log(`Project ${deployment.projectId} not found`);
|
log(`Project ${deployment.projectId} not found`);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
|
const dnsRecords = await this.laconicRegistry.getDNSRecordsByFilter({
|
||||||
|
request: deployment.applicationDeploymentRequestId
|
||||||
|
})
|
||||||
|
|
||||||
|
const dnsRecordData: DNSRecordAttributes = {
|
||||||
|
name: dnsRecords[0].name,
|
||||||
|
request: dnsRecords[0].request,
|
||||||
|
resourceType: dnsRecords[0].resourceType,
|
||||||
|
value: dnsRecords[0].value,
|
||||||
|
version: dnsRecords[0].version,
|
||||||
|
}
|
||||||
|
|
||||||
deployment.applicationDeploymentRecordId = record.id;
|
deployment.applicationDeploymentRecordId = record.id;
|
||||||
deployment.applicationDeploymentRecordData = record.attributes;
|
deployment.applicationDeploymentRecordData = record.attributes;
|
||||||
deployment.url = record.attributes.url;
|
deployment.url = record.attributes.url;
|
||||||
deployment.status = DeploymentStatus.Ready;
|
deployment.status = DeploymentStatus.Ready;
|
||||||
deployment.isCurrent = deployment.environment === Environment.Production;
|
deployment.isCurrent = deployment.environment === Environment.Production;
|
||||||
|
deployment.dnsRecordData = dnsRecordData;
|
||||||
|
|
||||||
await this.db.updateDeploymentById(deployment.id, deployment);
|
await this.db.updateDeploymentById(deployment.id, deployment);
|
||||||
|
|
||||||
|
@ -40,6 +40,14 @@ export interface AppDeploymentRecordAttributes {
|
|||||||
version: string;
|
version: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DNSRecordAttributes {
|
||||||
|
name: string;
|
||||||
|
value: string;
|
||||||
|
request: string;
|
||||||
|
resourceType: string;
|
||||||
|
version: string;
|
||||||
|
}
|
||||||
|
|
||||||
export interface AppDeploymentRemovalRecordAttributes {
|
export interface AppDeploymentRemovalRecordAttributes {
|
||||||
deployment: string;
|
deployment: string;
|
||||||
request: string;
|
request: string;
|
||||||
|
Loading…
Reference in New Issue
Block a user