From e4df0e9df024fa456aa1082543e4678bc2590414 Mon Sep 17 00:00:00 2001 From: q15971095971 <764419406@qq.com> Date: Sat, 20 Jul 2024 15:16:26 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E9=85=8D=E7=BD=AE=E7=A4=BA=E4=BE=8B?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=EF=BC=9A1.=E9=94=AE=E5=80=BC=E5=9E=8B?= =?UTF-8?q?=E6=96=B0=E5=A2=9Ehttp=E7=A4=BA=E4=BE=8B=EF=BC=9B2.p2p=E9=9B=86?= =?UTF-8?q?=E7=BE=A4id=E4=BB=8E=E4=B8=8B=E6=8B=89=E6=A1=86=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E4=B8=BA=E8=BE=93=E5=85=A5=E6=A1=86--story:118652507?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../assets/example-data/kv-http-python.yaml | 31 ++++ .../assets/example-data/kv-http-shell.yaml | 23 +++ bcs-services/bcs-bscp/ui/src/i18n/en-us.ts | 16 +- bcs-services/bcs-bscp/ui/src/i18n/zh-cn.ts | 14 +- .../components/content/container-example.vue | 19 +-- .../example/components/content/kv-example.vue | 96 +++++++++--- .../components/content/node-mana-example.vue | 2 +- .../client/example/components/form-option.vue | 109 ++++++++++---- .../example/components/p2p-acceleration.vue | 30 +++- .../client/example/components/p2p-label.vue | 140 ++++++++++++++++++ .../src/views/space/client/example/index.vue | 1 + bcs-services/bcs-bscp/ui/types/client.ts | 11 +- 12 files changed, 409 insertions(+), 83 deletions(-) create mode 100644 bcs-services/bcs-bscp/ui/src/assets/example-data/kv-http-python.yaml create mode 100644 bcs-services/bcs-bscp/ui/src/assets/example-data/kv-http-shell.yaml create mode 100644 bcs-services/bcs-bscp/ui/src/views/space/client/example/components/p2p-label.vue diff --git a/bcs-services/bcs-bscp/ui/src/assets/example-data/kv-http-python.yaml b/bcs-services/bcs-bscp/ui/src/assets/example-data/kv-http-python.yaml new file mode 100644 index 0000000000..c6e729617f --- /dev/null +++ b/bcs-services/bcs-bscp/ui/src/assets/example-data/kv-http-python.yaml @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +import requests + +# 设置参数 +biz_id = {{ .Bk_Bscp_Variable_BkBizId }}; +key_name = {{ .Bk_Bscp_Variable_KeyName }}; +service_name = "{{ .Bk_Bscp_Variable_ServiceName }}" +token = {{ .Bk_Bscp_Variable_ClientKey }}; +{{ .Bk_Bscp_Variable_Start_Leabels }}{{ .Bk_Bscp_Variable_Leabels }} + +# 使用参数构建URL +url = f"http://feed.sit.bktencent.com:8080/api/v1/feed/biz/{biz_id}/kvs/data/{key_name}" + +# 设置请求头,包括Authorization token +headers = { + "Authorization": f"Bearer {token}", +} + +# 设置请求数据 +data = { + "app_meta": { + "app": service_name, + "labels": labels, + } +} + +# 发送POST请求 +response = requests.post(url, headers=headers, json=data) + +# 打印响应内容 +print("Response content:", response.text) \ No newline at end of file diff --git a/bcs-services/bcs-bscp/ui/src/assets/example-data/kv-http-shell.yaml b/bcs-services/bcs-bscp/ui/src/assets/example-data/kv-http-shell.yaml new file mode 100644 index 0000000000..97c142a559 --- /dev/null +++ b/bcs-services/bcs-bscp/ui/src/assets/example-data/kv-http-shell.yaml @@ -0,0 +1,23 @@ +#!/bin/bash + +# 设置参数 +biz_id={{ .Bk_Bscp_Variable_BkBizId }}; +key_name={{ .Bk_Bscp_Variable_KeyName }}; +service_name="{{ .Bk_Bscp_Variable_ServiceName }}" +token={{ .Bk_Bscp_Variable_ClientKey }}; +{{ .Bk_Bscp_Variable_Start_Leabels }}{{ .Bk_Bscp_Variable_Leabels }} + +# 使用参数构建URL +url="http://feed.sit.bktencent.com:8080/api/v1/feed/biz/${biz_id}/kvs/data/${key_name}" + +# 设置请求头,包括Authorization token +auth_header="Authorization: Bearer ${token}" + +# 设置请求数据 +data="{\"app_meta\": {\"app\": \"${service_name}\", \"labels\": ${labels}}}" + +# 发送POST请求并保存响应 +response=$(curl -s -X POST -H "${auth_header}" -d "${data}" "${url}") + +# 打印响应内容 +echo "Response content: ${response}" \ No newline at end of file diff --git a/bcs-services/bcs-bscp/ui/src/i18n/en-us.ts b/bcs-services/bcs-bscp/ui/src/i18n/en-us.ts index 80d83e06ff..ca4d14e150 100644 --- a/bcs-services/bcs-bscp/ui/src/i18n/en-us.ts +++ b/bcs-services/bcs-bscp/ui/src/i18n/en-us.ts @@ -746,7 +746,9 @@ export default { Get方法: 'Get', Watch方法: 'Watch', 'Get方法:用于一次性拉取最新的配置信息,适用于需要获取并更新配置的场景。': 'Get method: Used for fetching the latest configuration information in a single request, suitable for scenarios requiring both retrieval and update of configurations', - 'Watch方法:通过建立长连接,实时监听配置版本的变更,当新版本的配置发布时,将自动调用回调方法处理新的配置信息,适用于需要实时响应配置变更的场景。': 'Watch method: Establish a long connection to monitor changes in the configuration version in real time. When the new configuration version is released, the callback method is automatically invoked to process the new configuration information. This method is applicable to scenarios that require real-time response to configuration changes.', + 'Watch方法:通过建立长连接,实时监听配置版本的变更,当新版本的配置发布时,将自动调用回调方法处理新的配置信息,适用于需要实时响应配置变更的场景。': 'Shell method: Establish a long connection to monitor changes in the configuration version in real time. When the new configuration version is released, the callback method is automatically invoked to process the new configuration information. This method is applicable to scenarios that require real-time response to configuration changes.', + 'Shell方法:用于一次性拉取最新的配置信息,适用于需要获取并更新配置的场景。': 'Shell method: Used for fetching the latest configuration information in a single request, suitable for scenarios requiring both retrieval and update of configurations', + 'Python方法:通过建立长连接,实时监听配置版本的变更,当新版本的配置发布时,将自动调用回调方法处理新的配置信息,适用于需要实时响应配置变更的场景。': 'Python method: Establish a long connection to monitor changes in the configuration version in real time. When the new configuration version is released, the callback method is automatically invoked to process the new configuration information. This method is applicable to scenarios that require real-time response to configuration changes.', 节点管理插件客户端需要在: 'Node management plug-in client needs to be in', 节点管理平台: 'Node management platform', '部署“bkbscp (bscp服务配置分发和热更新)”插件,部署详情请参考产品白皮书:': 'Deploy the bkbscp (bscp Service Configuration Distribution and Hot Update) plug-in. For details, see the product white paper:', @@ -783,9 +785,6 @@ export default { '用于主动获取配置项值的场景,此方法不会监听服务器端的配置更改\n有关Python SDK的部署环境和依赖组件,请参阅白皮书中的 [BSCP Python SDK依赖说明]': 'For scenarios where configuration values are actively retrieved, this method does not monitor server-side configuration changes\nFor information on the deployment environment and dependent components of the Python SDK, please refer to the [dependency instructions in the BSCP Python SDK]', '通过建立长连接,实时监听配置版本的变更,当新版本的配置发布时,将自动调用回调方法处理新的配置信息,适用于需要实时响应配置变更的场景\n有关Python SDK的部署环境和依赖组件,请参阅白皮书中的 [BSCP Python SDK依赖说明]': 'By establishing a persistent connection, real-time changes to configuration versions are monitored. When a new version of configuration is released, the callback method is automatically invoked to handle the new configuration information. This method is suitable for scenarios requiring real-time response to configuration changes\nFor information on the deployment environment and dependent components of the Python SDK, please refer to the [dependency instructions in the BSCP Python SDK]', '请将 {{ YOUR_KEY }} 替换为您的实际 Key': 'Please replace {\'{{ YOUR_KEY }}\'} with your actual key', - '设置日志自定义 Handler': 'Configure custom logging Handler', - '在线服务, 可设置 metrics': 'Online service with configurable metrics', - 初始化配置信息: 'Initialize configuration information', 复制命令: 'Command Copy', '仅支持字母,数字,\'-\',\'_\',\'.\' 及 \'/\' 且需以字母数字开头和结尾': 'Only supports letters, numbers, \'-\', \'_\', \'.\' and \'/\' characters, and must start and end with a letter or number', '需以字母、数字开头和结尾,可包含 \'-\',\'_\',\'.\' 和字母数字及负数': 'Must start and end with a letter or number, can include \'-\', \'_\', \'.\', and alphanumeric characters, as well as negative numbers', @@ -796,10 +795,15 @@ export default { '以下是启用 P2P 网络加速的基本条件,已确保实现有效的网络加速:': 'Below are the basic conditions for enabling P2P network acceleration, ensuring effective network acceleration:', '⒈ 单个配置文件的大小应超过 50MB': '⒈ The size of a single configuration file should exceed 50MB', '⒉ 客户端实例数量应超过 50 个': '⒉ The number of client instances should exceed 50', - 'P2P 网络加速依赖于 BCS 集群的元数据,请指定客户端即将部署的 BCS 集群 ID。\n更多 P2P 前置依赖信息,请查阅白皮书 P2P 网络加速': 'P2P network acceleration depends on the metadata of the BCS cluster. Please specify the BCS cluster ID where the client will be deployed.\nFor more P2P pre-requisite information, please refer to the P2P network acceleration white paper', + 'P2P 网络加速依赖于 BCS 集群的元数据,请指定客户端即将部署的 BCS 集群 ID。': 'P2P network acceleration relies on the metadata of the BCS cluster. Please specify the BCS cluster ID to which the client will soon be deployed', + '更多 P2P 前置依赖信息,请查阅白皮书 ': 'For more P2P prerequisite information, please refer to the white paper ', + 'P2P 网络加速': 'P2P network acceleration', 'BCS 集群 ID': 'BCS cluster ID', 搜索视图: 'Search view', -'请先选择BCS 集群 ID,替换下方示例代码后,再尝试复制示例': 'Please select the BCS cluster ID first, replace the example code below, and then try to copy the example', + '请输入配置项名称(key)用以获取对应值(value)': 'Please enter the configuration item name (key) to retrieve the corresponding value', + 'HTTP(S)接口调用': 'HTTP(S) interface invocation', + '请输入BCS 集群 ID,替换下方示例代码后,再尝试复制示例': 'Please enter the BCS cluster ID, replace the example code below, and then try copying the example', + 'BCS集群ID须符合以下格式:BCS-K8S-xxxxx,其中xxxxx为5位数字': 'The BCS cluster ID must follow the format: BCS-K8S-xxxxx, where xxxxx is a five-digit numbe', // 公共组件 页面不存在: 'Page does not exist', diff --git a/bcs-services/bcs-bscp/ui/src/i18n/zh-cn.ts b/bcs-services/bcs-bscp/ui/src/i18n/zh-cn.ts index ea7028d80d..9d93cf5476 100644 --- a/bcs-services/bcs-bscp/ui/src/i18n/zh-cn.ts +++ b/bcs-services/bcs-bscp/ui/src/i18n/zh-cn.ts @@ -752,6 +752,8 @@ export default { Watch方法: 'Watch方法', 'Get方法:用于一次性拉取最新的配置信息,适用于需要获取并更新配置的场景。': 'Get 方法:用于一次性拉取最新的配置信息,适用于需要获取并更新配置的场景。', 'Watch方法:通过建立长连接,实时监听配置版本的变更,当新版本的配置发布时,将自动调用回调方法处理新的配置信息,适用于需要实时响应配置变更的场景。': 'Watch 方法:通过建立长连接,实时监听配置版本的变更,当新版本的配置发布时,将自动调用回调方法处理新的配置信息,适用于需要实时响应配置变更的场景。', + 'Shell方法:用于一次性拉取最新的配置信息,适用于需要获取并更新配置的场景。': 'Shell 方法:用于一次性拉取最新的配置信息,适用于需要获取并更新配置的场景。', + 'Python方法:通过建立长连接,实时监听配置版本的变更,当新版本的配置发布时,将自动调用回调方法处理新的配置信息,适用于需要实时响应配置变更的场景。': 'Python 方法:通过建立长连接,实时监听配置版本的变更,当新版本的配置发布时,将自动调用回调方法处理新的配置信息,适用于需要实时响应配置变更的场景。', 节点管理插件客户端需要在: '节点管理插件客户端需要在', 节点管理平台: '节点管理平台', '部署“bkbscp (bscp服务配置分发和热更新)”插件,部署详情请参考产品白皮书:': '部署“bkbscp (bscp服务配置分发和热更新)”插件,部署详情请参考产品白皮书:', @@ -788,9 +790,6 @@ export default { '用于主动获取配置项值的场景,此方法不会监听服务器端的配置更改\n有关Python SDK的部署环境和依赖组件,请参阅白皮书中的 [BSCP Python SDK依赖说明]': '用于主动获取配置项值的场景,此方法不会监听服务器端的配置更改\n有关Python SDK的部署环境和依赖组件,请参阅白皮书中的 [BSCP Python SDK依赖说明]', '通过建立长连接,实时监听配置版本的变更,当新版本的配置发布时,将自动调用回调方法处理新的配置信息,适用于需要实时响应配置变更的场景\n有关Python SDK的部署环境和依赖组件,请参阅白皮书中的 [BSCP Python SDK依赖说明]': '通过建立长连接,实时监听配置版本的变更,当新版本的配置发布时,将自动调用回调方法处理新的配置信息,适用于需要实时响应配置变更的场景\n有关Python SDK的部署环境和依赖组件,请参阅白皮书中的 [BSCP Python SDK依赖说明]', '请将 {{ YOUR_KEY }} 替换为您的实际 Key': '请将 {\'{{ YOUR_KEY }}\'} 替换为您的实际 Key', - '设置日志自定义 Handler': '设置日志自定义 Handler', - '在线服务, 可设置 metrics': '在线服务, 可设置 metrics', - 初始化配置信息: '初始化配置信息', 复制命令: '复制命令', '仅支持字母,数字,\'-\',\'_\',\'.\' 及 \'/\' 且需以字母数字开头和结尾': '仅支持字母,数字,\'-\',\'_\',\'.\' 及 \'/\' 且需以字母数字开头和结尾', '需以字母、数字开头和结尾,可包含 \'-\',\'_\',\'.\' 和字母数字及负数': '需以字母、数字开头和结尾,可包含 \'-\',\'_\',\'.\' 和字母数字及负数', @@ -801,10 +800,15 @@ export default { '以下是启用 P2P 网络加速的基本条件,已确保实现有效的网络加速:': '以下是启用 P2P 网络加速的基本条件,已确保实现有效的网络加速:', '⒈ 单个配置文件的大小应超过 50MB': '⒈ 单个配置文件的大小应超过 50MB', '⒉ 客户端实例数量应超过 50 个': '⒉ 客户端实例数量应超过 50 个', - 'P2P 网络加速依赖于 BCS 集群的元数据,请指定客户端即将部署的 BCS 集群 ID。\n更多 P2P 前置依赖信息,请查阅白皮书 P2P 网络加速': 'P2P 网络加速依赖于 BCS 集群的元数据,请指定客户端即将部署的 BCS 集群 ID。\n更多 P2P 前置依赖信息,请查阅白皮书 P2P 网络加速', + 'P2P 网络加速依赖于 BCS 集群的元数据,请指定客户端即将部署的 BCS 集群 ID。': 'P2P 网络加速依赖于 BCS 集群的元数据,请指定客户端即将部署的 BCS 集群 ID。', + '更多 P2P 前置依赖信息,请查阅白皮书 ': '更多 P2P 前置依赖信息,请查阅白皮书 ', + 'P2P 网络加速': 'P2P 网络加速', 'BCS 集群 ID': 'BCS 集群 ID', 搜索视图: '搜索视图', - '请先选择BCS 集群 ID,替换下方示例代码后,再尝试复制示例': '请先选择BCS 集群 ID,替换下方示例代码后,再尝试复制示例', + '请输入配置项名称(key)用以获取对应值(value)': '请输入配置项名称(key)用以获取对应值(value)', + 'HTTP(S)接口调用': 'HTTP(S)接口调用', + '请输入BCS 集群 ID,替换下方示例代码后,再尝试复制示例': '请输入BCS 集群 ID,替换下方示例代码后,再尝试复制示例', + 'BCS集群ID须符合以下格式:BCS-K8S-xxxxx,其中xxxxx为5位数字': 'BCS集群ID须符合以下格式:BCS-K8S-xxxxx,其中xxxxx为5位数字', // 公共组件 页面不存在: '页面不存在', diff --git a/bcs-services/bcs-bscp/ui/src/views/space/client/example/components/content/container-example.vue b/bcs-services/bcs-bscp/ui/src/views/space/client/example/components/content/container-example.vue index 9c2f69ce2f..d93b2edcb4 100644 --- a/bcs-services/bcs-bscp/ui/src/views/space/client/example/components/content/container-example.vue +++ b/bcs-services/bcs-bscp/ui/src/views/space/client/example/components/content/container-example.vue @@ -40,10 +40,7 @@ labelArr: [], tempDir: '', clusterSwitch: false, - clusterInfo: { - name: '', // 集群名称 - value: '', // 集群id - }, + clusterInfo: '', }); const bkBizId = ref(String(route.params.spaceId)); const replaceVal = ref(''); @@ -69,7 +66,7 @@ let updateString = replaceVal.value; updateString = updateString.replaceAll('{{ .Bk_Bscp_Variable_BkBizId }}', bkBizId.value); updateString = updateString.replaceAll('{{ .Bk_Bscp_Variable_ServiceName }}', basicInfo!.serviceName.value); - replaceVal.value = updateString.replaceAll('{{ .Bk_Bscp_Variable_FEED_ADDR }}', (window as any).FEED_ADDR); + updateString = updateString.replaceAll('{{ .Bk_Bscp_Variable_FEED_ADDR }}', (window as any).FEED_ADDR); // p2p网络加速打开后动态插入内容 if (optionData.value.clusterSwitch) { const p2pPart1 = ` @@ -78,7 +75,7 @@ value: 'true' # 以下几个环境变量在启用 p2p 文件加速时为必填项 # BCS集群ID - - name: {{ .Bk_Bscp_Variable_Cluster_Name }} + - name: cluster_id value: {{ .Bk_Bscp_Variable_Cluster_Value }} # BSCP容器名称 - name: container_name @@ -91,7 +88,7 @@ const p2pPart2 = ` - name: enable_p2p_download value: 'true' - - name: {{ .Bk_Bscp_Variable_Cluster_Name }} + - name: cluster_id value: {{ .Bk_Bscp_Variable_Cluster_Value }} - name: container_name value: bscp-sidecar @@ -130,16 +127,10 @@ default_val: `'${optionData.value.tempDir}'`, memo: '', }, - { - name: 'Bk_Bscp_Variable_Cluster_Name', - type: '', - default_val: `${optionData.value.clusterInfo?.name}`, - memo: '', - }, { name: 'Bk_Bscp_Variable_Cluster_Value', type: '', - default_val: `${optionData.value.clusterInfo?.value}`, + default_val: `${optionData.value.clusterInfo}`, memo: '', }, ]; diff --git a/bcs-services/bcs-bscp/ui/src/views/space/client/example/components/content/kv-example.vue b/bcs-services/bcs-bscp/ui/src/views/space/client/example/components/content/kv-example.vue index 94a5a63a0d..87a00b72a5 100644 --- a/bcs-services/bcs-bscp/ui/src/views/space/client/example/components/content/kv-example.vue +++ b/bcs-services/bcs-bscp/ui/src/views/space/client/example/components/content/kv-example.vue @@ -1,6 +1,10 @@ + + diff --git a/bcs-services/bcs-bscp/ui/src/views/space/client/example/index.vue b/bcs-services/bcs-bscp/ui/src/views/space/client/example/index.vue index 31c3d2d42f..9b50744df3 100644 --- a/bcs-services/bcs-bscp/ui/src/views/space/client/example/index.vue +++ b/bcs-services/bcs-bscp/ui/src/views/space/client/example/index.vue @@ -47,6 +47,7 @@ { name: 'Go SDK', val: 'go' }, { name: 'Java SDK', val: 'java' }, { name: 'C++ SDK', val: 'cpp' }, + { name: t('HTTP(S)接口调用'), val: 'http' }, { name: t('命令行工具'), val: 'shell' }, ]; diff --git a/bcs-services/bcs-bscp/ui/types/client.ts b/bcs-services/bcs-bscp/ui/types/client.ts index f95f95790d..f7d9e5e57e 100644 --- a/bcs-services/bcs-bscp/ui/types/client.ts +++ b/bcs-services/bcs-bscp/ui/types/client.ts @@ -156,15 +156,16 @@ export interface IVersionDistributionPieItem { children?: IVersionDistributionPieItem[]; } -interface IClusterInfo { - name: string; - value: string; -} +// interface IClusterInfo { +// name: string; +// value: string; +// } export interface IExampleFormData { clientKey: string; privacyCredential: string; tempDir?: string; + httpConfigName?: string; labelArr: string[]; clusterSwitch?: boolean; - clusterInfo?: IClusterInfo; + clusterInfo?: string; }