feat: 腾讯云证书tke ingress

This commit is contained in:
xiaojunnuo
2021-01-02 02:47:58 +08:00
parent 43e90503ca
commit 67bff28255
20 changed files with 1852 additions and 173 deletions
@@ -16,6 +16,10 @@ export class UploadCertToAliyun extends AbstractAliyunPlugin {
name: {
label: '证书名称'
},
regionId: {
label: '大区',
value: 'cn-hangzhou'
},
accessProvider: {
label: 'Access提供者',
type: [String, Object],
@@ -41,11 +45,11 @@ export class UploadCertToAliyun extends AbstractAliyunPlugin {
})
}
async execute ({ accessProviders, cert, props, context, logger }) {
async execute ({ accessProviders, cert, props, context }) {
const { name, accessProvider } = props
const certName = name + '-' + dayjs().format('YYYYMMDD-HHmmss')
const certName = this.appendTimeSuffix(name || cert.domain)
const params = {
RegionId: 'cn-hangzhou',
RegionId: props.regionId || 'cn-hangzhou',
Name: certName,
Cert: this.format(cert.crt.toString()),
Key: this.format(cert.key.toString())
@@ -62,4 +66,33 @@ export class UploadCertToAliyun extends AbstractAliyunPlugin {
this.logger.info('证书上传成功:aliyunCertId=', ret.CertId)
context.aliyunCertId = ret.CertId
}
/**
* 没用,现在阿里云证书不允许删除
* @param accessProviders
* @param cert
* @param props
* @param context
* @returns {Promise<void>}
*/
async rollback ({ accessProviders, cert, props, context }) {
const { accessProvider } = props
const { aliyunCertId } = context
this.logger.info('准备删除阿里云证书:', aliyunCertId)
const params = {
RegionId: props.regionId || 'cn-hangzhou',
CertId: aliyunCertId
}
const requestOption = {
method: 'POST'
}
const provider = super.getAccessProvider(accessProvider, accessProviders)
const client = this.getClient(provider)
const ret = await client.request('DeleteUserCertificate', params, requestOption)
this.checkRet(ret)
this.logger.info('证书删除成功:', aliyunCertId)
delete context.aliyunCertId
}
}