refactor: 重构

master
xiaojunnuo 2021-02-08 14:00:28 +08:00
parent cb8c8186f1
commit 9ae414b1c6
4 changed files with 22 additions and 22 deletions

View File

@ -23,7 +23,6 @@ export class Executor {
async run (options) { async run (options) {
logger.info('------------------- Cert-D ---------------------') logger.info('------------------- Cert-D ---------------------')
try { try {
this.transferToSafetyOptions(options)
options = _.merge(createDefaultOptions(), options) options = _.merge(createDefaultOptions(), options)
return await this.doRun(options) return await this.doRun(options)
} catch (e) { } catch (e) {

View File

@ -1,8 +1,16 @@
import pkg from 'chai' import pkg from 'chai'
import { Executor } from '../src' import { Executor } from '../src/index.js'
import { createOptions } from '../../../../test/options.js' import { createOptions } from '../../../../test/options.js'
import PluginAliyun from '@certd/plugin-aliyun'
import PluginTencent from '@certd/plugin-tencent'
import PluginHost from '@certd/plugin-host'
const { expect } = pkg const { expect } = pkg
// 安装默认插件和授权提供者
PluginAliyun.install()
PluginTencent.install()
PluginHost.install()
describe('AutoDeploy', function () { describe('AutoDeploy', function () {
it('#run', async function () { it('#run', async function () {
this.timeout(120000) this.timeout(120000)

View File

@ -1,9 +1,9 @@
import _ from 'lodash-es' import _ from 'lodash-es'
import { SSHAccessProvider } from './access-providers/ssh' import { SSHAccessProvider } from './access-providers/ssh.js'
import { UploadCertToHost } from './host/upload-to-host/index.js' import { UploadCertToHost } from './plugins/upload-to-host/index.js'
import { HostShellExecute } from './host/host-shell-execute/index.js' import { HostShellExecute } from './plugins/host-shell-execute/index.js'
import { pluginRegistry, accessProviderRegistry } from '@certd/api' import { pluginRegistry, accessProviderRegistry } from '@certd/api'

View File

@ -66,7 +66,7 @@ const defaultOptions = {
props:{ props:{
domainName: 'certd-cdn-upload.docmirror.cn', domainName: 'certd-cdn-upload.docmirror.cn',
certName: 'certd部署测试(upload)', certName: 'certd部署测试(upload)',
certType: 'upload', from: 'upload',
accessProvider: 'aliyun' accessProvider: 'aliyun'
} }
} }
@ -82,29 +82,22 @@ const defaultOptions = {
disabled: true, disabled: true,
tasks: [ tasks: [
{ {
taskName: '上传证书到服务器,并重启nginx', taskName: '上传证书到服务器',
type: 'sshAndExecute', type: 'uploadCertToHost',
props:{ props:{
accessProvider: 'myLinux', accessProvider: 'aliyun-linux',
upload: [ upload: [
{ from: '{certPath}', to: '/xxx/xxx/xxx.cert.pem' }, { from: '{certPath}', to: '/xxx/xxx/xxx.cert.pem' },
{ from: '{keyPath}', to: '/xxx/xxx/xxx.key' } { from: '{keyPath}', to: '/xxx/xxx/xxx.key' }
], ]
script: 'sudo systemctl restart nginx'
} }
} },
]
},
{
deployName: '流程3-触发jenkins任务',
disabled: false,
tasks: [
{ {
taskName: '触发jenkins任务', taskName: '重启linux',
type: 'sshAndExecute', type: 'hostShellExecute',
props:{ props:{
accessProvider: 'myLinux', accessProvider: 'aliyun-linux',
script: 'sudo systemctl restart nginx' script: ['ls']
} }
} }
] ]