Merge remote-tracking branch 'origin/v2' into v2

# Conflicts:
#	packages/ui/certd-server/src/plugins/plugin-other/plugins/index.ts
This commit is contained in:
xiaojunnuo
2024-09-16 15:52:35 +08:00
59 changed files with 618 additions and 179 deletions
+1 -1
View File
@@ -8,7 +8,7 @@ RUN npm install -g pnpm@8.15.7
#RUN cd /workspace/certd-client && pnpm install && npm run build
RUN cp /workspace/certd-client/dist/* /workspace/certd-server/public/ -rf
RUN cd /workspace/certd-server && yarn install && npm run build-on-docker
RUN cd /workspace/certd-server && pnpm install && npm run build-on-docker
FROM node:18-alpine
+6
View File
@@ -3,6 +3,12 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.24.4](https://github.com/certd/certd/compare/v1.24.3...v1.24.4) (2024-09-09)
### Performance Improvements
* 插件选择支持搜索 ([d1498a7](https://github.com/certd/certd/commit/d1498a71601b74d38343b1d070eadd03705dd9d5))
## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06)
**Note:** Version bump only for package @certd/ui-client
+2 -2
View File
@@ -1,6 +1,6 @@
{
"name": "@certd/ui-client",
"version": "1.24.3",
"version": "1.24.4",
"private": true,
"scripts": {
"dev": "vite --open",
@@ -58,7 +58,7 @@
"vuedraggable": "^4.1.0"
},
"devDependencies": {
"@certd/pipeline": "^1.24.3",
"@certd/pipeline": "^1.24.4",
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@types/chai": "^4.3.12",
@@ -143,6 +143,7 @@ function openUpgrade() {
<div class="flex-o w-100">
<span>站点ID</span>
<fs-copyable class="flex-1" v-model={computedSiteId.value}></fs-copyable>
<div>注意保存好数据库暂不支持换绑默认数据库路径/data/certd/db.sqlite</div>
</div>
<a-input class="mt-10" v-model:value={formState.code} placeholder={placeholder} />
</div>
@@ -68,6 +68,17 @@ h1, h2, h3, h4, h5, h6 {
flex: 1;
}
.flex-col{
display: flex;
flex-direction: column;
}
.scroll-y{
overflow-y: auto;
}
.mb-2 {
margin-bottom: 2px;
}
@@ -137,6 +148,13 @@ h1, h2, h3, h4, h5, h6 {
.w-100 {
width: 100%;
}
.h-100 {
height: 100%;
}
.overflow-hidden {
overflow: hidden;
}
.block-header {
margin: 3px;
@@ -166,3 +184,17 @@ h1, h2, h3, h4, h5, h6 {
.need-plus {
color: #c5913f !important;
}
.deleted{
color: #c7c7c7;
//删除线
text-decoration: line-through;
}
.cursor-move{
cursor: move !important;
}
.cursor-pointer{
cursor: pointer;
}
@@ -8,43 +8,61 @@
</template>
<template v-if="currentStep">
<pi-container v-if="currentStep._isAdd" class="pi-step-form">
<a-tabs tab-position="left">
<a-tab-pane v-for="group of pluginGroups.groups" :key="group.key" :tab="group.title">
<a-row :gutter="10">
<a-col v-for="item of group.plugins" :key="item.key" class="step-plugin" :span="12">
<a-card
hoverable
:class="{ current: item.name === currentStep.type }"
@click="stepTypeSelected(item)"
@dblclick="
stepTypeSelected(item);
stepTypeSave();
"
>
<a-card-meta>
<template #title>
<a-avatar :src="item.icon || '/images/plugin.png'" />
<span class="title">{{ item.title }}</span>
<vip-button v-if="item.needPlus" mode="icon" />
</template>
<template #description>
<span :title="item.desc">{{ item.desc }}</span>
</template>
</a-card-meta>
</a-card>
</a-col>
</a-row>
</a-tab-pane>
</a-tabs>
<div style="padding: 20px; margin-left: 100px">
<a-button v-if="editMode" type="primary" @click="stepTypeSave"> 确定 </a-button>
<template #header>
<a-row :gutter="10" class="mb-10">
<a-col :span="24" style="padding-left: 20px">
<a-input-search v-model:value="pluginSearch.keyword" placeholder="搜索插件" :allow-clear="true" :show-search="true"></a-input-search>
</a-col>
</a-row>
</template>
<div class="flex-col h-100 w-100 overflow-hidden">
<a-tabs v-model:active-key="pluginGroupActive" tab-position="left" class="flex-1 overflow-hidden">
<a-tab-pane v-for="group of computedPluginGroups" :key="group.key" :tab="group.title" class="scroll-y">
<a-row v-if="!group.plugins || group.plugins.length === 0" :gutter="10">
<a-col class="flex-o">
<div class="flex-o m-10">没有找到插件</div>
</a-col>
</a-row>
<a-row v-else :gutter="10">
<a-col v-for="item of group.plugins" :key="item.key" class="step-plugin" :span="12">
<a-card
hoverable
:class="{ current: item.name === currentStep.type }"
@click="stepTypeSelected(item)"
@dblclick="
stepTypeSelected(item);
stepTypeSave();
"
>
<a-card-meta>
<template #title>
<a-avatar :src="item.icon || '/images/plugin.png'" />
<span class="title">{{ item.title }}</span>
<vip-button v-if="item.needPlus" mode="icon" />
</template>
<template #description>
<span :title="item.desc">{{ item.desc }}</span>
</template>
</a-card-meta>
</a-card>
</a-col>
</a-row>
</a-tab-pane>
</a-tabs>
</div>
<template #footer>
<div style="padding: 20px; margin-left: 100px">
<a-button v-if="editMode" type="primary" @click="stepTypeSave"> 确定 </a-button>
</div>
</template>
</pi-container>
<pi-container v-else class="pi-step-form">
<a-form ref="stepFormRef" class="step-form" :model="currentStep" :label-col="labelCol" :wrapper-col="wrapperCol">
<template #header>
<div class="mb-10">
<a-alert type="info" :message="currentPlugin.title" :description="currentPlugin.desc"> </a-alert>
</div>
</template>
<a-form ref="stepFormRef" class="step-form" :model="currentStep" :label-col="labelCol" :wrapper-col="wrapperCol">
<fs-form-item
v-model="currentStep.title"
:item="{
@@ -66,9 +84,9 @@
</a-form>
<template #footer>
<a-form-item v-if="editMode" :wrapper-col="{ span: 14, offset: 4 }">
<div v-if="editMode" class="bottom-button">
<a-button type="primary" @click="stepSave"> 确定 </a-button>
</a-form-item>
</div>
</template>
</pi-container>
</template>
@@ -77,7 +95,7 @@
<script lang="tsx">
import { message, Modal } from "ant-design-vue";
import { computed, inject, Ref, ref } from "vue";
import { computed, inject, Ref, ref, watch } from "vue";
import _ from "lodash-es";
import { nanoid } from "nanoid";
import { CopyOutlined } from "@ant-design/icons-vue";
@@ -263,7 +281,45 @@ export default {
const blankFn = () => {
return {};
};
const pluginSearch = ref({
keyword: "",
result: []
});
const pluginGroupActive = ref("all");
const computedPluginGroups: any = computed(() => {
const groups = pluginGroups.groups;
if (pluginSearch.value.keyword) {
const keyword = pluginSearch.value.keyword.toLowerCase();
const list = groups.all.plugins.filter((plugin) => {
return (
plugin.title?.toLowerCase().includes(keyword) || plugin.desc?.toLowerCase().includes(keyword) || plugin.name?.toLowerCase().includes(keyword)
);
});
return {
search: { key: "search", title: "搜索结果", plugins: list }
};
} else {
return groups;
}
});
watch(
() => {
return pluginSearch.value.keyword;
},
(val: any) => {
if (val) {
pluginGroupActive.value = "search";
} else {
pluginGroupActive.value = "all";
}
}
);
return {
pluginGroupActive,
computedPluginGroups,
pluginSearch,
stepTypeSelected,
stepTypeSave,
pluginGroups,
@@ -321,8 +377,23 @@ export default {
<style lang="less">
.pi-step-form {
.bottom-button {
padding: 20px;
padding-bottom: 5px;
margin-left: 100px;
}
.body {
padding: 10px;
padding: 0px;
.ant-tabs-content {
height: 100%;
}
.ant-tabs-tabpane {
padding-right: 10px;
overflow-y: auto;
overflow-x: hidden;
}
.ant-card {
margin-bottom: 10px;
@@ -48,13 +48,14 @@
<div class="step-row">
<div class="text">
<fs-icon icon="ion:flash"></fs-icon>
<h4 class="title">{{ element.title }}</h4>
<h4 class="title" :class="{ disabled: element.disabled, deleted: element.disabled }">{{ element.title }}</h4>
</div>
<div class="action">
<a key="edit" @click="stepEdit(currentTask, element, index)">编辑</a>
<a key="edit" @click="stepCopy(currentTask, element, index)">复制</a>
<a key="remove" @click="stepDelete(currentTask, index)">删除</a>
<fs-icon v-plus class="icon-button handle" title="拖动排序" icon="ion:move-outline"></fs-icon>
<a key="disabled" @click="element.disabled = !!!element.disabled">{{ element.disabled ? "启用" : "禁用" }}</a>
<fs-icon v-plus class="icon-button handle cursor-move" title="拖动排序" icon="ion:move-outline"></fs-icon>
</div>
</div>
</template>
@@ -94,7 +94,9 @@
<!-- :open="true"-->
<template #content>
<div v-for="(item, index) of task.steps" class="flex-o w-100">
<span class="ellipsis flex-1">{{ index + 1 }}. {{ item.title }} </span>
<span class="ellipsis flex-1 step-title" :class="{ disabled: item.disabled, deleted: item.disabled }">
{{ index + 1 }}. {{ item.title }}
</span>
<pi-status-show v-if="!editMode" :status="item.status?.result"></pi-status-show>
<fs-icon
v-if="!editMode"
@@ -346,14 +348,23 @@ export default defineComponent({
}
const intervalLoadHistoryRef = ref();
function watchNewHistoryList() {
intervalLoadHistoryRef.value = setInterval(async () => {
if (currentHistory.value == null) {
await loadHistoryList();
} else if (currentHistory.value.pipeline?.status?.status === "start") {
await loadCurrentHistoryDetail();
} else {
clearInterval(intervalLoadHistoryRef.value);
intervalLoadHistoryRef.value = setTimeout(async () => {
try {
if (currentHistory.value == null) {
await loadHistoryList();
}
if (currentHistory.value != null) {
if (currentHistory.value.pipeline?.status?.status === "start") {
await loadCurrentHistoryDetail();
} else {
return;
}
}
} catch (e) {
console.error(e);
}
watchNewHistoryList();
}, 3000);
}
@@ -603,6 +614,9 @@ export default defineComponent({
saveLoading.value = true;
try {
if (props.options.doSave) {
if (pipeline.value.version == null) {
pipeline.value.version = 0;
}
pipeline.value.version++;
currentPipeline.value = pipeline.value;
await props.options.doSave(pipeline.value);
@@ -48,6 +48,12 @@ const StatusEnum: StatusEnumType = {
label: "未运行",
color: "blue",
icon: "ant-design:minus-circle-twotone"
},
disabled: {
value: "disabled",
label: "禁用",
color: "gray",
icon: "ant-design:stop-outlined"
}
};
export const statusUtil = {
+11
View File
@@ -3,6 +3,17 @@
All notable changes to this project will be documented in this file.
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
## [1.24.4](https://github.com/certd/certd/compare/v1.24.3...v1.24.4) (2024-09-09)
### Bug Fixes
* 修复腾讯云cdn证书部署后会自动关闭hstshttp2.0等配置的bug ([7908ab7](https://github.com/certd/certd/commit/7908ab79da624c94fa05849925b15e480e3317c4))
* 修复腾讯云tke证书部署报错的bug ([653f409](https://github.com/certd/certd/commit/653f409d91a441850d6381f89a8dd390831f0d5e))
### Performance Improvements
* 支持群晖 ([5c270b6](https://github.com/certd/certd/commit/5c270b6b9d45a2152f9fdb3c07bd98b7c803cb8e))
## [1.24.3](https://github.com/certd/certd/compare/v1.24.2...v1.24.3) (2024-09-06)
### Performance Improvements
+12 -8
View File
@@ -1,6 +1,6 @@
{
"name": "@certd/ui-server",
"version": "1.24.3",
"version": "1.24.4",
"description": "fast-server base midway",
"private": true,
"type": "module",
@@ -16,18 +16,20 @@
"build": "mwtsc --cleanOutDir --skipLibCheck",
"build-on-docker": "node ./before-build.js && npm run build",
"up-mw-deps": "npx midway-version -u -w",
"clinic": "clinic heapprofiler -- node ./bootstrap.js"
"heap": "clinic heapprofiler -- node ./bootstrap.js",
"flame": "clinic flame -- node ./bootstrap.js"
},
"dependencies": {
"@alicloud/cs20151215": "^3.0.3",
"@alicloud/pop-core": "^1.7.10",
"@certd/acme-client": "^1.24.3",
"@certd/acme-client": "^1.24.4",
"@certd/lib-huawei": "^1.24.3",
"@certd/lib-k8s": "^1.24.3",
"@certd/midway-flyway-js": "^1.22.6",
"@certd/pipeline": "^1.24.3",
"@certd/plugin-cert": "^1.24.3",
"@certd/plugin-plus": "^1.24.3",
"@certd/lib-k8s": "^1.24.4",
"@certd/midway-flyway-js": "^1.24.4",
"@certd/pipeline": "^1.24.4",
"@certd/plugin-cert": "^1.24.4",
"@certd/plugin-plus": "^1.24.4",
"@koa/cors": "^5.0.0",
"@midwayjs/bootstrap": "^3.16.2",
"@midwayjs/cache": "^3.14.0",
@@ -47,6 +49,7 @@
"cache-manager": "^3.6.3",
"cron-parser": "^4.9.0",
"dayjs": "^1.11.7",
"form-data": "^4.0.0",
"glob": "^10.4.5",
"https-proxy-agent": "^7.0.5",
"iconv-lite": "^0.6.3",
@@ -67,6 +70,7 @@
"ssh2": "^1.15.0",
"strip-ansi": "^7.1.0",
"svg-captcha": "^1.4.0",
"syno": "^2.2.0",
"tencentcloud-sdk-nodejs": "^4.0.44",
"typeorm": "^0.3.20"
},
@@ -1,19 +1,19 @@
import crypto from 'crypto';
import querystring from 'querystring';
import { DogeCloudAccess } from '../access.js';
import { AxiosInstance } from 'axios';
import { HttpClient } from '@certd/pipeline';
export class DogeClient {
accessKey: string;
secretKey: string;
http: AxiosInstance;
constructor(access: DogeCloudAccess, http: AxiosInstance) {
http: HttpClient;
constructor(access: DogeCloudAccess, http: HttpClient) {
this.accessKey = access.accessKey;
this.secretKey = access.secretKey;
this.http = http;
}
async request(apiPath: string, data: any = {}, jsonMode = false) {
async request(apiPath: string, data: any = {}, jsonMode = false, ignoreResNullCode = false) {
// 这里替换为你的多吉云永久 AccessKey 和 SecretKey,可在用户中心 - 密钥管理中查看
// 请勿在客户端暴露 AccessKey 和 SecretKey,那样恶意用户将获得账号完全控制权
@@ -34,7 +34,9 @@ export class DogeClient {
},
});
if (res.code !== 200) {
if (res.code == null && ignoreResNullCode) {
//ignore
} else if (res.code !== 200) {
throw new Error('API Error: ' + res.msg);
}
return res.data;
@@ -44,6 +44,17 @@ export class DogeCloudDeployToCDNPlugin extends AbstractTaskPlugin {
})
accessId!: string;
@TaskInput({
title: '忽略部署接口报错',
helper: '当该域名部署后报错,但是实际上已经部署成功时,可以勾选',
value: false,
component: {
name: 'a-switch',
type: 'checked',
},
})
ignoreDeployNullCode = false;
dogeClient!: DogeClient;
async onInstance() {
@@ -66,10 +77,14 @@ export class DogeCloudDeployToCDNPlugin extends AbstractTaskPlugin {
}
async bindCert(certId: number) {
await this.dogeClient.request('/cdn/cert/bind.json', {
id: certId,
domain: this.domain,
});
await this.dogeClient.request(
'/cdn/cert/bind.json',
{
id: certId,
domain: this.domain,
},
this.ignoreDeployNullCode
);
}
}
new DogeCloudDeployToCDNPlugin();
@@ -1,2 +1,3 @@
export * from './plugin-k8s.js';
export * from './plugin-restart.js';
export * from './plugin-script.js';
@@ -6,6 +6,7 @@ import { appendTimeSuffix } from '../../plugin-aliyun/utils/index.js';
@IsTaskPlugin({
name: 'DeployToK8SIngress',
title: 'K8S Ingress证书部署',
desc: '暂不可用',
group: pluginGroups.other.key,
default: {
strategy: {
@@ -0,0 +1,58 @@
import { AbstractTaskPlugin, IsTaskPlugin, pluginGroups, RunStrategy, TaskInput, TaskInstanceContext } from '@certd/pipeline';
import { CertInfo, CertReader } from '@certd/plugin-cert';
export type CustomScriptContext = {
CertReader: typeof CertReader;
self: CustomScriptPlugin;
} & TaskInstanceContext;
@IsTaskPlugin({
name: 'CustomScript',
title: '自定义js脚本',
desc: '测试',
group: pluginGroups.other.key,
default: {
strategy: {
runStrategy: RunStrategy.SkipWhenSucceed,
},
},
})
export class CustomScriptPlugin extends AbstractTaskPlugin {
@TaskInput({
title: '脚本',
helper: '自定义js脚本',
component: {
name: 'a-textarea',
vModel: 'value',
rows: 10,
style: 'background-color: #000c17;color: #fafafa;',
},
required: true,
})
script!: string;
@TaskInput({
title: '域名证书',
helper: '请选择前置任务输出的域名证书',
component: {
name: 'pi-output-selector',
from: 'CertApply',
},
required: true,
})
cert!: CertInfo;
async onInstance() {}
async execute(): Promise<void> {
this.logger.info('执行自定义脚本:\n', this.script);
const ctx: CustomScriptContext = {
CertReader,
self: this,
...this.ctx,
};
const AsyncFunction = Object.getPrototypeOf(async () => {}).constructor;
const func = new AsyncFunction('ctx', this.script);
return await func(ctx);
}
}
new CustomScriptPlugin();
@@ -93,20 +93,20 @@ export class DeployToCdnPlugin extends AbstractTaskPlugin {
buildParams() {
return {
Https: {
Switch: 'on',
CertInfo: {
Domain: this.domainName,
Route: 'Https.CertInfo',
Value: JSON.stringify({
update: {
Certificate: this.cert.crt,
PrivateKey: this.cert.key,
},
},
Domain: this.domainName,
}),
};
}
async doRequest(params: any) {
const client = await this.getClient();
const ret = await client.UpdateDomainConfig(params);
const ret = await client.ModifyDomainConfig(params);
this.checkRet(ret);
this.logger.info('设置腾讯云CDN证书成功:', ret.RequestId);
return ret.RequestId;
@@ -6,7 +6,7 @@ import dayjs from 'dayjs';
name: 'DeployCertToTencentCLB',
title: '部署到腾讯云CLB',
group: pluginGroups.tencent.key,
desc: '暂时只支持单向认证证书,暂时只支持通用负载均衡',
desc: '暂时只支持单向认证证书,暂时只支持通用负载均衡,必须开启sni',
default: {
strategy: {
runStrategy: RunStrategy.SkipWhenSucceed,
@@ -93,14 +93,13 @@ export class DeployToClbPlugin extends AbstractTaskPlugin {
accessId!: string;
client: any;
ClbClient: any;
async onInstance() {
this.client = await this.getClient();
}
async getClient() {
const sdk = await import('tencentcloud-sdk-nodejs/tencentcloud/services/clb/v20180317/index.js');
this.ClbClient = sdk.v20180317.Client;
const ClbClient = sdk.v20180317.Client;
const accessProvider = (await this.accessService.getById(this.accessId)) as TencentAccess;
@@ -118,7 +117,7 @@ export class DeployToClbPlugin extends AbstractTaskPlugin {
},
};
return new this.ClbClient(clientConfig);
return new ClbClient(clientConfig);
}
async execute(): Promise<void> {
@@ -38,6 +38,7 @@ export class DeployToEOPlugin extends AbstractTaskPlugin {
@TaskInput({
title: '站点ID',
helper: '类似于zone-xxxx的字符串,在站点概览页面左上角,或者,站点列表页面站点名称下方',
required: true,
})
zoneId!: string;
@@ -89,19 +89,16 @@ export class DeployCertToTencentTKEIngressPlugin extends AbstractTaskPlugin {
})
cert!: any;
TkeClient: any;
K8sClient: any;
async onInstance() {
// const TkeClient = this.tencentcloud.tke.v20180525.Client;
const sdk = await import('tencentcloud-sdk-nodejs/tencentcloud/services/tke/v20220501/index.js');
this.TkeClient = sdk.v20220501.Client;
const k8sSdk = await import('@certd/lib-k8s');
this.K8sClient = k8sSdk.K8sClient;
}
async execute(): Promise<void> {
const accessProvider = await this.accessService.getById(this.accessId);
const tkeClient = this.getTkeClient(accessProvider, this.region);
const tkeClient = await this.getTkeClient(accessProvider, this.region);
const kubeConfigStr = await this.getTkeKubeConfig(tkeClient, this.clusterId);
this.logger.info('kubeconfig已成功获取');
@@ -127,7 +124,9 @@ export class DeployCertToTencentTKEIngressPlugin extends AbstractTaskPlugin {
await this.restartIngress({ k8sClient });
}
getTkeClient(accessProvider: any, region = 'ap-guangzhou') {
async getTkeClient(accessProvider: any, region = 'ap-guangzhou') {
const sdk = await import('tencentcloud-sdk-nodejs/tencentcloud/services/tke/v20180525/index.js');
const TkeClient = sdk.v20180525.Client;
const clientConfig = {
credential: {
secretId: accessProvider.secretId,
@@ -141,7 +140,7 @@ export class DeployCertToTencentTKEIngressPlugin extends AbstractTaskPlugin {
},
};
return new this.TkeClient(clientConfig);
return new TkeClient(clientConfig);
}
async getTkeKubeConfig(client: any, clusterId: string) {
+1 -1
View File
@@ -2,7 +2,7 @@ import { utils } from '@certd/pipeline';
export async function request(config: any): Promise<any> {
try {
return await utils.http(config);
return await utils.http.request(config);
} catch (e) {
const data = e.data || e.response?.data;
if (data) {
+1 -1
View File
@@ -9,4 +9,4 @@ log4js.configure({
},
categories: { default: { appenders: ['std'], level } },
});
export const logger = log4js.getLogger('fast');
export const logger = log4js.getLogger('server');