Compare commits
51 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
28449c348e | ||
|
|
bb9cf7b93c | ||
|
|
eb861083ad | ||
|
|
b133505086 | ||
|
|
0f0cae713a | ||
|
|
56cfce86e4 | ||
|
|
e950322232 | ||
|
|
14de21ee64 | ||
|
|
22712eae96 | ||
|
|
86d1033324 | ||
|
|
671f0142bc | ||
|
|
ab4bdc7be6 | ||
|
|
0859e60b23 | ||
|
|
e69c2d8b0c | ||
|
|
186e058f3d | ||
|
|
ed5af59040 | ||
|
|
0da312f755 | ||
|
|
dc646d9a45 | ||
|
|
109e01bb60 | ||
|
|
657fad06fb | ||
|
|
3e014c876d | ||
|
|
d14dd51359 | ||
|
|
70f876c445 | ||
|
|
9d8d51d88d | ||
|
|
57037f20cc | ||
|
|
4f2f509819 | ||
|
|
d2fad719fa | ||
|
|
6a3955a1d6 | ||
|
|
dceb33006a | ||
|
|
a096a43c56 | ||
|
|
8114a33d20 | ||
|
|
9f3adddd41 | ||
|
|
05f74ab654 | ||
|
|
0317118cd9 | ||
|
|
461de8d269 | ||
|
|
b258e92620 | ||
|
|
f6148ef1fb | ||
|
|
457da594be | ||
|
|
891a43ae67 | ||
|
|
bc65c0a786 | ||
|
|
3eeb1f77aa | ||
|
|
91be6826b9 | ||
|
|
f87eee3b9f | ||
|
|
b4e17691c4 | ||
|
|
cce372aeba | ||
|
|
b5a8a9e08a | ||
|
|
35632da284 | ||
|
|
02a9b0d16c | ||
|
|
d1809e0f7d | ||
|
|
abb4a7c0f9 | ||
|
|
cd6fa8b15c |
2
.gitignore
vendored
@@ -1,3 +1,4 @@
|
||||
./packages/core/lego
|
||||
# IntelliJ project files
|
||||
.vscode/
|
||||
node_modules/
|
||||
@@ -32,3 +33,4 @@ gen
|
||||
/pnpm-lock.yaml
|
||||
|
||||
docker/image/workspace
|
||||
/packages/core/lego
|
||||
|
||||
27
CHANGELOG.md
@@ -3,6 +3,33 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.6](https://github.com/certd/certd/compare/v1.1.5...v1.1.6) (2023-07-10)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复上传证书到腾讯云失败的bug ([e950322](https://github.com/certd/certd/commit/e950322232e19d1263b8552eefa5b0150fd7864e))
|
||||
|
||||
## [1.1.5](https://github.com/certd/certd/compare/v1.1.4...v1.1.5) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package root
|
||||
|
||||
## [1.1.4](https://github.com/certd/certd/compare/v1.1.3...v1.1.4) (2023-07-03)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 成功图标转动的问题 ([f87eee3](https://github.com/certd/certd/commit/f87eee3b9ff1ef9874e79a81fe0ed7104cb9ee8c))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* cancel task ([bc65c0a](https://github.com/certd/certd/commit/bc65c0a786360c087fe95cad93ec6a87804cc5ee))
|
||||
* flush log ([891a43a](https://github.com/certd/certd/commit/891a43ae6716ff98ed06643f7da2e35199ee195c))
|
||||
* flush logger ([91be682](https://github.com/certd/certd/commit/91be6826b902e0f302b1a6cbdb1d24e15914c18d))
|
||||
* timeout ([3eeb1f7](https://github.com/certd/certd/commit/3eeb1f77aa2922f3545f3d2067f561d95621d54f))
|
||||
|
||||
## [1.1.3](https://github.com/certd/certd/compare/v1.1.2...v1.1.3) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package root
|
||||
|
||||
## [1.1.2](https://github.com/certd/certd/compare/v1.1.1...v1.1.2) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package root
|
||||
|
||||
212
README.md
@@ -1,140 +1,108 @@
|
||||
# CertD
|
||||
|
||||
CertD 是一个帮助你全自动申请和部署SSL证书的工具。
|
||||
CertD 是一个免费全自动申请和部署SSL证书的工具。
|
||||
后缀D取自linux守护进程的命名风格,意为证书守护进程。
|
||||
|
||||
## 特性
|
||||
## 一、特性
|
||||
本项目不仅支持证书申请过程自动化,还可以自动化部署证书,让你的证书永不过期。
|
||||
|
||||
* 全自动申请证书(支持阿里云、腾讯云、华为云注册的域名)
|
||||
* 全自动部署证书(目前支持服务器上传部署、阿里云、腾讯云等)
|
||||
* 全自动部署证书(目前支持服务器上传部署、部署到阿里云、腾讯云等)
|
||||
* 支持通配符域名
|
||||
* 支持多个域名打到一个证书上
|
||||
* 邮件通知
|
||||
* 证书自动更新
|
||||
* 免费、免费、免费([阿里云单个通配符域名证书最便宜也要1800/年](https://yundun.console.aliyun.com/?p=cas#/certExtend/buy/cn-hangzhou))
|
||||
|
||||
|
||||
|
||||
## 二、在线体验
|
||||
|
||||
官方Demo地址,自助注册后体验
|
||||
|
||||
https://certd.handsfree.work/
|
||||
|
||||
> 注意数据将不定期清理,生产使用请自行部署
|
||||
> 包含敏感信息,务必自己本地部署进行生产使用
|
||||
|
||||
## 三、使用教程
|
||||
本案例演示,如何配置自动申请证书,并部署到阿里云CDN,然后快要到期前自动更新证书并重新部署
|
||||
|
||||

|
||||

|
||||

|
||||

|
||||

|
||||
|
||||
↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
|
||||
-------> [点我查看详细使用步骤演示](./step.md) <--------
|
||||
↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
|
||||
|
||||
## 四、本地docker部署
|
||||
|
||||
### 1. 安装docker、docker-compose
|
||||
|
||||
1.1 安装docker
|
||||
https://docs.docker.com/engine/install/
|
||||
|
||||
1.2 安装docker-compose
|
||||
https://docs.docker.com/compose/install/linux/
|
||||
|
||||
### 2. 下载docker-compose.yaml文件
|
||||
```bash
|
||||
mdkir certd
|
||||
cd certd
|
||||
wget https://github.com/certd/certd/blob/v2/docker/run/docker-compose.yaml
|
||||
|
||||
# 根据需要修改里面的配置
|
||||
# 1.修改镜像版本号
|
||||
# 2.配置数据保存路径
|
||||
# 3.配置certd_auth_jwt_secret
|
||||
vi docker-compose.yaml
|
||||
|
||||
|
||||
```
|
||||
> 镜像版本号与release版本号同步:
|
||||
https://github.com/certd/certd/releases
|
||||
|
||||
|
||||
### 3. 运行
|
||||
```bash
|
||||
# 如果docker compose是插件化安装
|
||||
docker compose up -d
|
||||
|
||||
#如果docker compose是独立安装
|
||||
docker-compose up -d
|
||||
|
||||
```
|
||||
### 4. 访问
|
||||
|
||||
http://your_server_ip:7001
|
||||
默认账号密码:admin/123456
|
||||
记得修改密码
|
||||
|
||||
|
||||
## 五、一些说明
|
||||
|
||||
## 免费证书申请说明
|
||||
* 本项目ssl证书提供商为letencrypt
|
||||
* 申请过程遵循acme协议
|
||||
* 需要验证域名所有权,一般有两种方式(目前本项目仅支持dns-01)
|
||||
* http-01: 在网站根目录下放置一份txt文件
|
||||
* dns-01: 需要给域名添加txt解析记录,泛域名只能用这种方式
|
||||
* 需要验证域名所有权,一般有两种方式(目前本项目仅支持dns-01)
|
||||
* http-01: 在网站根目录下放置一份txt文件
|
||||
* dns-01: 需要给域名添加txt解析记录,通配符域名只能用这种方式
|
||||
* 证书续期:
|
||||
* 实际上acme并没有续期概念。
|
||||
* 我们所说的续期,其实就是按照全套流程重新申请一份新证书。
|
||||
* 免费证书过期时间90天,以后可能还会缩短,所以自动化部署必不可少
|
||||
* 设置每天自动运行,当证书过期前20天,会自动重新申请证书并部署
|
||||
|
||||
## 六、联系作者
|
||||
如有疑问,欢迎加入群聊(请备注certd)
|
||||
* QQ群:141236433
|
||||
* 微信群:
|
||||

|
||||
|
||||
|
||||
|
||||
## 快速开始
|
||||
本案例演示,如何配置自动申请证书,并部署到阿里云CDN,然后快要到期前自动更新证书并重新部署
|
||||
|
||||
|
||||
1. 环境准备
|
||||
安装[nodejs](https://nodejs.org/zh-cn/)
|
||||
|
||||
|
||||
2. 生成node项目
|
||||
|
||||
通过ui生成: https://certd.docmirror.cn/
|
||||
|
||||
开始生成证书,先填写域名,支持将多个域名打到一个证书上
|
||||

|
||||
|
||||
配置证书详细信息
|
||||

|
||||
|
||||
配置证书部署流程
|
||||

|
||||
|
||||
配置好之后,点击导出按钮,导出一个node项目包
|
||||
|
||||
4. 运行
|
||||
将导出的压缩包解压,然后执行如下命令,即可开始申请证书并部署
|
||||
```
|
||||
npm install
|
||||
npm run certd
|
||||
```
|
||||
5. 执行效果
|
||||
生成的证书默认会存储在 `${home}/.certd/${email}/certs/${domain}/current`目录下
|
||||
```
|
||||
[2021-01-08T16:15:04.681] [INFO] certd - 任务完成
|
||||
[2021-01-08T16:15:04.681] [INFO] certd - ---------------------------任务结果总览--------------------------
|
||||
[2021-01-08T16:15:04.682] [INFO] certd - 【更新证书】--------------------------------------- [success]
|
||||
证书申请成功
|
||||
[2021-01-08T16:15:04.682] [INFO] certd - 【流程1-部署到阿里云CDN】---------------------------- [success] 执行成功
|
||||
[2021-01-08T16:15:04.682] [INFO] certd - └【上传到阿里云】-------------------------------- [success] 执行成功
|
||||
[2021-01-08T16:15:04.682] [INFO] certd - └【部署证书到CDN】------------------------------- [success] 执行成功
|
||||
```
|
||||
6. 证书续期
|
||||
实际上没有证书续期的概念,只有重新生成一份新的证书,然后重新部署证书
|
||||
所以每天定时运行即可,当证书过期日前20天时,会重新申请新的证书,然后执行部署任务。
|
||||
|
||||
7. 其他说明
|
||||
证书的部署任务执行后会记录执行结果,已经成功过的不会重复执行
|
||||
所以当你临时需要将证书部署到其他地方时,直接追加部署任务,然后再次运行即可
|
||||
|
||||
## CI/DI集成与自动续期重新部署
|
||||
集成前,将以上导出的node项目提交到内网git仓库,或者私有git仓库(由于包含敏感信息,不要提交到公开git仓库)
|
||||
|
||||
### jenkins任务
|
||||
1. 创建任务
|
||||
选择构建自由风格的任务
|
||||
|
||||
2. 配置git
|
||||
配置cert-run的git地址
|
||||
|
||||
3. 构建触发器
|
||||
配置 `H 3 * * *` ,每天凌晨3点-4点执行一次
|
||||
|
||||
4. 构建环境
|
||||
勾选 `Provide Node & npm bin/ folder to PATH`,提供nodejs运行环境
|
||||
如果没有此选项,需要jenkins安装`nodejs`插件
|
||||
|
||||
5. 构建
|
||||
执行shell
|
||||
```
|
||||
npm install --production #执行过一次之后,就可以注释掉,加快执行速度
|
||||
npm run post
|
||||
```
|
||||
6. 构建后操作
|
||||
邮件通知
|
||||
配置你的邮箱地址,可以在执行失败时收到邮件通知。
|
||||
|
||||
|
||||
## API
|
||||
先列个提纲,待完善
|
||||
|
||||
参数示例参考:https://gitee.com/certd/certd/blob/master/test/options.js
|
||||
|
||||
### 授权提供者
|
||||
用于dns验证接口调用
|
||||
#### aliyun
|
||||
|
||||
#### dnspod
|
||||
|
||||
### deploy插件
|
||||
部署任务插件
|
||||
#### 阿里云
|
||||
##### 上传到阿里云
|
||||
type = uploadCertToAliyun
|
||||
##### 部署到阿里云DNS
|
||||
type = deployCertToAliyunCDN
|
||||
|
||||
##### 部署到阿里云CLB
|
||||
type = deployCertToAliyunCLB
|
||||
|
||||
#### 腾讯云
|
||||
##### 上传到腾讯云
|
||||
type = uploadCertToTencent
|
||||
|
||||
##### 部署到腾讯云DNS
|
||||
type = deployCertToTencentDNS
|
||||
|
||||
##### 部署到腾讯云CLB
|
||||
type = deployCertToTencentCLB
|
||||
|
||||
##### 部署到腾讯云TKE-ingress
|
||||
type = deployCertToTencentTKEIngress
|
||||
|
||||
|
||||
### 更多部署插件
|
||||
等你来提需求
|
||||
## 七、我的其他项目
|
||||
* [袖手GPT](https://ai.handsfree.work/) ChatGPT,国内可用,无需FQ,每日免费额度
|
||||
* [fast-crud](https://gitee.com/fast-crud/fast-crud/) 基于vue3的crud快速开发框架
|
||||
* [dev-sidecar](https://github.com/docmirror/dev-sidecar/) 直连访问github工具,无需FQ,解决github无法访问的问题
|
||||
|
||||
17
deploy.js
@@ -2,9 +2,10 @@ import http from 'axios'
|
||||
import fs from 'fs'
|
||||
|
||||
//读取 packages/core/pipline/package.json的版本号
|
||||
import { default as packageJson } from './packages/core/pipeline/package.json' assert { type: "json" };
|
||||
import {default as packageJson} from './packages/core/pipeline/package.json' assert {type: "json"};
|
||||
|
||||
const certdVersion = packageJson.version
|
||||
console.log("certdVersion",certdVersion)
|
||||
console.log("certdVersion", certdVersion)
|
||||
|
||||
// 同步npmmirror的包
|
||||
async function getPackages(directoryPath) {
|
||||
@@ -29,18 +30,18 @@ async function getPackages(directoryPath) {
|
||||
|
||||
}
|
||||
|
||||
async function getAllPackages(){
|
||||
async function getAllPackages() {
|
||||
const base = await getPackages("./packages/core")
|
||||
const plugins =await getPackages("./packages/plugins")
|
||||
const plugins = await getPackages("./packages/plugins")
|
||||
|
||||
return base.concat(plugins)
|
||||
}
|
||||
|
||||
async function sync(){
|
||||
async function sync() {
|
||||
const packages = await getAllPackages()
|
||||
for(const pkg of packages){
|
||||
for (const pkg of packages) {
|
||||
await http({
|
||||
url: `https://registry-direct.npmmirror.com/@certd/${pkg}/sync?sync_upstream=true`,
|
||||
url: `http://registry-direct.npmmirror.com/@certd/${pkg}/sync?sync_upstream=true`,
|
||||
method: 'PUT',
|
||||
headers: {
|
||||
"Content-Type": "application/json"
|
||||
@@ -50,7 +51,6 @@ async function sync(){
|
||||
console.log(`sync success:${pkg}`)
|
||||
await sleep(1000)
|
||||
}
|
||||
await sleep(60000)
|
||||
}
|
||||
|
||||
// curl -X PUT https://registry-direct.npmmirror.com/@certd/plugin-cert/sync?sync_upstream=true
|
||||
@@ -87,6 +87,7 @@ async function start() {
|
||||
console.log("等待60秒")
|
||||
await sleep(60 * 1000)
|
||||
await sync()
|
||||
await sleep(60 * 1000)
|
||||
await triggerBuild()
|
||||
}
|
||||
|
||||
|
||||
BIN
doc/images/1-add.png
Normal file
|
After Width: | Height: | Size: 68 KiB |
BIN
doc/images/10-1-log.png
Normal file
|
After Width: | Height: | Size: 124 KiB |
BIN
doc/images/11-1-error.png
Normal file
|
After Width: | Height: | Size: 33 KiB |
BIN
doc/images/11-2-error.png
Normal file
|
After Width: | Height: | Size: 67 KiB |
BIN
doc/images/12-1-log-success.png
Normal file
|
After Width: | Height: | Size: 34 KiB |
BIN
doc/images/12-2-skip-log.png
Normal file
|
After Width: | Height: | Size: 47 KiB |
BIN
doc/images/13-1-result.png
Normal file
|
After Width: | Height: | Size: 82 KiB |
BIN
doc/images/13-2-result.png
Normal file
|
After Width: | Height: | Size: 46 KiB |
BIN
doc/images/13-3-download.png
Normal file
|
After Width: | Height: | Size: 43 KiB |
BIN
doc/images/14-timer.png
Normal file
|
After Width: | Height: | Size: 50 KiB |
BIN
doc/images/15-1-email.png
Normal file
|
After Width: | Height: | Size: 44 KiB |
BIN
doc/images/15-2-email.png
Normal file
|
After Width: | Height: | Size: 35 KiB |
BIN
doc/images/2-access-provider.png
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
doc/images/3-add-access.png
Normal file
|
After Width: | Height: | Size: 29 KiB |
BIN
doc/images/4-add-success.png
Normal file
|
After Width: | Height: | Size: 50 KiB |
BIN
doc/images/5-view.png
Normal file
|
After Width: | Height: | Size: 72 KiB |
BIN
doc/images/6-1-add-task.png
Normal file
|
After Width: | Height: | Size: 30 KiB |
BIN
doc/images/6-2-add-task.png
Normal file
|
After Width: | Height: | Size: 61 KiB |
BIN
doc/images/6-3-add-task.png
Normal file
|
After Width: | Height: | Size: 66 KiB |
BIN
doc/images/7-1-add-host-task.png
Normal file
|
After Width: | Height: | Size: 76 KiB |
BIN
doc/images/7-2-add-host-task.png
Normal file
|
After Width: | Height: | Size: 55 KiB |
BIN
doc/images/7-3-add-host-task.png
Normal file
|
After Width: | Height: | Size: 28 KiB |
BIN
doc/images/8-1-add-host-task.png
Normal file
|
After Width: | Height: | Size: 32 KiB |
BIN
doc/images/8-2-add-host-task.png
Normal file
|
After Width: | Height: | Size: 56 KiB |
BIN
doc/images/8-4-add-host-task.png
Normal file
|
After Width: | Height: | Size: 48 KiB |
BIN
doc/images/8-5-add-host-task.png
Normal file
|
After Width: | Height: | Size: 38 KiB |
BIN
doc/images/9-start.png
Normal file
|
After Width: | Height: | Size: 39 KiB |
BIN
doc/step1.png
|
Before Width: | Height: | Size: 12 KiB |
BIN
doc/step2.png
|
Before Width: | Height: | Size: 44 KiB |
BIN
doc/step3.png
|
Before Width: | Height: | Size: 92 KiB |
BIN
doc/tasks.png
|
Before Width: | Height: | Size: 18 KiB |
@@ -11,4 +11,5 @@ services: # 要拉起的服务们
|
||||
- "7001:7001"
|
||||
environment:
|
||||
- TZ=Asia/Shanghai
|
||||
- node_sqlite3_binary_host_mirror=https://registry.npmmirror.com/-/binary/sqlite3
|
||||
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
echo "请先输入一个版本号(如 1.0.6):"
|
||||
read version
|
||||
echo "您输入的版本号是: $version"
|
||||
export TAG="$version"
|
||||
# 判断$CERTD_VERSION 是否存在
|
||||
if [ -n "$CERTD_VERSION" ]; then
|
||||
echo "CERTD_VERSION is set = $CERTD_VERSION"
|
||||
else
|
||||
echo "CERTD_VERSION is not set"
|
||||
echo "请先输入一个版本号(如 1.0.6):"
|
||||
read CERTD_VERSION
|
||||
fi
|
||||
|
||||
echo "您输入的版本号是: $CERTD_VERSION"
|
||||
sudo -E docker compose up -d
|
||||
|
||||
@@ -1,20 +1,23 @@
|
||||
version: '3.3' # 指定docker-compose 版本
|
||||
services: # 要拉起的服务们
|
||||
version: '3.3'
|
||||
services:
|
||||
certd:
|
||||
# build:
|
||||
# context: ./
|
||||
# dockerfile: Dockerfile
|
||||
# ↓↓↓↓↓ 修改镜像版本号
|
||||
image: registry.cn-shenzhen.aliyuncs.com/handsfree/certd:${TAG}
|
||||
# 镜像 # ↓↓↓↓↓ --- 1、 修改镜像版本号,或者干脆写成latest
|
||||
image: registry.cn-shenzhen.aliyuncs.com/handsfree/certd:${CERTD_VERSION}
|
||||
container_name: certd # 容器名
|
||||
restart: unless-stopped # 重启
|
||||
volumes:
|
||||
# ↓↓↓↓↓ 修改数据库以及证书存储路径
|
||||
# ↓↓↓↓↓ ------------------------------------------------------- 2、 修改数据库以及证书存储路径
|
||||
- /data/certd:/app/data
|
||||
ports: # 端口映射
|
||||
- "7001:7001"
|
||||
environment:
|
||||
environment: # 环境变量
|
||||
- TZ=Asia/Shanghai
|
||||
- certd_auth_jwt_secret=changeme
|
||||
# ↑↑↑↑↑ 注意修改成你的自定义密钥
|
||||
# ↑↑↑↑↑ ---------------------------------- 3、 修改成你的自定义密钥
|
||||
# 设置环境变量即可自定义certd配置
|
||||
# 服务端配置项见: packages/ui/certd-server/src/config/config.default.ts
|
||||
# 服务端配置规则: certd_ + 配置项, 点号用_代替
|
||||
# 如jwt密钥配置为: auth.jwt.secret,则设置环境变量 certd_auth_jwt_secret=changeme
|
||||
|
||||
# 客户端配置项见: packages/ui/certd-client/.env
|
||||
# 按实际名称配置环境变量即可,如: VITE_APP_API=http://localhost:7001
|
||||
|
||||
@@ -9,5 +9,5 @@
|
||||
}
|
||||
},
|
||||
"npmClient": "pnpm",
|
||||
"version": "1.1.2"
|
||||
"version": "1.1.6"
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
"scripts": {
|
||||
"start": "lerna bootstrap --hoist",
|
||||
"i-all": "lerna link && lerna exec npm install ",
|
||||
"publish": "npm run proxy && npm run prepublishOnly1 && lerna publish --conventional-commits && npm run afterpublishOnly && node deploy.js",
|
||||
"publish": "npm run proxy && npm run prepublishOnly1 && lerna publish --conventional-commits && npm run afterpublishOnly && npm run deploy1",
|
||||
"afterpublishOnly": "",
|
||||
"proxy": "npm config set proxy=http://127.0.0.1:10809",
|
||||
"prepublishOnly1": "npm run before-build && lerna run build ",
|
||||
|
||||
@@ -3,6 +3,22 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.6](https://github.com/publishlab/node-acme-client/compare/v1.1.5...v1.1.6) (2023-07-10)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
## [1.1.5](https://github.com/publishlab/node-acme-client/compare/v1.1.4...v1.1.5) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
## [1.1.4](https://github.com/publishlab/node-acme-client/compare/v1.1.3...v1.1.4) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
## [1.1.3](https://github.com/publishlab/node-acme-client/compare/v1.1.2...v1.1.3) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
## [1.1.2](https://github.com/publishlab/node-acme-client/compare/v1.1.1...v1.1.2) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/acme-client
|
||||
|
||||
@@ -1 +1 @@
|
||||
09:16
|
||||
12:58
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
"description": "Simple and unopinionated ACME client",
|
||||
"private": false,
|
||||
"author": "nmorsman",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.6",
|
||||
"main": "src/index.js",
|
||||
"types": "types",
|
||||
"license": "MIT",
|
||||
@@ -58,5 +58,5 @@
|
||||
"bugs": {
|
||||
"url": "https://github.com/publishlab/node-acme-client/issues"
|
||||
},
|
||||
"gitHead": "5950e1cae7cf30ebfc5128c15c7d1b0d101cbbb8"
|
||||
"gitHead": "b258e926209fef4cc4d633b0383eb54e26c516f9"
|
||||
}
|
||||
|
||||
@@ -3,6 +3,29 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.6](https://github.com/certd/certd/compare/v1.1.5...v1.1.6) (2023-07-10)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复上传证书到腾讯云失败的bug ([e950322](https://github.com/certd/certd/commit/e950322232e19d1263b8552eefa5b0150fd7864e))
|
||||
|
||||
## [1.1.5](https://github.com/certd/certd/compare/v1.1.4...v1.1.5) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/pipeline
|
||||
|
||||
## [1.1.4](https://github.com/certd/certd/compare/v1.1.3...v1.1.4) (2023-07-03)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* cancel task ([bc65c0a](https://github.com/certd/certd/commit/bc65c0a786360c087fe95cad93ec6a87804cc5ee))
|
||||
* flush log ([891a43a](https://github.com/certd/certd/commit/891a43ae6716ff98ed06643f7da2e35199ee195c))
|
||||
* flush logger ([91be682](https://github.com/certd/certd/commit/91be6826b902e0f302b1a6cbdb1d24e15914c18d))
|
||||
* timeout ([3eeb1f7](https://github.com/certd/certd/commit/3eeb1f77aa2922f3545f3d2067f561d95621d54f))
|
||||
|
||||
## [1.1.3](https://github.com/certd/certd/compare/v1.1.2...v1.1.3) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/pipeline
|
||||
|
||||
## [1.1.2](https://github.com/certd/certd/compare/v1.1.1...v1.1.2) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/pipeline
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@certd/pipeline",
|
||||
"private": false,
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.6",
|
||||
"main": "./src/index.ts",
|
||||
"module": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
@@ -23,7 +23,7 @@
|
||||
"qs": "^6.11.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@certd/acme-client": "^1.1.2",
|
||||
"@certd/acme-client": "^1.1.6",
|
||||
"@rollup/plugin-commonjs": "^23.0.4",
|
||||
"@rollup/plugin-json": "^6.0.0",
|
||||
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||
@@ -56,5 +56,5 @@
|
||||
"vite": "^4.3.8",
|
||||
"vue-tsc": "^1.6.5"
|
||||
},
|
||||
"gitHead": "5950e1cae7cf30ebfc5128c15c7d1b0d101cbbb8"
|
||||
"gitHead": "b258e926209fef4cc4d633b0383eb54e26c516f9"
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import { RegistryItem } from "../registry";
|
||||
import { Decorator } from "../decorator";
|
||||
import { IEmailService } from "../service";
|
||||
import { FileStore } from "./file-store";
|
||||
import { TimeoutPromise } from "../utils/util.promise";
|
||||
|
||||
export type ExecutorOptions = {
|
||||
userId: any;
|
||||
@@ -31,6 +32,7 @@ export class Executor {
|
||||
lastStatusMap!: RunnableCollection;
|
||||
lastRuntime!: RunHistory;
|
||||
options: ExecutorOptions;
|
||||
canceled = false;
|
||||
onChanged: (history: RunHistory) => void;
|
||||
constructor(options: ExecutorOptions) {
|
||||
this.options = options;
|
||||
@@ -50,6 +52,12 @@ export class Executor {
|
||||
this.lastStatusMap = new RunnableCollection(lastRuntime?.pipeline);
|
||||
}
|
||||
|
||||
async cancel() {
|
||||
this.canceled = true;
|
||||
this.runtime?.cancel(this.pipeline);
|
||||
await this.onChanged(this.runtime);
|
||||
}
|
||||
|
||||
async run(runtimeId: any = 0, triggerType: string) {
|
||||
try {
|
||||
await this.init();
|
||||
@@ -99,17 +107,24 @@ export class Executor {
|
||||
return ResultType.skip;
|
||||
}
|
||||
}
|
||||
try {
|
||||
await run();
|
||||
this.runtime.success(runnable);
|
||||
const intervalFlushLogId = setInterval(async () => {
|
||||
await this.onChanged(this.runtime);
|
||||
}, 5000);
|
||||
const timeout = runnable.timeout ?? 20 * 60 * 1000;
|
||||
try {
|
||||
if (this.canceled) {
|
||||
throw new Error("task canceled");
|
||||
}
|
||||
await TimeoutPromise(run, timeout);
|
||||
this.runtime.success(runnable);
|
||||
return ResultType.success;
|
||||
} catch (e: any) {
|
||||
this.runtime.error(runnable, e);
|
||||
await this.onChanged(this.runtime);
|
||||
throw e;
|
||||
} finally {
|
||||
this.runtime.finally(runnable);
|
||||
clearInterval(intervalFlushLogId);
|
||||
await this.onChanged(this.runtime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -92,6 +92,19 @@ export class RunHistory {
|
||||
this.logError(runnable, e);
|
||||
}
|
||||
|
||||
cancel(runnable: Runnable) {
|
||||
const now = new Date().getTime();
|
||||
const status = runnable.status;
|
||||
_.merge(status, {
|
||||
status: ResultType.canceled,
|
||||
endTime: now,
|
||||
result: ResultType.canceled,
|
||||
message: "用户取消",
|
||||
});
|
||||
|
||||
this.log(runnable, "任务取消");
|
||||
}
|
||||
|
||||
log(runnable: Runnable, text: string) {
|
||||
// @ts-ignore
|
||||
this._loggers[runnable.id].info(`[${runnable.title}]<id:${runnable.id}> [${runnable.runnableType}]`, text);
|
||||
|
||||
@@ -66,6 +66,7 @@ export type Runnable = {
|
||||
strategy?: RunnableStrategy;
|
||||
runnableType?: string; // pipeline, stage, task , step
|
||||
status?: HistoryResult;
|
||||
timeout?: number;
|
||||
default?: {
|
||||
[key: string]: any;
|
||||
};
|
||||
@@ -87,7 +88,7 @@ export type Pipeline = Runnable & {
|
||||
userId: any;
|
||||
stages: Stage[];
|
||||
triggers: Trigger[];
|
||||
notifications: Notification[];
|
||||
notifications?: Notification[];
|
||||
};
|
||||
|
||||
export type Context = {
|
||||
@@ -105,6 +106,7 @@ export enum ResultType {
|
||||
start = "start",
|
||||
success = "success",
|
||||
error = "error",
|
||||
canceled = "canceled",
|
||||
skip = "skip",
|
||||
none = "none",
|
||||
}
|
||||
|
||||
13
packages/core/pipeline/src/utils/util.promise.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export function TimeoutPromise(callback: () => Promise<void>, ms = 30 * 1000) {
|
||||
let timeout: any;
|
||||
return Promise.race([
|
||||
callback(),
|
||||
new Promise((resolve, reject) => {
|
||||
timeout = setTimeout(() => {
|
||||
reject(new Error(`Task timeout in ${ms} ms`));
|
||||
}, ms);
|
||||
}),
|
||||
]).finally(() => {
|
||||
clearTimeout(timeout);
|
||||
});
|
||||
}
|
||||
@@ -3,6 +3,24 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.6](https://github.com/certd/certd/compare/v1.1.5...v1.1.6) (2023-07-10)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-aliyun
|
||||
|
||||
## [1.1.5](https://github.com/certd/certd/compare/v1.1.4...v1.1.5) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-aliyun
|
||||
|
||||
## [1.1.4](https://github.com/certd/certd/compare/v1.1.3...v1.1.4) (2023-07-03)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* timeout ([3eeb1f7](https://github.com/certd/certd/commit/3eeb1f77aa2922f3545f3d2067f561d95621d54f))
|
||||
|
||||
## [1.1.3](https://github.com/certd/certd/compare/v1.1.2...v1.1.3) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-aliyun
|
||||
|
||||
## [1.1.2](https://github.com/certd/certd/compare/v1.1.1...v1.1.2) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-aliyun
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@certd/plugin-aliyun",
|
||||
"private": false,
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.6",
|
||||
"main": "./src/index.ts",
|
||||
"module": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
@@ -23,10 +23,10 @@
|
||||
"node-forge": "^0.10.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@certd/acme-client": "^1.1.2",
|
||||
"@certd/pipeline": "^1.1.2",
|
||||
"@certd/plugin-cert": "^1.1.2",
|
||||
"@certd/plugin-util": "^1.1.2",
|
||||
"@certd/acme-client": "^1.1.6",
|
||||
"@certd/pipeline": "^1.1.6",
|
||||
"@certd/plugin-cert": "^1.1.6",
|
||||
"@certd/plugin-util": "^1.1.6",
|
||||
"@midwayjs/core": "^3.0.0",
|
||||
"@midwayjs/decorator": "^3.0.0",
|
||||
"@rollup/plugin-commonjs": "^23.0.4",
|
||||
@@ -59,5 +59,5 @@
|
||||
"vite": "^3.1.0",
|
||||
"vue-tsc": "^0.38.9"
|
||||
},
|
||||
"gitHead": "5950e1cae7cf30ebfc5128c15c7d1b0d101cbbb8"
|
||||
"gitHead": "b258e926209fef4cc4d633b0383eb54e26c516f9"
|
||||
}
|
||||
|
||||
@@ -3,6 +3,26 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.6](https://github.com/certd/certd/compare/v1.1.5...v1.1.6) (2023-07-10)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复上传证书到腾讯云失败的bug ([e950322](https://github.com/certd/certd/commit/e950322232e19d1263b8552eefa5b0150fd7864e))
|
||||
|
||||
## [1.1.5](https://github.com/certd/certd/compare/v1.1.4...v1.1.5) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-all
|
||||
|
||||
## [1.1.4](https://github.com/certd/certd/compare/v1.1.3...v1.1.4) (2023-07-03)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* timeout ([3eeb1f7](https://github.com/certd/certd/commit/3eeb1f77aa2922f3545f3d2067f561d95621d54f))
|
||||
|
||||
## [1.1.3](https://github.com/certd/certd/compare/v1.1.2...v1.1.3) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-all
|
||||
|
||||
## [1.1.2](https://github.com/certd/certd/compare/v1.1.1...v1.1.2) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-all
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@certd/plugin-all",
|
||||
"private": false,
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.6",
|
||||
"main": "./src/index.ts",
|
||||
"module": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
@@ -17,12 +17,12 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@certd/pipeline": "^1.1.2",
|
||||
"@certd/plugin-aliyun": "^1.1.2",
|
||||
"@certd/plugin-cert": "^1.1.2",
|
||||
"@certd/plugin-host": "^1.1.2",
|
||||
"@certd/plugin-huawei": "^1.1.2",
|
||||
"@certd/plugin-tencent": "^1.1.2",
|
||||
"@certd/pipeline": "^1.1.6",
|
||||
"@certd/plugin-aliyun": "^1.1.6",
|
||||
"@certd/plugin-cert": "^1.1.6",
|
||||
"@certd/plugin-host": "^1.1.6",
|
||||
"@certd/plugin-huawei": "^1.1.6",
|
||||
"@certd/plugin-tencent": "^1.1.6",
|
||||
"@rollup/plugin-commonjs": "^23.0.4",
|
||||
"@rollup/plugin-json": "^6.0.0",
|
||||
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||
@@ -48,5 +48,5 @@
|
||||
"vite": "^3.1.0",
|
||||
"vue-tsc": "^0.38.9"
|
||||
},
|
||||
"gitHead": "5950e1cae7cf30ebfc5128c15c7d1b0d101cbbb8"
|
||||
"gitHead": "b258e926209fef4cc4d633b0383eb54e26c516f9"
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { IAccessService } from "@certd/pipeline";
|
||||
import { EmailSend, IAccessService, IEmailService } from "@certd/pipeline";
|
||||
import { AliyunAccess } from "@certd/plugin-aliyun";
|
||||
import { aliyunSecret } from "../user.secret";
|
||||
|
||||
export class AccessServiceTest implements IAccessService {
|
||||
async getById(id: any): Promise<any> {
|
||||
return {
|
||||
@@ -8,3 +9,10 @@ export class AccessServiceTest implements IAccessService {
|
||||
} as AliyunAccess;
|
||||
}
|
||||
}
|
||||
|
||||
export class EmailServiceTest implements IEmailService {
|
||||
send(email: EmailSend): Promise<void> {
|
||||
console.log("send email", email);
|
||||
return Promise.resolve(undefined);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,6 +58,17 @@ export const pipeline: Pipeline = {
|
||||
runStrategy: RunStrategy.SkipWhenSucceed,
|
||||
},
|
||||
},
|
||||
{
|
||||
id: generateId(),
|
||||
title: "上传证书到腾讯云",
|
||||
type: "EchoPlugin",
|
||||
input: {
|
||||
cert: "cert",
|
||||
},
|
||||
strategy: {
|
||||
runStrategy: RunStrategy.SkipWhenSucceed,
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import "mocha";
|
||||
import { Executor, FileStorage, RunHistory } from "@certd/pipeline";
|
||||
import { pipeline } from "./pipeline.define";
|
||||
import { AccessServiceTest } from "./access-service-test";
|
||||
import { AccessServiceTest, EmailServiceTest } from "./access-service-test";
|
||||
import "../../src";
|
||||
import "../plugin/echo-plugin";
|
||||
|
||||
@@ -13,7 +13,14 @@ describe("pipeline", function () {
|
||||
console.log("changed:");
|
||||
}
|
||||
|
||||
const executor = new Executor({ userId: "test", pipeline, onChanged, accessService: new AccessServiceTest(), storage: new FileStorage() });
|
||||
const executor = new Executor({
|
||||
userId: "test",
|
||||
pipeline,
|
||||
onChanged,
|
||||
accessService: new AccessServiceTest(),
|
||||
emailService: new EmailServiceTest(),
|
||||
storage: new FileStorage(),
|
||||
});
|
||||
await executor.run(1, "user");
|
||||
// expect(define.name).eq("EchoPlugin");
|
||||
});
|
||||
|
||||
@@ -3,6 +3,24 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.6](https://github.com/certd/certd/compare/v1.1.5...v1.1.6) (2023-07-10)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-cert
|
||||
|
||||
## [1.1.5](https://github.com/certd/certd/compare/v1.1.4...v1.1.5) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-cert
|
||||
|
||||
## [1.1.4](https://github.com/certd/certd/compare/v1.1.3...v1.1.4) (2023-07-03)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* timeout ([3eeb1f7](https://github.com/certd/certd/commit/3eeb1f77aa2922f3545f3d2067f561d95621d54f))
|
||||
|
||||
## [1.1.3](https://github.com/certd/certd/compare/v1.1.2...v1.1.3) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-cert
|
||||
|
||||
## [1.1.2](https://github.com/certd/certd/compare/v1.1.1...v1.1.2) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-cert
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@certd/plugin-cert",
|
||||
"private": false,
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.6",
|
||||
"main": "./src/index.ts",
|
||||
"module": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
@@ -17,8 +17,8 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@certd/acme-client": "^1.1.2",
|
||||
"@certd/pipeline": "^1.1.2",
|
||||
"@certd/acme-client": "^1.1.6",
|
||||
"@certd/pipeline": "^1.1.6",
|
||||
"jszip": "^3.10.1",
|
||||
"node-forge": "^0.10.0"
|
||||
},
|
||||
@@ -57,5 +57,5 @@
|
||||
"vite": "^3.1.0",
|
||||
"vue-tsc": "^0.38.9"
|
||||
},
|
||||
"gitHead": "5950e1cae7cf30ebfc5128c15c7d1b0d101cbbb8"
|
||||
"gitHead": "b258e926209fef4cc4d633b0383eb54e26c516f9"
|
||||
}
|
||||
|
||||
@@ -3,6 +3,24 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.6](https://github.com/certd/certd/compare/v1.1.5...v1.1.6) (2023-07-10)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-host
|
||||
|
||||
## [1.1.5](https://github.com/certd/certd/compare/v1.1.4...v1.1.5) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-host
|
||||
|
||||
## [1.1.4](https://github.com/certd/certd/compare/v1.1.3...v1.1.4) (2023-07-03)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* timeout ([3eeb1f7](https://github.com/certd/certd/commit/3eeb1f77aa2922f3545f3d2067f561d95621d54f))
|
||||
|
||||
## [1.1.3](https://github.com/certd/certd/compare/v1.1.2...v1.1.3) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-host
|
||||
|
||||
## [1.1.2](https://github.com/certd/certd/compare/v1.1.1...v1.1.2) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-host
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@certd/plugin-host",
|
||||
"private": false,
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.6",
|
||||
"main": "./src/index.ts",
|
||||
"module": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
@@ -17,8 +17,8 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@certd/pipeline": "^1.1.2",
|
||||
"@certd/plugin-cert": "^1.1.2",
|
||||
"@certd/pipeline": "^1.1.6",
|
||||
"@certd/plugin-cert": "^1.1.6",
|
||||
"ssh2": "^0.8.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -57,5 +57,5 @@
|
||||
"vite": "^3.1.0",
|
||||
"vue-tsc": "^0.38.9"
|
||||
},
|
||||
"gitHead": "5950e1cae7cf30ebfc5128c15c7d1b0d101cbbb8"
|
||||
"gitHead": "b258e926209fef4cc4d633b0383eb54e26c516f9"
|
||||
}
|
||||
|
||||
@@ -3,6 +3,24 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.6](https://github.com/certd/certd/compare/v1.1.5...v1.1.6) (2023-07-10)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-huawei
|
||||
|
||||
## [1.1.5](https://github.com/certd/certd/compare/v1.1.4...v1.1.5) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-huawei
|
||||
|
||||
## [1.1.4](https://github.com/certd/certd/compare/v1.1.3...v1.1.4) (2023-07-03)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* timeout ([3eeb1f7](https://github.com/certd/certd/commit/3eeb1f77aa2922f3545f3d2067f561d95621d54f))
|
||||
|
||||
## [1.1.3](https://github.com/certd/certd/compare/v1.1.2...v1.1.3) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-huawei
|
||||
|
||||
## [1.1.2](https://github.com/certd/certd/compare/v1.1.1...v1.1.2) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-huawei
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@certd/plugin-huawei",
|
||||
"private": false,
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.6",
|
||||
"main": "./src/index.ts",
|
||||
"module": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
@@ -17,10 +17,10 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@certd/acme-client": "^1.1.2",
|
||||
"@certd/pipeline": "^1.1.2",
|
||||
"@certd/plugin-cert": "^1.1.2",
|
||||
"@certd/plugin-util": "^1.1.2",
|
||||
"@certd/acme-client": "^1.1.6",
|
||||
"@certd/pipeline": "^1.1.6",
|
||||
"@certd/plugin-cert": "^1.1.6",
|
||||
"@certd/plugin-util": "^1.1.6",
|
||||
"axios": "^0.27.2",
|
||||
"dayjs": "^1.11.6",
|
||||
"lodash": "^4.17.21",
|
||||
@@ -59,5 +59,5 @@
|
||||
"vite": "^3.1.0",
|
||||
"vue-tsc": "^0.38.9"
|
||||
},
|
||||
"gitHead": "5950e1cae7cf30ebfc5128c15c7d1b0d101cbbb8"
|
||||
"gitHead": "b258e926209fef4cc4d633b0383eb54e26c516f9"
|
||||
}
|
||||
|
||||
@@ -3,6 +3,26 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.6](https://github.com/certd/certd/compare/v1.1.5...v1.1.6) (2023-07-10)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 修复上传证书到腾讯云失败的bug ([e950322](https://github.com/certd/certd/commit/e950322232e19d1263b8552eefa5b0150fd7864e))
|
||||
|
||||
## [1.1.5](https://github.com/certd/certd/compare/v1.1.4...v1.1.5) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-tencent
|
||||
|
||||
## [1.1.4](https://github.com/certd/certd/compare/v1.1.3...v1.1.4) (2023-07-03)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* timeout ([3eeb1f7](https://github.com/certd/certd/commit/3eeb1f77aa2922f3545f3d2067f561d95621d54f))
|
||||
|
||||
## [1.1.3](https://github.com/certd/certd/compare/v1.1.2...v1.1.3) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-tencent
|
||||
|
||||
## [1.1.2](https://github.com/certd/certd/compare/v1.1.1...v1.1.2) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-tencent
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@certd/plugin-tencent",
|
||||
"private": false,
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.6",
|
||||
"main": "./src/index.ts",
|
||||
"module": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
@@ -17,9 +17,9 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@certd/pipeline": "^1.1.2",
|
||||
"@certd/plugin-cert": "^1.1.2",
|
||||
"@certd/plugin-util": "^1.1.2",
|
||||
"@certd/pipeline": "^1.1.6",
|
||||
"@certd/plugin-cert": "^1.1.6",
|
||||
"@certd/plugin-util": "^1.1.6",
|
||||
"tencentcloud-sdk-nodejs": "^4.0.44"
|
||||
},
|
||||
"devDependencies": {
|
||||
@@ -58,5 +58,5 @@
|
||||
"vite": "^3.1.0",
|
||||
"vue-tsc": "^0.38.9"
|
||||
},
|
||||
"gitHead": "5950e1cae7cf30ebfc5128c15c7d1b0d101cbbb8"
|
||||
"gitHead": "b258e926209fef4cc4d633b0383eb54e26c516f9"
|
||||
}
|
||||
|
||||
@@ -7,13 +7,20 @@ import { IsAccess, AccessInput } from "@certd/pipeline";
|
||||
})
|
||||
export class DnspodAccess {
|
||||
@AccessInput({
|
||||
title: "token",
|
||||
title: "端点",
|
||||
component: {
|
||||
placeholder: "开放接口token",
|
||||
placeholder: "endpoint",
|
||||
name: "a-select",
|
||||
vModel: "value",
|
||||
options: [
|
||||
{ value: "https://dnsapi.cn", label: "中国站" },
|
||||
{ value: "https://api.dnspod.com", label: "国际站" },
|
||||
],
|
||||
},
|
||||
rules: [{ required: true, message: "该项必填" }],
|
||||
})
|
||||
token = "";
|
||||
endpoint = "";
|
||||
|
||||
@AccessInput({
|
||||
title: "账户id",
|
||||
component: {
|
||||
@@ -22,6 +29,15 @@ export class DnspodAccess {
|
||||
rules: [{ required: true, message: "该项必填" }],
|
||||
})
|
||||
id = "";
|
||||
|
||||
@AccessInput({
|
||||
title: "token",
|
||||
component: {
|
||||
placeholder: "开放接口token",
|
||||
},
|
||||
rules: [{ required: true, message: "该项必填" }],
|
||||
})
|
||||
token = "";
|
||||
}
|
||||
|
||||
new DnspodAccess();
|
||||
|
||||
@@ -20,9 +20,11 @@ export class DnspodDnsProvider implements IDnsProvider {
|
||||
|
||||
loginToken: any;
|
||||
|
||||
endpoint = "";
|
||||
async onInstance() {
|
||||
const access: DnspodAccess = this.access as DnspodAccess;
|
||||
this.loginToken = access.id + "," + access.token;
|
||||
this.endpoint = access.endpoint || "https://dnsapi.cn";
|
||||
}
|
||||
|
||||
async doRequest(options: any, successCodes: string[] = []) {
|
||||
@@ -51,7 +53,7 @@ export class DnspodDnsProvider implements IDnsProvider {
|
||||
|
||||
async getDomainList() {
|
||||
const ret = await this.doRequest({
|
||||
url: "https://dnsapi.cn/Domain.List",
|
||||
url: this.access.endpoint + "/Domain.List",
|
||||
});
|
||||
this.logger.debug("dnspod 域名列表:", ret.domains);
|
||||
return ret.domains;
|
||||
@@ -66,7 +68,7 @@ export class DnspodDnsProvider implements IDnsProvider {
|
||||
|
||||
const ret = await this.doRequest(
|
||||
{
|
||||
url: "https://dnsapi.cn/Record.Create",
|
||||
url: this.access.endpoint + "/Record.Create",
|
||||
formData: {
|
||||
domain,
|
||||
sub_domain: rr,
|
||||
@@ -87,7 +89,7 @@ export class DnspodDnsProvider implements IDnsProvider {
|
||||
const domain = await this.matchDomain(fullRecord);
|
||||
|
||||
const ret = await this.doRequest({
|
||||
url: "https://dnsapi.cn/Record.Remove",
|
||||
url: this.access.endpoint + "/Record.Remove",
|
||||
formData: {
|
||||
domain,
|
||||
record_id: record.id,
|
||||
|
||||
@@ -47,6 +47,17 @@ export class DeployToCdnPlugin extends AbstractTaskPlugin {
|
||||
})
|
||||
domainName!: string;
|
||||
|
||||
@TaskInput({
|
||||
title: "CDN接口",
|
||||
helper: "CDN接口端点",
|
||||
component: {
|
||||
name: "a-select",
|
||||
type: "tencent",
|
||||
},
|
||||
required: true,
|
||||
})
|
||||
endpoint!: string;
|
||||
|
||||
accessService!: IAccessService;
|
||||
|
||||
logger!: ILogger;
|
||||
|
||||
@@ -87,7 +87,7 @@ export class DeployCertToTencentTKEIngressPlugin extends AbstractTaskPlugin {
|
||||
this.logger = this.ctx.logger;
|
||||
}
|
||||
async execute(): Promise<void> {
|
||||
const accessProvider = this.accessService.getById(this.accessId);
|
||||
const accessProvider = await this.accessService.getById(this.accessId);
|
||||
const tkeClient = this.getTkeClient(accessProvider, this.region);
|
||||
const kubeConfigStr = await this.getTkeKubeConfig(tkeClient, this.clusterId);
|
||||
|
||||
|
||||
@@ -52,7 +52,7 @@ export class UploadToTencentPlugin extends AbstractTaskPlugin {
|
||||
|
||||
async execute(): Promise<void> {
|
||||
const { accessId, name, cert } = this;
|
||||
const accessProvider = this.accessService.getById(accessId);
|
||||
const accessProvider = await this.accessService.getById(accessId);
|
||||
const certName = this.appendTimeSuffix(name || cert.domain);
|
||||
const client = this.getClient(accessProvider);
|
||||
|
||||
@@ -96,7 +96,7 @@ export class UploadToTencentPlugin extends AbstractTaskPlugin {
|
||||
|
||||
// async rollback({ input }) {
|
||||
// const { accessId } = input;
|
||||
// const accessProvider = this.accessService.getById(accessId);
|
||||
// const accessProvider = await this.accessService.getById(accessId);
|
||||
// const client = this.getClient(accessProvider);
|
||||
//
|
||||
// const { tencentCertId } = context;
|
||||
|
||||
@@ -3,6 +3,24 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.6](https://github.com/certd/certd/compare/v1.1.5...v1.1.6) (2023-07-10)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-util
|
||||
|
||||
## [1.1.5](https://github.com/certd/certd/compare/v1.1.4...v1.1.5) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-util
|
||||
|
||||
## [1.1.4](https://github.com/certd/certd/compare/v1.1.3...v1.1.4) (2023-07-03)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* timeout ([3eeb1f7](https://github.com/certd/certd/commit/3eeb1f77aa2922f3545f3d2067f561d95621d54f))
|
||||
|
||||
## [1.1.3](https://github.com/certd/certd/compare/v1.1.2...v1.1.3) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-util
|
||||
|
||||
## [1.1.2](https://github.com/certd/certd/compare/v1.1.1...v1.1.2) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/plugin-util
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "@certd/plugin-util",
|
||||
"private": false,
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.6",
|
||||
"main": "./src/index.ts",
|
||||
"module": "./src/index.ts",
|
||||
"types": "./src/index.ts",
|
||||
@@ -21,7 +21,7 @@
|
||||
"shelljs": "^0.8.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@certd/pipeline": "^1.1.2",
|
||||
"@certd/pipeline": "^1.1.6",
|
||||
"@rollup/plugin-commonjs": "^23.0.4",
|
||||
"@rollup/plugin-json": "^6.0.0",
|
||||
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||
@@ -44,5 +44,5 @@
|
||||
"vite": "^3.1.0",
|
||||
"vue-tsc": "^0.38.9"
|
||||
},
|
||||
"gitHead": "5950e1cae7cf30ebfc5128c15c7d1b0d101cbbb8"
|
||||
"gitHead": "b258e926209fef4cc4d633b0383eb54e26c516f9"
|
||||
}
|
||||
|
||||
@@ -3,6 +3,29 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.6](https://github.com/certd/certd/compare/v1.1.5...v1.1.6) (2023-07-10)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-client
|
||||
|
||||
## [1.1.5](https://github.com/certd/certd/compare/v1.1.4...v1.1.5) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-client
|
||||
|
||||
## [1.1.4](https://github.com/certd/certd/compare/v1.1.3...v1.1.4) (2023-07-03)
|
||||
|
||||
### Bug Fixes
|
||||
|
||||
* 成功图标转动的问题 ([f87eee3](https://github.com/certd/certd/commit/f87eee3b9ff1ef9874e79a81fe0ed7104cb9ee8c))
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* cancel task ([bc65c0a](https://github.com/certd/certd/commit/bc65c0a786360c087fe95cad93ec6a87804cc5ee))
|
||||
* flush log ([891a43a](https://github.com/certd/certd/commit/891a43ae6716ff98ed06643f7da2e35199ee195c))
|
||||
|
||||
## [1.1.3](https://github.com/certd/certd/compare/v1.1.2...v1.1.3) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-client
|
||||
|
||||
## [1.1.2](https://github.com/certd/certd/compare/v1.1.1...v1.1.2) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-client
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/ui-client",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.6",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
@@ -22,7 +22,7 @@
|
||||
"dependencies": {
|
||||
"@ant-design/colors": "^6.0.0",
|
||||
"@ant-design/icons-vue": "^6.0.1",
|
||||
"@certd/acme-client": "^1.1.2",
|
||||
"@certd/acme-client": "^1.1.6",
|
||||
"@fast-crud/fast-crud": "^1.14.4",
|
||||
"@fast-crud/fast-extends": "^1.14.4",
|
||||
"@fast-crud/ui-antdv": "^1.14.4",
|
||||
@@ -59,7 +59,7 @@
|
||||
"vuedraggable": "^4.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@certd/pipeline": "^1.1.2",
|
||||
"@certd/pipeline": "^1.1.6",
|
||||
"@rollup/plugin-commonjs": "^23.0.4",
|
||||
"@rollup/plugin-node-resolve": "^15.0.1",
|
||||
"@types/chai": "^4.3.4",
|
||||
|
||||
@@ -67,6 +67,14 @@ export function Trigger(id: any) {
|
||||
});
|
||||
}
|
||||
|
||||
export function Cancel(historyId: any) {
|
||||
return request({
|
||||
url: apiPrefix + "/cancel",
|
||||
method: "post",
|
||||
params: { historyId }
|
||||
});
|
||||
}
|
||||
|
||||
export async function GetFiles(pipelineId: number) {
|
||||
return request({
|
||||
url: historyApiPrefix + "/files",
|
||||
|
||||
@@ -5,8 +5,9 @@
|
||||
</template>
|
||||
<p>
|
||||
<fs-date-format :model-value="runnable.status?.startTime"></fs-date-format>
|
||||
<a-tag class="ml-1" :color="status.color">{{ status.label }}</a-tag>
|
||||
|
||||
<a-tag class="ml-1" :color="status.color" :closable="status.value === 'start'" @close="cancelTask">
|
||||
{{ status.label }}
|
||||
</a-tag>
|
||||
<a-tag v-if="isCurrent" class="pointer" color="green" :closable="true" @close="cancel">当前</a-tag>
|
||||
<a-tag v-else-if="!editMode" class="pointer" color="blue" @click="view">查看</a-tag>
|
||||
</p>
|
||||
@@ -16,6 +17,8 @@
|
||||
<script lang="ts">
|
||||
import { defineComponent, ref, provide, Ref, watch, computed } from "vue";
|
||||
import { statusUtil } from "/@/views/certd/pipeline/pipeline/utils/util.status";
|
||||
import * as api from "../../api";
|
||||
import { Modal, notification } from "ant-design-vue";
|
||||
export default defineComponent({
|
||||
name: "PiHistoryTimelineItem",
|
||||
props: {
|
||||
@@ -38,7 +41,7 @@ export default defineComponent({
|
||||
}
|
||||
},
|
||||
emits: ["view", "cancel"],
|
||||
setup(props, ctx) {
|
||||
setup(props: any, ctx: any) {
|
||||
const status = computed(() => {
|
||||
return statusUtil.get(props.runnable?.status?.result);
|
||||
});
|
||||
@@ -49,10 +52,25 @@ export default defineComponent({
|
||||
function cancel() {
|
||||
ctx.emit("cancel");
|
||||
}
|
||||
function cancelTask() {
|
||||
Modal.confirm({
|
||||
title: "确认取消",
|
||||
content: "确认取消该任务吗?",
|
||||
okText: "确认",
|
||||
cancelText: "取消",
|
||||
onOk: async () => {
|
||||
await api.Cancel(props.runnable.id);
|
||||
notification.success({
|
||||
message: "任务取消成功"
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
return {
|
||||
status,
|
||||
cancel,
|
||||
view
|
||||
view,
|
||||
cancelTask
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</template>
|
||||
|
||||
<script lang="ts">
|
||||
import { inject, provide, Ref, ref } from "vue";
|
||||
import { computed, inject, Ref, ref } from "vue";
|
||||
import { RunHistory } from "../../type";
|
||||
import PiStatusShow from "/@/views/certd/pipeline/pipeline/component/status-show.vue";
|
||||
|
||||
@@ -55,7 +55,9 @@ export default {
|
||||
}
|
||||
for (let node of nodes) {
|
||||
if (currentHistory?.value?.logs != null) {
|
||||
node.logs = currentHistory.value.logs[node.node.id] || [];
|
||||
node.logs = computed(() => {
|
||||
return currentHistory.value.logs[node.node.id] || [];
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,7 +62,7 @@
|
||||
name: 'a-input',
|
||||
vModel: 'value'
|
||||
},
|
||||
helper: 'cron表达式,例如: * * 3 * * * ,表示每天凌晨3点触发',
|
||||
helper: 'cron表达式,例如: 0 0 3 * * * ,表示每天凌晨3点触发',
|
||||
rules: [{ required: true, message: '此项必填' }]
|
||||
}"
|
||||
/>
|
||||
|
||||
@@ -14,7 +14,7 @@ const StatusEnum: StatusEnumType = {
|
||||
value: "success",
|
||||
label: "成功",
|
||||
color: "green",
|
||||
spin: true,
|
||||
spin: false,
|
||||
icon: "ant-design:check-circle-outlined"
|
||||
},
|
||||
error: {
|
||||
|
||||
@@ -3,6 +3,26 @@
|
||||
All notable changes to this project will be documented in this file.
|
||||
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
||||
|
||||
## [1.1.6](https://github.com/fast-crud/fast-server-js/compare/v1.1.5...v1.1.6) (2023-07-10)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-server
|
||||
|
||||
## [1.1.5](https://github.com/fast-crud/fast-server-js/compare/v1.1.4...v1.1.5) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-server
|
||||
|
||||
## [1.1.4](https://github.com/fast-crud/fast-server-js/compare/v1.1.3...v1.1.4) (2023-07-03)
|
||||
|
||||
### Performance Improvements
|
||||
|
||||
* cancel task ([bc65c0a](https://github.com/fast-crud/fast-server-js/commit/bc65c0a786360c087fe95cad93ec6a87804cc5ee))
|
||||
* flush logger ([91be682](https://github.com/fast-crud/fast-server-js/commit/91be6826b902e0f302b1a6cbdb1d24e15914c18d))
|
||||
* timeout ([3eeb1f7](https://github.com/fast-crud/fast-server-js/commit/3eeb1f77aa2922f3545f3d2067f561d95621d54f))
|
||||
|
||||
## [1.1.3](https://github.com/fast-crud/fast-server-js/compare/v1.1.2...v1.1.3) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-server
|
||||
|
||||
## [1.1.2](https://github.com/fast-crud/fast-server-js/compare/v1.1.1...v1.1.2) (2023-07-03)
|
||||
|
||||
**Note:** Version bump only for package @certd/ui-server
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@certd/ui-server",
|
||||
"version": "1.1.2",
|
||||
"version": "1.1.6",
|
||||
"description": "fast-server base midway",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
@@ -21,15 +21,15 @@
|
||||
"mig": "typeorm migration:create -n name"
|
||||
},
|
||||
"dependencies": {
|
||||
"@certd/acme-client": "^1.1.2",
|
||||
"@certd/pipeline": "^1.1.2",
|
||||
"@certd/plugin-aliyun": "^1.1.2",
|
||||
"@certd/plugin-all": "^1.1.2",
|
||||
"@certd/plugin-cert": "^1.1.2",
|
||||
"@certd/plugin-host": "^1.1.2",
|
||||
"@certd/plugin-huawei": "^1.1.2",
|
||||
"@certd/plugin-tencent": "^1.1.2",
|
||||
"@certd/plugin-util": "^1.1.2",
|
||||
"@certd/acme-client": "^1.1.6",
|
||||
"@certd/pipeline": "^1.1.6",
|
||||
"@certd/plugin-aliyun": "^1.1.6",
|
||||
"@certd/plugin-all": "^1.1.6",
|
||||
"@certd/plugin-cert": "^1.1.6",
|
||||
"@certd/plugin-host": "^1.1.6",
|
||||
"@certd/plugin-huawei": "^1.1.6",
|
||||
"@certd/plugin-tencent": "^1.1.6",
|
||||
"@certd/plugin-util": "^1.1.6",
|
||||
"@koa/cors": "^3.4.3",
|
||||
"@midwayjs/bootstrap": "^3.9.1",
|
||||
"@midwayjs/cache": "^3.9.0",
|
||||
|
||||
@@ -16,7 +16,7 @@ const development = {
|
||||
staticFile: {
|
||||
usePrecompiledGzip: true,
|
||||
buffer: true,
|
||||
maxAge: 60 * 60 * 24 * 30 * 1000,
|
||||
maxAge: 30 * 24 * 60 * 60 * 1000,
|
||||
gzip: true,
|
||||
dirs: {
|
||||
default: {
|
||||
|
||||
@@ -4,7 +4,7 @@ import _ from 'lodash';
|
||||
const yaml = require('js-yaml');
|
||||
const fs = require('fs');
|
||||
|
||||
function parseEnv() {
|
||||
function parseEnv(defaultConfig: any) {
|
||||
const config = {};
|
||||
for (const key in process.env) {
|
||||
let keyName = key;
|
||||
@@ -13,21 +13,30 @@ function parseEnv() {
|
||||
}
|
||||
keyName = keyName.replace('certd_', '');
|
||||
const configKey = keyName.replace('_', '.');
|
||||
_.set(config, configKey, process.env[key]);
|
||||
const oldValue = _.get(defaultConfig, configKey);
|
||||
let value: any = process.env[key];
|
||||
if (typeof oldValue === 'boolean') {
|
||||
value = value === 'true';
|
||||
} else if (Number.isInteger(oldValue)) {
|
||||
value = parseInt(value, 10);
|
||||
} else if (typeof oldValue === 'number') {
|
||||
value = parseFloat(value);
|
||||
}
|
||||
_.set(config, configKey, value);
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
||||
export function load(env = '') {
|
||||
export function load(config, env = '') {
|
||||
// Get document, or throw exception on error
|
||||
const yamlPath = path.join(process.cwd(), `.env.${env}.yaml`);
|
||||
const doc = yaml.load(fs.readFileSync(yamlPath, 'utf8'));
|
||||
_.merge(doc, parseEnv());
|
||||
_.merge(doc, parseEnv(config));
|
||||
return doc;
|
||||
}
|
||||
|
||||
export function mergeConfig(config: any, envType: string) {
|
||||
_.merge(config, load(envType));
|
||||
_.merge(config, load(config, envType));
|
||||
const keys = _.get(config, 'auth.jwt.secret');
|
||||
if (keys) {
|
||||
config.keys = keys;
|
||||
|
||||
@@ -16,7 +16,6 @@ import { AuthorityMiddleware } from './middleware/authority';
|
||||
import * as staticFile from '@midwayjs/static-file';
|
||||
import * as cron from './plugins/cron';
|
||||
import { logger } from './utils/logger';
|
||||
|
||||
@Configuration({
|
||||
imports: [koa, orm, cache, flyway, validateComp, cron, staticFile],
|
||||
importConfigs: [
|
||||
|
||||
@@ -11,6 +11,7 @@ import { CrudController } from '../../../basic/crud-controller';
|
||||
import { PipelineService } from '../service/pipeline-service';
|
||||
import { PipelineEntity } from '../entity/pipeline';
|
||||
import { Constants } from '../../../basic/constants';
|
||||
import { HistoryService } from '../service/history-service';
|
||||
|
||||
/**
|
||||
* 证书
|
||||
@@ -20,6 +21,8 @@ import { Constants } from '../../../basic/constants';
|
||||
export class PipelineController extends CrudController<PipelineService> {
|
||||
@Inject()
|
||||
service: PipelineService;
|
||||
@Inject()
|
||||
historyService: HistoryService;
|
||||
|
||||
getService() {
|
||||
return this.service;
|
||||
@@ -77,4 +80,11 @@ export class PipelineController extends CrudController<PipelineService> {
|
||||
await this.service.trigger(id);
|
||||
return this.ok({});
|
||||
}
|
||||
|
||||
@Post('/cancel', { summary: Constants.per.authOnly })
|
||||
async cancel(@Query('historyId') historyId) {
|
||||
await this.historyService.checkUserId(historyId, this.ctx.user.id);
|
||||
await this.service.cancel(historyId);
|
||||
return this.ok({});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ import { In, Repository } from 'typeorm';
|
||||
import { BaseService } from '../../../basic/base-service';
|
||||
import { PipelineEntity } from '../entity/pipeline';
|
||||
import { PipelineDetail } from '../entity/vo/pipeline-detail';
|
||||
import { Executor, Pipeline, RunHistory } from '@certd/pipeline';
|
||||
import { Executor, Pipeline, ResultType, RunHistory } from '@certd/pipeline';
|
||||
import { AccessService } from './access-service';
|
||||
import { DbStorage } from './db-storage';
|
||||
import { StorageService } from './storage-service';
|
||||
@@ -16,6 +16,8 @@ import { HistoryLogService } from './history-log-service';
|
||||
import { logger } from '../../../utils/logger';
|
||||
import { EmailService } from '../../basic/service/email-service';
|
||||
|
||||
const runningTasks: Map<string | number, Executor> = new Map();
|
||||
|
||||
/**
|
||||
* 证书申请
|
||||
*/
|
||||
@@ -178,7 +180,7 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
});
|
||||
}
|
||||
|
||||
async run(id, triggerId) {
|
||||
async run(id: number, triggerId: string) {
|
||||
const entity: PipelineEntity = await this.info(id);
|
||||
const pipeline = JSON.parse(entity.content);
|
||||
|
||||
@@ -219,11 +221,27 @@ export class PipelineService extends BaseService<PipelineEntity> {
|
||||
fileRootDir: this.certdConfig.fileRootDir,
|
||||
});
|
||||
try {
|
||||
runningTasks.set(historyId, executor);
|
||||
await executor.init();
|
||||
await executor.run(historyId, triggerType);
|
||||
} catch (e) {
|
||||
logger.error('执行失败:', e);
|
||||
throw e;
|
||||
} finally {
|
||||
runningTasks.delete(historyId);
|
||||
}
|
||||
}
|
||||
|
||||
async cancel(historyId: number) {
|
||||
const executor = runningTasks.get(historyId);
|
||||
if (executor) {
|
||||
await executor.cancel();
|
||||
} else {
|
||||
const entity = await this.historyService.info(historyId);
|
||||
const pipeline: Pipeline = JSON.parse(entity.pipeline);
|
||||
pipeline.status.status = ResultType.canceled;
|
||||
const runtime = new RunHistory(historyId, null, pipeline);
|
||||
await this.saveHistory(runtime);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
112
step.md
Normal file
@@ -0,0 +1,112 @@
|
||||
# Certd演示示例
|
||||
|
||||
本示例演示从创建证书申请任务到自动部署证书全流程
|
||||
|
||||
## 准备工作
|
||||
1. 已部署CertD服务(可官方Demo自助注册体验 https://certd.handsfree.work/ )
|
||||
2. 注册一个域名(支持阿里云万网、腾讯云DnsPod、华为云)
|
||||
3. 准备好以上DNS解析服务商的AccessKey 和 AccessSecret
|
||||
4. 证书要部署的目标(可选,单纯当成证书申请工具用也不错)
|
||||
|
||||
## 自动化流水线创建
|
||||
|
||||
### 1. 创建证书申请部署流水线
|
||||

|
||||
|
||||
需要添加域名的DNS解析服务商的授权
|
||||

|
||||
|
||||
填写accessKey和accessSecret
|
||||

|
||||
流水线创建成功
|
||||

|
||||
|
||||
### 2. 任务详情界面
|
||||
|
||||

|
||||
|
||||
到这一步申请证书就已经配置完成了。
|
||||
点击手动触发,就可以申请证书了。
|
||||
|
||||
接下来演示如何添加部署任务
|
||||
|
||||
### 3. 添加部署到阿里云CDN任务
|
||||
点击添加任务
|
||||

|
||||
|
||||
选择任务类型
|
||||

|
||||
|
||||
填写任务参数
|
||||

|
||||
|
||||
点击确定,部署到CDN任务配置成功
|
||||
|
||||
### 4. 添加部署到服务器主机任务
|
||||
点击新任务,弹出添加任务界面
|
||||

|
||||
先选择上传到主机任务
|
||||
|
||||
填写任务参数,比如证书保存路径
|
||||

|
||||
|
||||
需要添加主机ip、用户名、密码,只需添加一次,后续其他任务可以复用
|
||||

|
||||
|
||||
然后添加第二个任务,执行主机命令,部署证书
|
||||

|
||||
|
||||
选择执行脚本命令任务
|
||||

|
||||
|
||||
编写脚本,选择之前添加的主机
|
||||

|
||||
|
||||
点击确定,部署到主机任务配置成功
|
||||

|
||||
|
||||
### 5. 手动触发执行任务,测试一下
|
||||

|
||||
|
||||
点击任务可以查看状态和日志
|
||||

|
||||
|
||||
这里执行失败,可以查看错误日志
|
||||

|
||||

|
||||
|
||||
修改正确后,重新执行
|
||||

|
||||
可以看到前面执行过的就会跳过,不会重复执行
|
||||

|
||||
|
||||
### 6. 查看证书部署效果
|
||||
可以看到证书已经部署到CDN成功
|
||||

|
||||

|
||||
也可以手动下载证书
|
||||

|
||||
|
||||
### 7. 定时触发
|
||||
配置定时触发,以后每天定时执行
|
||||
cron格式,例如: `0 0 3 * * *` 表示每天凌晨3点执行
|
||||
到期前20天会自动申请新证书并部署,没到期前不会重复申请
|
||||

|
||||
|
||||
### 8. 邮件通知
|
||||
可以接收邮件通知(支持时机:开始、成功、失败、失败转成功)
|
||||

|
||||
需要配置邮件服务器
|
||||

|
||||
|
||||
|
||||
|
||||
|
||||
以上,演示了从创建证书申请任务到自动部署证书全流程。
|
||||
|
||||
如有疑问,欢迎加入群聊(请备注certd)
|
||||
* QQ群:141236433
|
||||
* 微信群:
|
||||

|
||||
|
||||
|
||||