From 653f409d91a441850d6381f89a8dd390831f0d5e Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Mon, 9 Sep 2024 10:24:20 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E8=85=BE=E8=AE=AF?= =?UTF-8?q?=E4=BA=91tke=E8=AF=81=E4=B9=A6=E9=83=A8=E7=BD=B2=E6=8A=A5?= =?UTF-8?q?=E9=94=99=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://github.com/certd/certd/issues/162 --- .../plugin/deploy-to-tke-ingress/index.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/ui/certd-server/src/plugins/plugin-tencent/plugin/deploy-to-tke-ingress/index.ts b/packages/ui/certd-server/src/plugins/plugin-tencent/plugin/deploy-to-tke-ingress/index.ts index 2faf94af..935baa4a 100644 --- a/packages/ui/certd-server/src/plugins/plugin-tencent/plugin/deploy-to-tke-ingress/index.ts +++ b/packages/ui/certd-server/src/plugins/plugin-tencent/plugin/deploy-to-tke-ingress/index.ts @@ -1,5 +1,6 @@ import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, utils } from '@certd/pipeline'; import dayjs from 'dayjs'; +import { tke } from 'tencentcloud-sdk-nodejs'; @IsTaskPlugin({ name: 'DeployCertToTencentTKEIngress', @@ -89,19 +90,16 @@ export class DeployCertToTencentTKEIngressPlugin extends AbstractTaskPlugin { }) cert!: any; - TkeClient: any; K8sClient: any; async onInstance() { // const TkeClient = this.tencentcloud.tke.v20180525.Client; - const sdk = await import('tencentcloud-sdk-nodejs/tencentcloud/services/tke/v20220501/index.js'); - this.TkeClient = sdk.v20220501.Client; const k8sSdk = await import('@certd/lib-k8s'); this.K8sClient = k8sSdk.K8sClient; } async execute(): Promise { const accessProvider = await this.accessService.getById(this.accessId); - const tkeClient = this.getTkeClient(accessProvider, this.region); + const tkeClient = await this.getTkeClient(accessProvider, this.region); const kubeConfigStr = await this.getTkeKubeConfig(tkeClient, this.clusterId); this.logger.info('kubeconfig已成功获取'); @@ -127,7 +125,9 @@ export class DeployCertToTencentTKEIngressPlugin extends AbstractTaskPlugin { await this.restartIngress({ k8sClient }); } - getTkeClient(accessProvider: any, region = 'ap-guangzhou') { + async getTkeClient(accessProvider: any, region = 'ap-guangzhou') { + const sdk = await import('tencentcloud-sdk-nodejs/tencentcloud/services/tke/v20180525/index.js'); + const TkeClient = sdk.v20180525.Client; const clientConfig = { credential: { secretId: accessProvider.secretId, @@ -141,7 +141,7 @@ export class DeployCertToTencentTKEIngressPlugin extends AbstractTaskPlugin { }, }; - return new this.TkeClient(clientConfig); + return new TkeClient(clientConfig); } async getTkeKubeConfig(client: any, clusterId: string) {