feat: add safeline deployer

This commit is contained in:
Fu Diwei
2025-02-17 16:48:33 +08:00
parent a40b078e9c
commit c72dc0d2c4
30 changed files with 586 additions and 77 deletions

View File

@@ -0,0 +1 @@
<svg class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" width="200" height="200"><path d="M461.750857 72.850286l-325.193143 282.331428L378.148571 580.096h125.659429L266.24 358.4 512 153.526857l289.645714 246.418286v69.339428l86.162286 56.685715V357.888L562.761143 74.532571 466.358857 72.850286z" fill="#45495A"></path><path d="M542.646857 446.317714h-22.820571l239.177143 222.354286-243.565715 209.334857-295.862857-246.710857V553.398857l-83.382857-53.394286v163.108572l336.457143 288.036571h90.331428l320.804572-282.404571-242.102857-222.427429z" fill="#45495A"></path></svg>

View File

@@ -31,6 +31,7 @@ import AccessFormNS1Config from "./AccessFormNS1Config";
import AccessFormPowerDNSConfig from "./AccessFormPowerDNSConfig";
import AccessFormQiniuConfig from "./AccessFormQiniuConfig";
import AccessFormRainYunConfig from "./AccessFormRainYunConfig";
import AccessFormSafeLineConfig from "./AccessFormSafeLineConfig";
import AccessFormSSHConfig from "./AccessFormSSHConfig";
import AccessFormTencentCloudConfig from "./AccessFormTencentCloudConfig";
import AccessFormUCloudConfig from "./AccessFormUCloudConfig";
@@ -134,6 +135,8 @@ const AccessForm = forwardRef<AccessFormInstance, AccessFormProps>(({ className,
return <AccessFormQiniuConfig {...nestedFormProps} />;
case ACCESS_PROVIDERS.RAINYUN:
return <AccessFormRainYunConfig {...nestedFormProps} />;
case ACCESS_PROVIDERS.SAFELINE:
return <AccessFormSafeLineConfig {...nestedFormProps} />;
case ACCESS_PROVIDERS.SSH:
return <AccessFormSSHConfig {...nestedFormProps} />;
case ACCESS_PROVIDERS.TENCENTCLOUD:

View File

@@ -17,7 +17,7 @@ export type AccessFormBaotaPanelConfigProps = {
const initFormModel = (): AccessFormBaotaPanelConfigFieldValues => {
return {
apiUrl: "",
apiUrl: "http://<your-ipaddr>:8888/",
apiKey: "",
};
};

View File

@@ -17,7 +17,7 @@ export type AccessFormPowerDNSConfigProps = {
const initFormModel = (): AccessFormPowerDNSConfigFieldValues => {
return {
apiUrl: "",
apiUrl: "http://<your-ipaddr>:8082/",
apiKey: "",
};
};

View File

@@ -0,0 +1,72 @@
import { useTranslation } from "react-i18next";
import { Form, type FormInstance, Input } from "antd";
import { createSchemaFieldRule } from "antd-zod";
import { z } from "zod";
import { type AccessConfigForSafeLine } from "@/domain/access";
type AccessFormSafeLineConfigFieldValues = Nullish<AccessConfigForSafeLine>;
export type AccessFormSafeLineConfigProps = {
form: FormInstance;
formName: string;
disabled?: boolean;
initialValues?: AccessFormSafeLineConfigFieldValues;
onValuesChange?: (values: AccessFormSafeLineConfigFieldValues) => void;
};
const initFormModel = (): AccessFormSafeLineConfigFieldValues => {
return {
apiUrl: "http://<your-ipaddr>:9443/",
apiToken: "",
};
};
const AccessFormSafeLineConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: AccessFormSafeLineConfigProps) => {
const { t } = useTranslation();
const formSchema = z.object({
apiUrl: z.string().url(t("common.errmsg.url_invalid")),
apiToken: z
.string()
.min(1, t("access.form.safeline_api_token.placeholder"))
.max(64, t("common.errmsg.string_max", { max: 64 }))
.trim(),
});
const formRule = createSchemaFieldRule(formSchema);
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
onValuesChange?.(values);
};
return (
<Form
form={formInst}
disabled={disabled}
initialValues={initialValues ?? initFormModel()}
layout="vertical"
name={formName}
onValuesChange={handleFormChange}
>
<Form.Item
name="apiUrl"
label={t("access.form.safeline_api_url.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.safeline_api_url.tooltip") }}></span>}
>
<Input placeholder={t("access.form.safeline_api_url.placeholder")} />
</Form.Item>
<Form.Item
name="apiToken"
label={t("access.form.safeline_api_token.label")}
rules={[formRule]}
tooltip={<span dangerouslySetInnerHTML={{ __html: t("access.form.safeline_api_token.tooltip") }}></span>}
>
<Input.Password autoComplete="new-password" placeholder={t("access.form.safeline_api_token.placeholder")} />
</Form.Item>
</Form>
);
};
export default AccessFormSafeLineConfig;

View File

@@ -47,12 +47,18 @@ const AccessProviderSelect = (props: AccessProviderSelectProps) => {
return (
<Select
{...props}
filterOption={(inputValue, option) => {
if (!option) return false;
const value = inputValue.toLowerCase();
return option.value.toLowerCase().includes(value) || option.label.toLowerCase().includes(value);
}}
labelRender={({ label, value }) => {
if (label) {
return renderOption(value as string);
if (!label) {
return <Typography.Text type="secondary">{props.placeholder}</Typography.Text>;
}
return <Typography.Text type="secondary">{props.placeholder}</Typography.Text>;
return renderOption(value as string);
}}
options={options}
optionFilterProp={undefined}

View File

@@ -33,12 +33,18 @@ const ApplyDNSProviderSelect = (props: ApplyDNSProviderSelectProps) => {
return (
<Select
{...props}
filterOption={(inputValue, option) => {
if (!option) return false;
const value = inputValue.toLowerCase();
return option.value.toLowerCase().includes(value) || option.label.toLowerCase().includes(value);
}}
labelRender={({ label, value }) => {
if (label) {
return renderOption(value as string);
if (!label) {
return <Typography.Text type="secondary">{props.placeholder}</Typography.Text>;
}
return <Typography.Text type="secondary">{props.placeholder}</Typography.Text>;
return renderOption(value as string);
}}
options={options}
optionFilterProp={undefined}

View File

@@ -33,12 +33,18 @@ const DeployProviderSelect = (props: DeployProviderSelectProps) => {
return (
<Select
{...props}
filterOption={(inputValue, option) => {
if (!option) return false;
const value = inputValue.toLowerCase();
return option.value.toLowerCase().includes(value) || option.label.toLowerCase().includes(value);
}}
labelRender={({ label, value }) => {
if (label) {
return renderOption(value as string);
if (!label) {
return <Typography.Text type="secondary">{props.placeholder}</Typography.Text>;
}
return <Typography.Text type="secondary">{props.placeholder}</Typography.Text>;
return renderOption(value as string);
}}
options={options}
optionFilterProp={undefined}

View File

@@ -39,6 +39,7 @@ import DeployNodeConfigFormKubernetesSecretConfig from "./DeployNodeConfigFormKu
import DeployNodeConfigFormLocalConfig from "./DeployNodeConfigFormLocalConfig";
import DeployNodeConfigFormQiniuCDNConfig from "./DeployNodeConfigFormQiniuCDNConfig";
import DeployNodeConfigFormQiniuPiliConfig from "./DeployNodeConfigFormQiniuPiliConfig";
import DeployNodeConfigFormSafeLineConfig from "./DeployNodeConfigFormSafeLineConfig";
import DeployNodeConfigFormSSHConfig from "./DeployNodeConfigFormSSHConfig.tsx";
import DeployNodeConfigFormTencentCloudCDNConfig from "./DeployNodeConfigFormTencentCloudCDNConfig.tsx";
import DeployNodeConfigFormTencentCloudCLBConfig from "./DeployNodeConfigFormTencentCloudCLBConfig.tsx";
@@ -104,7 +105,7 @@ const DeployNodeConfigForm = forwardRef<DeployNodeConfigFormInstance, DeployNode
.nonempty(t("workflow_node.deploy.form.provider_access.placeholder"))
.refine(() => !!formInst.getFieldValue("provider"), t("workflow_node.deploy.form.provider.placeholder")),
providerConfig: z.any(),
skipOnLastSucceeded: z.boolean(),
skipOnLastSucceeded: z.boolean().nullish(),
});
const formRule = createSchemaFieldRule(formSchema);
const { form: formInst, formProps } = useAntdForm({
@@ -177,6 +178,8 @@ const DeployNodeConfigForm = forwardRef<DeployNodeConfigFormInstance, DeployNode
return <DeployNodeConfigFormQiniuCDNConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.QINIU_PILI:
return <DeployNodeConfigFormQiniuPiliConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.SAFELINE:
return <DeployNodeConfigFormSafeLineConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.SSH:
return <DeployNodeConfigFormSSHConfig {...nestedFormProps} />;
case DEPLOY_PROVIDERS.TENCENTCLOUD_CDN:

View File

@@ -0,0 +1,85 @@
import { useTranslation } from "react-i18next";
import { Form, type FormInstance, Input, Select } from "antd";
import { createSchemaFieldRule } from "antd-zod";
import { z } from "zod";
import Show from "@/components/Show";
type DeployNodeConfigFormSafeLineConfigFieldValues = Nullish<{
resourceType: string;
certificateId?: string;
}>;
export type DeployNodeConfigFormSafeLineConfigProps = {
form: FormInstance;
formName: string;
disabled?: boolean;
initialValues?: DeployNodeConfigFormSafeLineConfigFieldValues;
onValuesChange?: (values: DeployNodeConfigFormSafeLineConfigFieldValues) => void;
};
const RESOURCE_TYPE_CERTIFICATE = "certificate" as const;
const initFormModel = (): DeployNodeConfigFormSafeLineConfigFieldValues => {
return {
resourceType: RESOURCE_TYPE_CERTIFICATE,
certificateId: "",
};
};
const DeployNodeConfigFormSafeLineConfig = ({ form: formInst, formName, disabled, initialValues, onValuesChange }: DeployNodeConfigFormSafeLineConfigProps) => {
const { t } = useTranslation();
const formSchema = z.object({
resourceType: z.literal(RESOURCE_TYPE_CERTIFICATE, {
message: t("workflow_node.deploy.form.safeline_resource_type.placeholder"),
}),
region: z
.string({ message: t("workflow_node.deploy.form.safeline_region.placeholder") })
.nonempty(t("workflow_node.deploy.form.safeline_region.placeholder"))
.trim(),
certificateId: z
.string()
.max(64, t("common.errmsg.string_max", { max: 64 }))
.trim()
.nullish()
.refine((v) => {
if (fieldResourceType !== RESOURCE_TYPE_CERTIFICATE) return true;
return /^\d+$/.test(v!);
}, t("workflow_node.deploy.form.safeline_certificate_id.placeholder")),
});
const formRule = createSchemaFieldRule(formSchema);
const fieldResourceType = Form.useWatch("resourceType", formInst);
const handleFormChange = (_: unknown, values: z.infer<typeof formSchema>) => {
onValuesChange?.(values);
};
return (
<Form
form={formInst}
disabled={disabled}
initialValues={initialValues ?? initFormModel()}
layout="vertical"
name={formName}
onValuesChange={handleFormChange}
>
<Form.Item name="resourceType" label={t("workflow_node.deploy.form.safeline_resource_type.label")} rules={[formRule]}>
<Select placeholder={t("workflow_node.deploy.form.safeline_resource_type.placeholder")}>
<Select.Option key={RESOURCE_TYPE_CERTIFICATE} value={RESOURCE_TYPE_CERTIFICATE}>
{t("workflow_node.deploy.form.safeline_resource_type.option.certificate.label")}
</Select.Option>
</Select>
</Form.Item>
<Show when={fieldResourceType === RESOURCE_TYPE_CERTIFICATE}>
<Form.Item name="certificateId" label={t("workflow_node.deploy.form.safeline_certificate_id.label")} rules={[formRule]}>
<Input placeholder={t("workflow_node.deploy.form.safeline_certificate_id.placeholder")} />
</Form.Item>
</Show>
</Form>
);
};
export default DeployNodeConfigFormSafeLineConfig;

View File

@@ -27,6 +27,7 @@ export interface AccessModel extends BaseModel {
| AccessConfigForPowerDNS
| AccessConfigForQiniu
| AccessConfigForRainYun
| AccessConfigForSafeLine
| AccessConfigForSSH
| AccessConfigForTencentCloud
| AccessConfigForUCloud
@@ -143,6 +144,11 @@ export type AccessConfigForRainYun = {
apiKey: string;
};
export type AccessConfigForSafeLine = {
apiUrl: string;
apiToken: string;
};
export type AccessConfigForSSH = {
host: string;
port: number;

View File

@@ -26,6 +26,7 @@ export const ACCESS_PROVIDERS = Object.freeze({
POWERDNS: "powerdns",
QINIU: "qiniu",
RAINYUN: "rainyun",
SAFELINE: "safeline",
SSH: "ssh",
TENCENTCLOUD: "tencentcloud",
UCLOUD: "ucloud",
@@ -70,6 +71,7 @@ export const accessProvidersMap: Map<AccessProvider["type"] | string, AccessProv
[ACCESS_PROVIDERS.DOGECLOUD, "provider.dogecloud", "/imgs/providers/dogecloud.svg", [ACCESS_USAGES.DEPLOY]],
[ACCESS_PROVIDERS.BYTEPLUS, "provider.byteplus", "/imgs/providers/byteplus.svg", [ACCESS_USAGES.DEPLOY]],
[ACCESS_PROVIDERS.UCLOUD, "provider.ucloud", "/imgs/providers/ucloud.svg", [ACCESS_USAGES.DEPLOY]],
[ACCESS_PROVIDERS.SAFELINE, "provider.safeline", "/imgs/providers/safeline.svg", [ACCESS_USAGES.DEPLOY]],
[ACCESS_PROVIDERS.BAOTAPANEL, "provider.baotapanel", "/imgs/providers/baotapanel.svg", [ACCESS_USAGES.DEPLOY]],
[ACCESS_PROVIDERS.EDGIO, "provider.edgio", "/imgs/providers/edgio.svg", [ACCESS_USAGES.DEPLOY]],
[ACCESS_PROVIDERS.AZURE, "provider.azure", "/imgs/providers/azure.svg", [ACCESS_USAGES.APPLY]],
@@ -200,6 +202,7 @@ export const DEPLOY_PROVIDERS = Object.freeze({
LOCAL: `${ACCESS_PROVIDERS.LOCAL}`,
QINIU_CDN: `${ACCESS_PROVIDERS.QINIU}-cdn`,
QINIU_PILI: `${ACCESS_PROVIDERS.QINIU}-pili`,
SAFELINE: `${ACCESS_PROVIDERS.SAFELINE}`,
SSH: `${ACCESS_PROVIDERS.SSH}`,
TENCENTCLOUD_CDN: `${ACCESS_PROVIDERS.TENCENTCLOUD}-cdn`,
TENCENTCLOUD_CLB: `${ACCESS_PROVIDERS.TENCENTCLOUD}-clb`,
@@ -291,6 +294,7 @@ export const deployProvidersMap: Map<DeployProvider["type"] | string, DeployProv
[DEPLOY_PROVIDERS.BAOTAPANEL_CONSOLE, "provider.baotapanel.console", DEPLOY_CATEGORIES.OTHER],
[DEPLOY_PROVIDERS.BAOTAPANEL_SITE, "provider.baotapanel.site", DEPLOY_CATEGORIES.WEBSITE],
[DEPLOY_PROVIDERS.EDGIO_APPLICATIONS, "provider.edgio.applications", DEPLOY_CATEGORIES.WEBSITE],
[DEPLOY_PROVIDERS.SAFELINE, "provider.safeline", DEPLOY_CATEGORIES.FIREWALL],
].map(([type, name, category]) => [
type,
{

View File

@@ -147,6 +147,12 @@
"access.form.rainyun_api_key.label": "Rain Yun API key",
"access.form.rainyun_api_key.placeholder": "Please enter Rain Yun API key",
"access.form.rainyun_api_key.tooltip": "For more information, see <a href=\"https://www.rainyun.com/docs/account/racc/setting#api%E5%AF%86%E9%92%A5\" target=\"_blank\">https://www.rainyun.com/docs/account/racc/setting</a>",
"access.form.safeline_api_url.label": "SafeLine URL",
"access.form.safeline_api_url.placeholder": "Please enter SafeLine URL",
"access.form.safeline_api_url.tooltip": "For more information, see <a href=\"https://docs.waf.chaitin.com/en/tutorials/install#use-web-ui\" target=\"_blank\">https://docs.waf.chaitin.com/en/tutorials/install</a>",
"access.form.safeline_api_token.label": "SafeLine API token",
"access.form.safeline_api_token.placeholder": "Please enter SafeLine API token",
"access.form.safeline_api_token.tooltip": "For more information, see <a href=\"https://docs.waf.chaitin.com/en/reference/articles/openapi\" target=\"_blank\">https://docs.waf.chaitin.com/en/reference/articles/openapi</a>",
"access.form.ssh_host.label": "Server host",
"access.form.ssh_host.placeholder": "Please enter server host",
"access.form.ssh_port.label": "Server port",

View File

@@ -300,6 +300,11 @@
"workflow_node.deploy.form.qiniu_pili_domain.label": "Qiniu Pili streaming domain",
"workflow_node.deploy.form.qiniu_pili_domain.placeholder": "Please enter Qiniu Pili streaming domain name",
"workflow_node.deploy.form.qiniu_pili_domain.tooltip": "For more information, see <a href=\"hhttps://portal.qiniu.com/hub\" target=\"_blank\">https://portal.qiniu.com/hub</a>",
"workflow_node.deploy.form.safeline_resource_type.label": "Resource type",
"workflow_node.deploy.form.safeline_resource_type.placeholder": "Please select resource type",
"workflow_node.deploy.form.safeline_resource_type.option.certificate.label": "Certificate",
"workflow_node.deploy.form.safeline_certificate_id.label": "SafeLine certificate ID",
"workflow_node.deploy.form.safeline_certificate_id.placeholder": "Please enter SafeLine certificate ID",
"workflow_node.deploy.form.ssh_format.label": "File format",
"workflow_node.deploy.form.ssh_format.placeholder": "Please select file format",
"workflow_node.deploy.form.ssh_format.option.pem.label": "PEM (*.pem, *.crt, *.key)",

View File

@@ -147,6 +147,12 @@
"access.form.rainyun_api_key.label": "雨云 API 密钥",
"access.form.rainyun_api_key.placeholder": "请输入雨云 API 密钥",
"access.form.rainyun_api_key.tooltip": "这是什么?请参阅 <a href=\"https://www.rainyun.com/docs/account/racc/setting#api%E5%AF%86%E9%92%A5\" target=\"_blank\">https://www.rainyun.com/docs/account/racc/setting</a>",
"access.form.safeline_api_url.label": "雷池 URL",
"access.form.safeline_api_url.placeholder": "请输入雷池 URL",
"access.form.safeline_api_url.tooltip": "这是什么?请参阅 <a href=\"https://docs.waf-ce.chaitin.cn/zh/%E4%B8%8A%E6%89%8B%E6%8C%87%E5%8D%97/%E5%AE%89%E8%A3%85%E9%9B%B7%E6%B1%A0#%E8%AE%BF%E9%97%AE%E9%9B%B7%E6%B1%A0%E6%8E%A7%E5%88%B6%E5%8F%B0\" target=\"_blank\">https://docs.waf-ce.chaitin.cn/zh/上手指南/安装雷池</a>",
"access.form.safeline_api_token.label": "雷池 API Token",
"access.form.safeline_api_token.placeholder": "请输入雷池 API Token",
"access.form.safeline_api_token.tooltip": "这是什么?请参阅 <a href=\"https://docs.waf-ce.chaitin.cn/zh/%E6%9B%B4%E5%A4%9A%E6%8A%80%E6%9C%AF%E6%96%87%E6%A1%A3/OPENAPI\" target=\"_blank\">https://docs.waf-ce.chaitin.cn/zh/更多技术文档/OPENAPI</a>",
"access.form.ssh_host.label": "服务器地址",
"access.form.ssh_host.placeholder": "请输入服务器地址",
"access.form.ssh_port.label": "服务器端口",

View File

@@ -300,6 +300,11 @@
"workflow_node.deploy.form.qiniu_pili_domain.label": "七牛云视频直播流域名",
"workflow_node.deploy.form.qiniu_pili_domain.placeholder": "请输入七牛云视频直播流域名",
"workflow_node.deploy.form.qiniu_pili_domain.tooltip": "这是什么?请参阅 <a href=\"hhttps://portal.qiniu.com/hub\" target=\"_blank\">https://portal.qiniu.com/hub</a>",
"workflow_node.deploy.form.safeline_resource_type.label": "证书替换方式",
"workflow_node.deploy.form.safeline_resource_type.placeholder": "请选择证书替换方式",
"workflow_node.deploy.form.safeline_resource_type.option.certificate.label": "替换指定证书",
"workflow_node.deploy.form.safeline_certificate_id.label": "雷池证书 ID",
"workflow_node.deploy.form.safeline_certificate_id.placeholder": "请输入雷池证书 ID",
"workflow_node.deploy.form.ssh_format.label": "文件格式",
"workflow_node.deploy.form.ssh_format.placeholder": "请选择文件格式",
"workflow_node.deploy.form.ssh_format.option.pem.label": "PEM 格式(*.pem, *.crt, *.key",