Skip to content

Commit

Permalink
fix: cluster generate template func
Browse files Browse the repository at this point in the history
  • Loading branch information
kidneyweakx committed Mar 18, 2024
1 parent 40008ed commit 1709ea3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 10 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion src/quorum/instance/bdkFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,12 @@ export default class BdkFile {
}
}

public getGoQuorumGensisChartPath (): string {
public createYaml (name: string, yaml: string) {
fs.mkdirSync(`${this.helmPath}/kubernetes`, { recursive: true })
fs.writeFileSync(`${this.helmPath}/kubernetes/${name}.yaml`, yaml)
}

public getGoQuorumGenesisChartPath (): string {
this.checkHelmChartPath()
return `${this.helmPath}/goquorum-genesis`
}
Expand Down
32 changes: 26 additions & 6 deletions src/quorum/service/cluster.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class Cluster extends AbstractService {
// custom namespace
spinner.start('Helm install genesis chart')
const genesisOutput = await k8s.install({
helmChart: this.bdkFile.getGoQuorumGensisChartPath(),
helmChart: this.bdkFile.getGoQuorumGenesisChartPath(),
name: 'genesis',
namespace: 'quorum',
values: this.bdkFile.getGenesisChartPath(),
Expand Down Expand Up @@ -100,12 +100,32 @@ export default class Cluster extends AbstractService {

if (clusterGenerateConfig.chartPackageModeEnabled) {
const k8s = new KubernetesInstance(this.config, this.infra, this.kubernetesInfra)
await k8s.template({
helmChart: this.bdkFile.getGoQuorumGensisChartPath(),
const genesisOutput = await k8s.template({
helmChart: this.bdkFile.getGoQuorumGenesisChartPath(),
name: 'genesis',
namespace: 'quorum',
values: this.bdkFile.getGenesisChartPath(),
})
}) as DockerResultType
this.bdkFile.createYaml('genesis', genesisOutput.stdout)

for (let i = 0; i < validatorNumber; i += 1) {
const validatorOutput = await k8s.template({
helmChart: this.bdkFile.getGoQuorumNodeChartPath(),
name: `validator-${i + 1}`,
namespace: 'quorum',
values: this.bdkFile.getValidatorChartPath(i),
}) as DockerResultType
this.bdkFile.createYaml(`validator-${i + 1}`, validatorOutput.stdout)
}
for (let i = 0; i < memberNumber; i += 1) {
const memberOutput = await k8s.template({
helmChart: this.bdkFile.getGoQuorumNodeChartPath(),
name: `member-${i + 1}`,
namespace: 'quorum',
values: this.bdkFile.getMemberChartPath(i),
}) as DockerResultType
this.bdkFile.createYaml(`member-${i + 1}`, memberOutput.stdout)
}
}
this.exportChartTar()
}
Expand All @@ -116,9 +136,9 @@ export default class Cluster extends AbstractService {
public async delete (): Promise<void> {
const k8s = new KubernetesInstance(this.config, this.infra, this.kubernetesInfra)
const releases = await this.getAllHelmRelease()
releases.forEach(async (release: string) => {
await Promise.all(releases.map(async (release: string) => {
await k8s.delete({ name: release, namespace: 'quorum' })
})
}))
}

private async getAllHelmRelease () {
Expand Down

0 comments on commit 1709ea3

Please sign in to comment.