Update method to return webapp deployer records from registry
This commit is contained in:
parent
4bd111611d
commit
b15d998ed2
@ -1,5 +1,4 @@
|
|||||||
import { Entity, PrimaryColumn, Column, OneToMany } from 'typeorm';
|
import { Entity, PrimaryColumn, Column, OneToMany } from 'typeorm';
|
||||||
import { Deployment } from './Deployment';
|
|
||||||
|
|
||||||
@Entity()
|
@Entity()
|
||||||
export class Deployer {
|
export class Deployer {
|
||||||
|
@ -14,7 +14,7 @@ import {
|
|||||||
ApplicationDeploymentRequest,
|
ApplicationDeploymentRequest,
|
||||||
ApplicationDeploymentRemovalRequest
|
ApplicationDeploymentRemovalRequest
|
||||||
} from './entity/Deployment';
|
} from './entity/Deployment';
|
||||||
import { AppDeploymentRecord, AppDeploymentRemovalRecord, AuctionParams } from './types';
|
import { AppDeploymentRecord, AppDeploymentRemovalRecord, AuctionParams, DeployerRecord } from './types';
|
||||||
import { getConfig, getRepoDetails, sleep } from './utils';
|
import { getConfig, getRepoDetails, sleep } from './utils';
|
||||||
|
|
||||||
const log = debug('snowball:registry');
|
const log = debug('snowball:registry');
|
||||||
@ -25,6 +25,7 @@ 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 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
|
||||||
@ -116,7 +117,7 @@ export class Registry {
|
|||||||
this.registryConfig.privateKey,
|
this.registryConfig.privateKey,
|
||||||
fee
|
fee
|
||||||
);
|
);
|
||||||
|
log("Result: ", result);
|
||||||
log(`Published application record ${result.id}`);
|
log(`Published application record ${result.id}`);
|
||||||
log('Application record data:', applicationRecord);
|
log('Application record data:', applicationRecord);
|
||||||
|
|
||||||
@ -291,32 +292,33 @@ export class Registry {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async getAuctionWinningDeployers(
|
async getAuctionWinningDeployerRecords(
|
||||||
auctionId: string
|
auctionId: string
|
||||||
): Promise<string[]> {
|
): Promise<DeployerRecord[]> {
|
||||||
const records = await this.registry.getAuctionsByIds([auctionId]);
|
const records = await this.registry.getAuctionsByIds([auctionId]);
|
||||||
const auctionResult = records[0];
|
const auctionResult = records[0];
|
||||||
|
|
||||||
let deployerLrns = [];
|
let deployerRecords = [];
|
||||||
const { winnerAddresses } = auctionResult;
|
const { winnerAddresses } = auctionResult;
|
||||||
|
|
||||||
for (const auctionWinner of winnerAddresses) {
|
for (const auctionWinner of winnerAddresses) {
|
||||||
const deployerRecords = await this.registry.queryRecords(
|
const records = await this.registry.queryRecords(
|
||||||
{
|
{
|
||||||
paymentAddress: auctionWinner,
|
paymentAddress: auctionWinner,
|
||||||
|
type: WEBAPP_DEPLOYER_RECORD_TYPE,
|
||||||
},
|
},
|
||||||
true
|
true
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const record of deployerRecords) {
|
for (const record of records) {
|
||||||
if (record.names && record.names.length > 0) {
|
if (record.id) {
|
||||||
deployerLrns.push(record.names[0]);
|
deployerRecords.push(record);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return deployerLrns;
|
return deployerRecords;
|
||||||
}
|
}
|
||||||
|
|
||||||
async releaseDeployerFunds(
|
async releaseDeployerFunds(
|
||||||
|
@ -140,7 +140,6 @@ type Deployer {
|
|||||||
updatedAt: String!
|
updatedAt: String!
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
type AuthResult {
|
type AuthResult {
|
||||||
token: String!
|
token: String!
|
||||||
}
|
}
|
||||||
|
@ -308,20 +308,21 @@ export class Service {
|
|||||||
completedAuctionIds.includes(project.auctionId!)
|
completedAuctionIds.includes(project.auctionId!)
|
||||||
);
|
);
|
||||||
|
|
||||||
for (const project of projectsToBedeployed) {
|
|
||||||
const deployerLrns = await this.laconicRegistry.getAuctionWinningDeployers(project.auctionId!);
|
|
||||||
|
|
||||||
if (!deployerLrns) {
|
for (const project of projectsToBedeployed) {
|
||||||
|
const deployers = await this.laconicRegistry.getAuctionWinningDeployerRecords(project!.auctionId!);
|
||||||
|
|
||||||
|
if (!deployers) {
|
||||||
log(`No winning deployer for auction ${project!.auctionId}`);
|
log(`No winning deployer for auction ${project!.auctionId}`);
|
||||||
} else {
|
} else {
|
||||||
// Update project with deployer LRNs
|
// TODO:Update project with deployer LRNs
|
||||||
await this.db.updateProjectById(project.id!, {
|
// await this.db.updateProjectById(project.id!, {
|
||||||
deployerLrns
|
// deployers
|
||||||
});
|
// });
|
||||||
|
|
||||||
for (const deployer of deployerLrns) {
|
for (const deployer of deployers) {
|
||||||
log(`Creating deployment for deployer LRN ${deployer}`);
|
log(`Creating deployment for deployer LRN ${deployer}`);
|
||||||
await this.createDeploymentFromAuction(project, deployer);
|
await this.createDeploymentFromAuction(project, deployer.names[0]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -588,7 +589,7 @@ export class Service {
|
|||||||
domain: prodBranchDomains[0],
|
domain: prodBranchDomains[0],
|
||||||
commitHash: oldDeployment.commitHash,
|
commitHash: oldDeployment.commitHash,
|
||||||
commitMessage: oldDeployment.commitMessage,
|
commitMessage: oldDeployment.commitMessage,
|
||||||
deployer: oldDeployment.deployer
|
deployer: oldDeployment.deployer
|
||||||
});
|
});
|
||||||
|
|
||||||
return newDeployment;
|
return newDeployment;
|
||||||
|
@ -82,3 +82,20 @@ export interface EnvironmentVariables {
|
|||||||
key: string,
|
key: string,
|
||||||
value: string,
|
value: string,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface DeployerRecord {
|
||||||
|
id: string;
|
||||||
|
names: string[];
|
||||||
|
owners: string[];
|
||||||
|
bondId: string;
|
||||||
|
createTime: string;
|
||||||
|
expiryTime: string;
|
||||||
|
attributes: {
|
||||||
|
apiUrl: string;
|
||||||
|
name: string;
|
||||||
|
paymentAddress: string;
|
||||||
|
publicKey: string;
|
||||||
|
type: string;
|
||||||
|
version: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user