Skip to content

Commit

Permalink
feat: 配置示例更新:1.键值型新增http示例;2.p2p集群id从下拉框变更为输入框--story:118652507
Browse files Browse the repository at this point in the history
  • Loading branch information
q15971095971 committed Jul 20, 2024
1 parent 373b0c4 commit e4df0e9
Show file tree
Hide file tree
Showing 12 changed files with 409 additions and 83 deletions.
Original file line number Diff line number Diff line change
@@ -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)
Original file line number Diff line number Diff line change
@@ -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}"
16 changes: 10 additions & 6 deletions bcs-services/bcs-bscp/ui/src/i18n/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:',
Expand Down Expand Up @@ -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',
Expand All @@ -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',
Expand Down
14 changes: 9 additions & 5 deletions bcs-services/bcs-bscp/ui/src/i18n/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,8 @@ export default {
Watch方法: 'Watch方法',
'Get方法:用于一次性拉取最新的配置信息,适用于需要获取并更新配置的场景。': 'Get 方法:用于一次性拉取最新的配置信息,适用于需要获取并更新配置的场景。',
'Watch方法:通过建立长连接,实时监听配置版本的变更,当新版本的配置发布时,将自动调用回调方法处理新的配置信息,适用于需要实时响应配置变更的场景。': 'Watch 方法:通过建立长连接,实时监听配置版本的变更,当新版本的配置发布时,将自动调用回调方法处理新的配置信息,适用于需要实时响应配置变更的场景。',
'Shell方法:用于一次性拉取最新的配置信息,适用于需要获取并更新配置的场景。': 'Shell 方法:用于一次性拉取最新的配置信息,适用于需要获取并更新配置的场景。',
'Python方法:通过建立长连接,实时监听配置版本的变更,当新版本的配置发布时,将自动调用回调方法处理新的配置信息,适用于需要实时响应配置变更的场景。': 'Python 方法:通过建立长连接,实时监听配置版本的变更,当新版本的配置发布时,将自动调用回调方法处理新的配置信息,适用于需要实时响应配置变更的场景。',
节点管理插件客户端需要在: '节点管理插件客户端需要在',
节点管理平台: '节点管理平台',
'部署“bkbscp (bscp服务配置分发和热更新)”插件,部署详情请参考产品白皮书:': '部署“bkbscp (bscp服务配置分发和热更新)”插件,部署详情请参考产品白皮书:',
Expand Down Expand Up @@ -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',
初始化配置信息: '初始化配置信息',
复制命令: '复制命令',
'仅支持字母,数字,\'-\',\'_\',\'.\' 及 \'/\' 且需以字母数字开头和结尾': '仅支持字母,数字,\'-\',\'_\',\'.\' 及 \'/\' 且需以字母数字开头和结尾',
'需以字母、数字开头和结尾,可包含 \'-\',\'_\',\'.\' 和字母数字及负数': '需以字母、数字开头和结尾,可包含 \'-\',\'_\',\'.\' 和字母数字及负数',
Expand All @@ -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位数字',

// 公共组件
页面不存在: '页面不存在',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@
labelArr: [],
tempDir: '',
clusterSwitch: false,
clusterInfo: {
name: '', // 集群名称
value: '', // 集群id
},
clusterInfo: '',
});
const bkBizId = ref(String(route.params.spaceId));
const replaceVal = ref('');
Expand All @@ -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 = `
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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: '',
},
];
Expand Down
Loading

0 comments on commit e4df0e9

Please sign in to comment.