Fix DNS records data not getting stored in the DB
This commit is contained in:
parent
624f36155a
commit
9784eb4f4a
@ -16,7 +16,7 @@ import {
|
|||||||
ApplicationDeploymentRequest,
|
ApplicationDeploymentRequest,
|
||||||
ApplicationDeploymentRemovalRequest
|
ApplicationDeploymentRemovalRequest
|
||||||
} from './entity/Deployment';
|
} from './entity/Deployment';
|
||||||
import { AppDeploymentRecord, AppDeploymentRemovalRecord, AuctionParams, DeployerRecord, DNSRecordAttributes } from './types';
|
import { AppDeploymentRecord, AppDeploymentRemovalRecord, AuctionParams, DeployerRecord, DNSRecord, 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');
|
||||||
@ -446,7 +446,7 @@ export class Registry {
|
|||||||
/**
|
/**
|
||||||
* Fetch deployment DNS Records by filter
|
* Fetch deployment DNS Records by filter
|
||||||
*/
|
*/
|
||||||
async getDNSRecordsByFilter(filter: { [key: string]: any }): Promise<DNSRecordAttributes[]> {
|
async getDNSRecordsByFilter(filter: { [key: string]: any }): Promise<DNSRecord[]> {
|
||||||
return this.registry.queryRecords(
|
return this.registry.queryRecords(
|
||||||
{
|
{
|
||||||
type: DNS_RECORD_TYPE,
|
type: DNS_RECORD_TYPE,
|
||||||
|
@ -206,11 +206,11 @@ export class Service {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const dnsRecordData: DNSRecordAttributes = {
|
const dnsRecordData: DNSRecordAttributes = {
|
||||||
name: dnsRecords[0].name,
|
name: dnsRecords[0].attributes.name,
|
||||||
request: dnsRecords[0].request,
|
request: dnsRecords[0].attributes.request,
|
||||||
resourceType: dnsRecords[0].resourceType,
|
resourceType: dnsRecords[0].attributes.resourceType,
|
||||||
value: dnsRecords[0].value,
|
value: dnsRecords[0].attributes.value,
|
||||||
version: dnsRecords[0].version,
|
version: dnsRecords[0].attributes.version,
|
||||||
}
|
}
|
||||||
|
|
||||||
deployment.applicationDeploymentRecordId = record.id;
|
deployment.applicationDeploymentRecordId = record.id;
|
||||||
@ -665,11 +665,7 @@ export class Service {
|
|||||||
const environmentVariablesObj = await this.getEnvVariables(data.project!.id!);
|
const environmentVariablesObj = await this.getEnvVariables(data.project!.id!);
|
||||||
|
|
||||||
// If a custom domain is present then use that as the DNS in the deployment request
|
// If a custom domain is present then use that as the DNS in the deployment request
|
||||||
const domain = await this.db.getOldestDomainByProjectId(data.projectId!);
|
const domain = await this.db.getOldestDomainByProjectId(data.project!.id!);
|
||||||
let dns: string | undefined = undefined;
|
|
||||||
if (domain) {
|
|
||||||
dns = domain[0].name;
|
|
||||||
}
|
|
||||||
|
|
||||||
// To set project DNS
|
// To set project DNS
|
||||||
if (data.environment === Environment.Production) {
|
if (data.environment === Environment.Production) {
|
||||||
@ -680,7 +676,7 @@ export class Service {
|
|||||||
appName: repo,
|
appName: repo,
|
||||||
repository: repoUrl,
|
repository: repoUrl,
|
||||||
environmentVariables: environmentVariablesObj,
|
environmentVariables: environmentVariablesObj,
|
||||||
dns: `${newDeployment.project.name}`,
|
dns: domain?.[0]?.name ?? `${newDeployment.project.name}`,
|
||||||
lrn: deployer!.deployerLrn!,
|
lrn: deployer!.deployerLrn!,
|
||||||
apiUrl: deployer!.deployerApiUrl!,
|
apiUrl: deployer!.deployerApiUrl!,
|
||||||
payment: data.project.txHash,
|
payment: data.project.txHash,
|
||||||
@ -698,7 +694,7 @@ export class Service {
|
|||||||
lrn: deployer!.deployerLrn!,
|
lrn: deployer!.deployerLrn!,
|
||||||
apiUrl: deployer!.deployerApiUrl!,
|
apiUrl: deployer!.deployerApiUrl!,
|
||||||
environmentVariables: environmentVariablesObj,
|
environmentVariables: environmentVariablesObj,
|
||||||
dns: dns || `${newDeployment.project.name}-${newDeployment.id}`,
|
dns: `${newDeployment.project.name}-${newDeployment.id}`,
|
||||||
payment: data.project.txHash,
|
payment: data.project.txHash,
|
||||||
auctionId: data.project.auctionId,
|
auctionId: data.project.auctionId,
|
||||||
requesterAddress: address,
|
requesterAddress: address,
|
||||||
|
@ -72,6 +72,10 @@ export interface AppDeploymentRemovalRecord extends RegistryRecord {
|
|||||||
attributes: AppDeploymentRemovalRecordAttributes;
|
attributes: AppDeploymentRemovalRecordAttributes;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DNSRecord extends RegistryRecord {
|
||||||
|
attributes: DNSRecordAttributes
|
||||||
|
}
|
||||||
|
|
||||||
export interface AddProjectFromTemplateInput {
|
export interface AddProjectFromTemplateInput {
|
||||||
templateOwner: string;
|
templateOwner: string;
|
||||||
templateRepo: string;
|
templateRepo: string;
|
||||||
|
@ -100,6 +100,10 @@ const DomainCard = ({
|
|||||||
|
|
||||||
const dnsData = await client.getLatestDNSDataByProjectId(id);
|
const dnsData = await client.getLatestDNSDataByProjectId(id);
|
||||||
|
|
||||||
|
if (!dnsData || !dnsData.value) {
|
||||||
|
setIPAddress('Not Configured');
|
||||||
|
}
|
||||||
|
|
||||||
setIPAddress(dnsData.value);
|
setIPAddress(dnsData.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -74,9 +74,13 @@ const Config = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dnsData = await client.getLatestDNSDataByProjectId(id);
|
const dnsData = await client.getLatestDNSDataByProjectId(id);
|
||||||
|
|
||||||
setIPAddress(dnsData.value);
|
setIPAddress(dnsData.value);
|
||||||
|
|
||||||
|
if (!dnsData || !dnsData.value) {
|
||||||
|
setIPAddress("Not Configured")
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchDNSData();
|
fetchDNSData();
|
||||||
|
@ -462,6 +462,6 @@ export class GQLClient {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
return data.dnsRecordData;
|
return data.getLatestDNSDataByProjectId;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -346,7 +346,7 @@ query ($txHash: String!, $amount: String!, $senderAddress: String!) {
|
|||||||
|
|
||||||
export const getLatestDNSDataByProjectId = gql`
|
export const getLatestDNSDataByProjectId = gql`
|
||||||
query($projectId: String!) {
|
query($projectId: String!) {
|
||||||
dnsRecordData(projectId: $projectId) {
|
getLatestDNSDataByProjectId(projectId: $projectId) {
|
||||||
name
|
name
|
||||||
value
|
value
|
||||||
request
|
request
|
||||||
|
Loading…
Reference in New Issue
Block a user