From fbde35483b93855611cc6a8309d571696f573ff7 Mon Sep 17 00:00:00 2001 From: xiaojunnuo Date: Mon, 18 Jan 2021 22:28:41 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E5=8E=BB=E6=8E=89=E5=8F=AF?= =?UTF-8?q?=E9=80=89=E9=93=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/executor/src/index.js | 4 ++-- packages/plugins/src/utils/util.k8s.client.js | 20 +++++++++---------- packages/providers/src/dns-provider/dnspod.js | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/packages/executor/src/index.js b/packages/executor/src/index.js index acd617ce..b667b326 100644 --- a/packages/executor/src/index.js +++ b/packages/executor/src/index.js @@ -80,7 +80,7 @@ export class Executor { logger.info('----------------------') if (!cert.isNew) { // 如果没有更新 - if (!options.args?.forceDeploy && !options.args?.forceRedeploy) { + if (!options.args.forceDeploy && !options.args.forceRedeploy) { // 且不需要强制运行deploy logger.info('证书无更新,无需重新部署') logger.info('任务完成') @@ -178,7 +178,7 @@ export class Executor { } const taskTrace = trace.getInstance({ type: 'deploy', deployName, taskName }) const traceStatus = taskTrace.get({}) - if (traceStatus?.status === 'success' && !options?.args?.forceRedeploy) { + if (traceStatus && traceStatus.status === 'success' && !options.args.forceRedeploy) { logger.info(`----【${taskName}】已经执行完成,跳过此任务`) taskTrace.set({ value: { current: 'skip', status: 'success', remark: '已执行成功过,本次跳过' } }) return diff --git a/packages/plugins/src/utils/util.k8s.client.js b/packages/plugins/src/utils/util.k8s.client.js index 96fe8a3d..e52bed4f 100644 --- a/packages/plugins/src/utils/util.k8s.client.js +++ b/packages/plugins/src/utils/util.k8s.client.js @@ -46,7 +46,7 @@ export class K8sClient { * @returns secretsList */ async getSecret (opts) { - const namespace = opts?.namespace || 'default' + const namespace = opts.namespace || 'default' const secrets = await this.client.api.v1.namespaces(namespace).secrets.get() return secrets } @@ -57,7 +57,7 @@ export class K8sClient { * @returns {Promise<*>} */ async createSecret (opts) { - const namespace = opts?.namespace || 'default' + const namespace = opts.namespace || 'default' const created = await this.client.api.v1.namespaces(namespace).secrets.post({ body: opts.body }) @@ -66,8 +66,8 @@ export class K8sClient { } async updateSecret (opts) { - const namespace = opts?.namespace || 'default' - const secretName = opts?.secretName + const namespace = opts.namespace || 'default' + const secretName = opts.secretName if (secretName == null) { throw new Error('secretName 不能为空') } @@ -77,8 +77,8 @@ export class K8sClient { } async patchSecret (opts) { - const namespace = opts?.namespace || 'default' - const secretName = opts?.secretName + const namespace = opts.namespace || 'default' + const secretName = opts.secretName if (secretName == null) { throw new Error('secretName 不能为空') } @@ -88,8 +88,8 @@ export class K8sClient { } async getIngress (opts) { - const namespace = opts?.namespace || 'default' - const ingressName = opts?.ingressName + const namespace = opts.namespace || 'default' + const ingressName = opts.ingressName if (!ingressName) { throw new Error('ingressName 不能为空') } @@ -97,8 +97,8 @@ export class K8sClient { } async patchIngress (opts) { - const namespace = opts?.namespace || 'default' - const ingressName = opts?.ingressName + const namespace = opts.namespace || 'default' + const ingressName = opts.ingressName if (!ingressName) { throw new Error('ingressName 不能为空') } diff --git a/packages/providers/src/dns-provider/dnspod.js b/packages/providers/src/dns-provider/dnspod.js index ac5b6634..8e79462f 100644 --- a/packages/providers/src/dns-provider/dnspod.js +++ b/packages/providers/src/dns-provider/dnspod.js @@ -28,7 +28,7 @@ export class DnspodDnsProvider extends AbstractDnsProvider { _.merge(config, options) const ret = await request(config) - if (ret?.status?.code !== '1') { + if (!ret || !ret.status || ret.status.code !== '1') { throw new Error('请求失败:' + ret.status.message + ',api=' + config.url) } return ret