mirror of
https://github.com/certd/certd.git
synced 2026-04-15 05:00:52 +08:00
feat: 自动化流程
This commit is contained in:
21
packages/plugins/test/aliyun/deploy-to-cdn.test.js
Normal file
21
packages/plugins/test/aliyun/deploy-to-cdn.test.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import pkg from 'chai'
|
||||
import { DeployCertToAliyunCDN } from '../../src/aliyun/deploy-to-cdn/index.js'
|
||||
import options from '../options.js'
|
||||
import { Certd } from '@certd/certd'
|
||||
const { expect } = pkg
|
||||
describe('DeployToAliyunCDN', function () {
|
||||
it('#execute', async function () {
|
||||
const plugin = new DeployCertToAliyunCDN()
|
||||
const certd = new Certd()
|
||||
const cert = certd.readCurrentCert('xiaojunnuo@qq.com', ['*.docmirror.cn'])
|
||||
const ret = await plugin.execute({
|
||||
accessProviders: options.accessProviders,
|
||||
cert,
|
||||
args: { domainName: 'certd-cdn-upload.docmirror.cn', certName: 'certd部署测试', certType: 'cas', accessProvider: 'aliyun' },
|
||||
context: {
|
||||
aliyunCertId: '4947435'
|
||||
}
|
||||
})
|
||||
console.log('context:', context)
|
||||
})
|
||||
})
|
||||
@@ -1,19 +1,19 @@
|
||||
import pkg from 'chai'
|
||||
import { UploadToAliyunPlugin } from '../../src/aliyun/upload-to-aliyun/index.js'
|
||||
import { UploadCertToAliyun } from '../../src/aliyun/upload-to-aliyun/index.js'
|
||||
import options from '../options.js'
|
||||
import { Certd } from '@certd/certd'
|
||||
const { expect } = pkg
|
||||
describe('PluginUploadToAliyun', function () {
|
||||
it('#execute', async function () {
|
||||
const plugin = new UploadToAliyunPlugin()
|
||||
const plugin = new UploadCertToAliyun()
|
||||
const certd = new Certd()
|
||||
const cert = certd.readCurrentCert('xiaojunnuo@qq.com', ['*.docmirror.club', 'docmirror.club'])
|
||||
const cert = certd.readCurrentCert('xiaojunnuo@qq.com', ['_.docmirror.cn'])
|
||||
const context = {}
|
||||
await plugin.execute({
|
||||
accessProviders: options.accessProviders,
|
||||
cert,
|
||||
args: { name: '上传证书到阿里云测试', provider: 'aliyun' },
|
||||
context
|
||||
context,
|
||||
args: { name: 'certd部署测试', provider: 'aliyun' }
|
||||
})
|
||||
|
||||
console.log('context:', context)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import _ from 'lodash'
|
||||
import optionsPrivate from '../../../test/options.private.mjs'
|
||||
const defaultOptions = {
|
||||
version: '1.0.0',
|
||||
accessProviders: {
|
||||
aliyun: {
|
||||
providerType: 'aliyun',
|
||||
@@ -31,55 +32,7 @@ const defaultOptions = {
|
||||
organizationUnit: 'IT Department',
|
||||
emailAddress: 'xiaojunnuo@qq.com'
|
||||
}
|
||||
},
|
||||
deploy: [
|
||||
{
|
||||
deployName: '流程1-部署到阿里云系列产品',
|
||||
tasks: [
|
||||
{
|
||||
name: '上传证书到云',
|
||||
taskType: 'uploadCertToCloud',
|
||||
certStore: 'aliyun'
|
||||
},
|
||||
{
|
||||
name: '部署证书到SLB',
|
||||
taskType: 'deployCertToAliyunSLB',
|
||||
certStore: 'aliyun'
|
||||
},
|
||||
{
|
||||
name: '部署证书到阿里云集群Ingress',
|
||||
taskType: 'deployCertToAliyunK8sIngress',
|
||||
certStore: 'aliyun'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
deployName: '流程2-部署到nginx服务器',
|
||||
tasks: [
|
||||
{
|
||||
name: '上传证书到服务器,并重启nginx',
|
||||
taskType: 'sshAndExecute',
|
||||
ssh: 'myLinux',
|
||||
upload: [
|
||||
{ from: '{certPath}', to: '/xxx/xxx/xxx.cert.pem' },
|
||||
{ from: '{keyPath}', to: '/xxx/xxx/xxx.key' }
|
||||
],
|
||||
script: 'sudo systemctl restart nginx'
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
deployName: '流程3-触发jenkins任务',
|
||||
tasks: [
|
||||
{
|
||||
name: '触发jenkins任务',
|
||||
taskType: 'sshAndExecute',
|
||||
ssh: 'myLinux',
|
||||
script: 'sudo systemctl restart nginx'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
_.merge(defaultOptions, optionsPrivate)
|
||||
|
||||
Reference in New Issue
Block a user