Add script for publishing ApplicationDeploymentRemovalRecord record
This commit is contained in:
parent
f290b5c0b5
commit
b53e12b94b
@ -41,6 +41,7 @@
|
|||||||
"lint": "tsc --noEmit",
|
"lint": "tsc --noEmit",
|
||||||
"test:registry:init": "DEBUG=snowball:* ts-node ./test/initialize-registry.ts",
|
"test:registry:init": "DEBUG=snowball:* ts-node ./test/initialize-registry.ts",
|
||||||
"test:registry:publish-deploy-records": "DEBUG=snowball:* ts-node ./test/publish-deploy-records.ts",
|
"test:registry:publish-deploy-records": "DEBUG=snowball:* ts-node ./test/publish-deploy-records.ts",
|
||||||
|
"test:registry:publish-deployment-removal-records": "DEBUG=snowball:* ts-node ./test/publish-deployment-removal-records.ts",
|
||||||
"test:db:load:fixtures": "DEBUG=snowball:* ts-node ./test/initialize-db.ts",
|
"test:db:load:fixtures": "DEBUG=snowball:* ts-node ./test/initialize-db.ts",
|
||||||
"test:db:delete": "DEBUG=snowball:* ts-node ./test/delete-db.ts"
|
"test:db:delete": "DEBUG=snowball:* ts-node ./test/delete-db.ts"
|
||||||
},
|
},
|
||||||
|
@ -6,7 +6,8 @@ import {
|
|||||||
UpdateDateColumn,
|
UpdateDateColumn,
|
||||||
ManyToOne,
|
ManyToOne,
|
||||||
OneToOne,
|
OneToOne,
|
||||||
JoinColumn
|
JoinColumn,
|
||||||
|
DeleteDateColumn
|
||||||
} from 'typeorm';
|
} from 'typeorm';
|
||||||
|
|
||||||
import { Project } from './Project';
|
import { Project } from './Project';
|
||||||
@ -146,4 +147,7 @@ export class Deployment {
|
|||||||
|
|
||||||
@UpdateDateColumn()
|
@UpdateDateColumn()
|
||||||
updatedAt!: Date;
|
updatedAt!: Date;
|
||||||
|
|
||||||
|
@DeleteDateColumn()
|
||||||
|
deletedAt!: Date | null;
|
||||||
}
|
}
|
||||||
|
@ -19,6 +19,7 @@ enum DeploymentStatus {
|
|||||||
Building
|
Building
|
||||||
Ready
|
Ready
|
||||||
Error
|
Error
|
||||||
|
Deleting
|
||||||
}
|
}
|
||||||
|
|
||||||
enum DomainStatus {
|
enum DomainStatus {
|
||||||
|
@ -52,6 +52,8 @@ export class Service {
|
|||||||
init (): void {
|
init (): void {
|
||||||
// Start check for ApplicationDeploymentRecords asynchronously
|
// Start check for ApplicationDeploymentRecords asynchronously
|
||||||
this.checkDeployRecordsAndUpdate();
|
this.checkDeployRecordsAndUpdate();
|
||||||
|
// Start check for ApplicationDeploymentRemovalRecords asynchronously
|
||||||
|
this.checkDeploymentRemovalRecordsAndUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
67
packages/backend/test/publish-deployment-removal-records.ts
Normal file
67
packages/backend/test/publish-deployment-removal-records.ts
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
import debug from 'debug';
|
||||||
|
import { DataSource } from 'typeorm';
|
||||||
|
import path from 'path';
|
||||||
|
|
||||||
|
import { Registry } from '@cerc-io/laconic-sdk';
|
||||||
|
|
||||||
|
import { Config } from '../src/config';
|
||||||
|
import { DEFAULT_CONFIG_FILE_PATH } from '../src/constants';
|
||||||
|
import { getConfig } from '../src/utils';
|
||||||
|
import { Deployment, DeploymentStatus } from '../src/entity/Deployment';
|
||||||
|
|
||||||
|
const log = debug('snowball:publish-deployment-removal-records');
|
||||||
|
|
||||||
|
async function main () {
|
||||||
|
const { registryConfig, database, misc } = await getConfig<Config>(DEFAULT_CONFIG_FILE_PATH);
|
||||||
|
|
||||||
|
const registry = new Registry(
|
||||||
|
registryConfig.gqlEndpoint,
|
||||||
|
registryConfig.restEndpoint,
|
||||||
|
registryConfig.chainId
|
||||||
|
);
|
||||||
|
|
||||||
|
const dataSource = new DataSource({
|
||||||
|
type: 'better-sqlite3',
|
||||||
|
database: database.dbPath,
|
||||||
|
synchronize: true,
|
||||||
|
entities: [path.join(__dirname, '../src/entity/*')]
|
||||||
|
});
|
||||||
|
|
||||||
|
await dataSource.initialize();
|
||||||
|
|
||||||
|
const deploymentRepository = dataSource.getRepository(Deployment);
|
||||||
|
const deployments = await deploymentRepository.find({
|
||||||
|
relations: {
|
||||||
|
project: true
|
||||||
|
},
|
||||||
|
where: {
|
||||||
|
status: DeploymentStatus.Deleting
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
for await (const deployment of deployments) {
|
||||||
|
const applicationDeploymentRemovalRecord = {
|
||||||
|
type: "ApplicationDeploymentRemovalRecord",
|
||||||
|
version: "1.0.0",
|
||||||
|
deployment: deployment.applicationDeploymentRecordId,
|
||||||
|
request: deployment.applicationDeploymentRemovalRequestId,
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = await registry.setRecord(
|
||||||
|
{
|
||||||
|
privateKey: registryConfig.privateKey,
|
||||||
|
record: applicationDeploymentRemovalRecord,
|
||||||
|
bondId: registryConfig.bondId
|
||||||
|
},
|
||||||
|
'',
|
||||||
|
registryConfig.fee
|
||||||
|
);
|
||||||
|
|
||||||
|
log('Application deployment removal record data:', applicationDeploymentRemovalRecord);
|
||||||
|
log(`Application deployment removal record published: ${result.data.id}`);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch((err) => {
|
||||||
|
log(err);
|
||||||
|
});
|
Loading…
Reference in New Issue
Block a user