Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: 配置示例新增windows路径需求--story=119618143 #3549

Merged
merged 4 commits into from
Oct 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@ labels: {{ .Bk_Bscp_Variable_Leabels }}

# 临时目录,在拉取配置文件时,用于存储配置文件的目录,默认为:/data/bscp,可根据实际情况调整
temp_dir: {{ .Bk_Bscp_VariableTempDir }}

{{ .Bk_Bscp_Variable_Rules }}
EOF
8 changes: 7 additions & 1 deletion bcs-services/bcs-bscp/ui/src/i18n/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ export default {
文件own必须有读取权限: 'The file owner must have read permission',
最大长度1024个字符: 'Maximum length of 1024 characters',
'无效的路径,路径不符合Unix文件路径格式规范': 'Invalid path, the path does not comply with the Unix file path format specification',
'无效的路径,路径不符合Unix或Windows文件路径格式规范': 'Invalid path, the path does not conform to Unix or Windows file path format specifications',
最大长度200个字符: 'Maximum length of 200 characters',
请上传文件: 'Please upload the file',
'配置内容不能超过{size}M': 'Configuration content cannot exceed {size}M',
Expand Down Expand Up @@ -830,6 +831,7 @@ export default {
'如果没有安装 GO,可以通过浏览器手动下载,建议下载最新版本': 'If GO is not installed, you can download it manually through the browser. You are advised to download the latest version',
'下载地址:': 'download url',
'为命令行工具创建所需的配置文件bscp.yaml,请复制以下命令并在与该命令行工具相同的目录下执行': 'Create the necessary configuration file bscp.yaml for the command-line tool. Please copy the following command and execute it in the directory where the command-line tool resides',
'为命令行工具创建所需的配置文件bscp.yaml': 'Create the necessary configuration file bscp.yaml for the command-line tool',
获取业务下的服务列表: 'Get the service list of the service',
拉取服务下所有配置文件: 'Pull all configuration files under the service',
获取服务下所有配置文件列表: 'Obtain a list of all configuration files for the service',
Expand All @@ -847,13 +849,16 @@ export default {
复制成功: 'Copy Successful',
'下载配置文件时,保留目录层级,并将其保存到指定目录下,例如:将 /etc/nginx.conf 文件下载到 /tmp 目录时,文件保存在 /tmp/etc/nginx.conf': 'When downloading configuration files, preserve directory structure and save them to a specified directory. For example, downloading the file /etc/nginx.conf to the /tmp directory would save it as /tmp/etc/nginx.conf',
'下载配置文件时,不保留目录层级,并将其保存到指定目录下,例如:将 /etc/nginx.conf 文件下载到 /tmp 目录时,文件保存在 /tmp/nginx.conf': 'When downloading configuration files, do not preserve directory structure and save them directly to a specified directory. For example, downloading the file /etc/nginx.conf to the /tmp directory would save it as /tmp/nginx.conf',
'下载配置文件时,保留目录层级,并将其保存到指定目录下,例如:将 \\etc\\nginx.conf 文件下载到当前目录时,文件保存在 .\\etc\\nginx.conf': 'When downloading the configuration file, retain the directory structure and save it to a specified directory. For example, when downloading the \\etc\\nginx.conf file to the current directory, it should be saved as .\\etc\\nginx.conf',
'下载配置文件时,不保留目录层级,并将其保存到指定目录下,例如:将 \\etc\\nginx.conf 文件下载到当前目录时,文件保存在 .\\nginx.conf': 'When downloading the configuration file, do not retain the directory structure and save it to a specified directory. For example, when downloading the \\etc\\nginx.conf file to the current directory, it should be saved as .\\nginx.conf',
'BSCP Python SDK依赖说明': 'dependency instructions in the BSCP Python SDK',
'用于主动获取配置项值的场景,此方法不会监听服务器端的配置更改,有关Python SDK的部署环境和依赖组件,请参阅白皮书中的': 'For scenarios where configuration values are actively retrieved, this method does not monitor server-side configuration changes. For information on the deployment environment and dependent components of the Python SDK, please refer to the',
'通过建立长连接,实时监听配置版本的变更,当新版本的配置发布时,将自动调用回调方法处理新的配置信息,适用于需要实时响应配置变更的场景,有关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. For information on the deployment environment and dependent components of the Python SDK, please refer to the',
'用于主动获取配置项值的场景,此方法不会监听服务器端的配置更改\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',
复制命令: 'Command Copy',
复制命令: 'Copy',
复制配置: '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',
服务标签: 'Service label',
Expand Down Expand Up @@ -883,6 +888,7 @@ export default {
'全局配置文件筛选:': 'Global Configuration File Filter:',
'(全局配置文件筛选与服务配置文件筛选一样,不同的是全局配置文件筛选可供多个服务共用)': '(The filtering of the global configuration file is the same as that of the service configuration file; the difference is that the global configuration file can be shared among multiple services)',
配置筛选规则: 'Configuration filtering rules',
'服务feed-server地址:': 'The address of the feed-server service:',

// 公共组件
页面不存在: 'Page does not exist',
Expand Down
6 changes: 6 additions & 0 deletions bcs-services/bcs-bscp/ui/src/i18n/zh-cn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ export default {
文件own必须有读取权限: '文件own必须有读取权限',
最大长度1024个字符: '最大长度1024个字符',
'无效的路径,路径不符合Unix文件路径格式规范': '无效的路径,路径不符合Unix文件路径格式规范',
'无效的路径,路径不符合Unix或Windows文件路径格式规范': '无效的路径,路径不符合Unix或Windows文件路径格式规范',
最大长度200个字符: '最大长度200个字符',
请上传文件: '请上传文件',
'配置内容不能超过{size}M': '配置内容不能超过{size}M',
Expand Down Expand Up @@ -834,6 +835,7 @@ export default {
'如果没有安装 GO,可以通过浏览器手动下载,建议下载最新版本': '如果没有安装 GO,可以通过浏览器手动下载,建议下载最新版本',
'下载地址:': '下载地址:',
'为命令行工具创建所需的配置文件bscp.yaml,请复制以下命令并在与该命令行工具相同的目录下执行': '为命令行工具创建所需的配置文件bscp.yaml,请复制以下命令并在与该命令行工具相同的目录下执行',
'为命令行工具创建所需的配置文件bscp.yaml': '为命令行工具创建所需的配置文件bscp.yaml',
获取业务下的服务列表: '获取业务下的服务列表',
拉取服务下所有配置文件: '拉取服务下所有配置文件',
获取服务下所有配置文件列表: '获取服务下所有配置文件列表',
Expand All @@ -851,13 +853,16 @@ export default {
复制成功: '复制成功',
'下载配置文件时,保留目录层级,并将其保存到指定目录下,例如:将 /etc/nginx.conf 文件下载到 /tmp 目录时,文件保存在 /tmp/etc/nginx.conf': '下载配置文件时,保留目录层级,并将其保存到指定目录下,例如:将 /etc/nginx.conf 文件下载到 /tmp 目录时,文件保存在 /tmp/etc/nginx.conf',
'下载配置文件时,不保留目录层级,并将其保存到指定目录下,例如:将 /etc/nginx.conf 文件下载到 /tmp 目录时,文件保存在 /tmp/nginx.conf': '下载配置文件时,不保留目录层级,并将其保存到指定目录下,例如:将 /etc/nginx.conf 文件下载到 /tmp 目录时,文件保存在 /tmp/nginx.conf',
'下载配置文件时,保留目录层级,并将其保存到指定目录下,例如:将 \\etc\\nginx.conf 文件下载到当前目录时,文件保存在 .\\etc\\nginx.conf': '下载配置文件时,保留目录层级,并将其保存到指定目录下,例如:将 \\etc\\nginx.conf 文件下载到当前目录时,文件保存在 .\\etc\\nginx.conf',
'下载配置文件时,不保留目录层级,并将其保存到指定目录下,例如:将 \\etc\\nginx.conf 文件下载到当前目录时,文件保存在 .\\nginx.conf': '下载配置文件时,不保留目录层级,并将其保存到指定目录下,例如:将 \\etc\\nginx.conf 文件下载到当前目录时,文件保存在 .\\nginx.conf',
'BSCP Python SDK依赖说明': 'BSCP Python SDK依赖说明',
'用于主动获取配置项值的场景,此方法不会监听服务器端的配置更改,有关Python SDK的部署环境和依赖组件,请参阅白皮书中的': '用于主动获取配置项值的场景,此方法不会监听服务器端的配置更改,有关Python SDK的部署环境和依赖组件,请参阅白皮书中的',
'通过建立长连接,实时监听配置版本的变更,当新版本的配置发布时,将自动调用回调方法处理新的配置信息,适用于需要实时响应配置变更的场景,有关Python SDK的部署环境和依赖组件,请参阅白皮书中的': '通过建立长连接,实时监听配置版本的变更,当新版本的配置发布时,将自动调用回调方法处理新的配置信息,适用于需要实时响应配置变更的场景,有关Python SDK的部署环境和依赖组件,请参阅白皮书中的',
'用于主动获取配置项值的场景,此方法不会监听服务器端的配置更改\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',
复制命令: '复制命令',
复制配置: '复制配置',
'仅支持字母,数字,\'-\',\'_\',\'.\' 及 \'/\' 且需以字母数字开头和结尾': '仅支持字母,数字,\'-\',\'_\',\'.\' 及 \'/\' 且需以字母数字开头和结尾',
'需以字母、数字开头和结尾,可包含 \'-\',\'_\',\'.\' 和字母数字及负数': '需以字母、数字开头和结尾,可包含 \'-\',\'_\',\'.\' 和字母数字及负数',
服务标签: '服务标签',
Expand Down Expand Up @@ -886,6 +891,7 @@ export default {
'全局配置文件筛选:': '全局配置文件筛选:',
'(全局配置文件筛选与服务配置文件筛选一样,不同的是全局配置文件筛选可供多个服务共用)': '全局配置文件筛选与服务配置文件筛选一样,不同的是全局配置文件筛选可供多个服务共用',
配置筛选规则: '配置筛选规则',
'服务feed-server地址:': '服务feed-server地址:',

// 公共组件
页面不存在: '页面不存在',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,28 @@
ref="fileOptionRef"
:directory-show="basicInfo!.serviceType.value === 'file'"
:associate-config-show="basicInfo!.serviceType.value === 'file'"
:dual-system-support="true"
@is-windows-path="isWindowsPath = $event"
@update-option-data="getOptionData" />
<div class="preview-container">
<p class="headline">{{ $t('配置指引与示例预览') }}</p>
<div class="guide-wrap">
<div class="guide-content" v-for="(item, index) in cmdContent" :key="item.title">
<div class="guide-content" v-for="(item, index) in cmdContent" :key="item.value + index">
<p class="guide-text">{{ `${index + 1}. ${item.title}` }}</p>
<p class="guide-text guide-text--copy" v-if="item.value" @click="copyText(item.value)">
{{ item.value }}
<copy-shape class="icon-copy" />
</p>
<template v-else>
<bk-button theme="primary" class="copy-btn" @click="copyExample">{{ $t('复制命令') }}</bk-button>
<bk-button theme="primary" class="copy-btn" @click="copyExample">
{{ $t(isWindowsPath ? '复制配置' : '复制命令') }}
</bk-button>
<code-preview
:class="[
'preview-component',
{ 'preview-component--kvcmd': basicInfo!.serviceType.value === 'kv' },
{ 'rules-height': optionData.rules.length },
{ 'windows-path-height': isWindowsPath },
]"
:code-val="replaceVal"
:variables="variables"
Expand Down Expand Up @@ -97,6 +102,46 @@
},
];

const windowsFileText = [
{
title: t('下载二进制命令行'),
value: 'go install github.com/TencentBlueKing/bscp-go/cmd/bscp@latest',
tips: {
title: t('如果没有安装 GO,可以通过浏览器手动下载,建议下载最新版本'),
value: t('下载地址:'),
url: 'https://github.com/TencentBlueKing/bscp-go/releases/',
},
},
{
title: t('为命令行工具创建所需的配置文件bscp.yaml'),
value: '',
},
{
title: t('获取业务下的服务列表'),
value: '.\\bscp.exe get app -c .\\bscp.yaml',
},
{
title: t('拉取服务下所有配置文件'),
value: `.\\bscp.exe pull -a ${basicInfo!.serviceName.value} -c .\\bscp.yaml`,
},
{
title: t('获取服务下所有配置文件列表'),
value: `.\\bscp.exe get file -a ${basicInfo!.serviceName.value} -c .\\bscp.yaml`,
},
{
title: t(
'下载配置文件时,保留目录层级,并将其保存到指定目录下,例如:将 \\etc\\nginx.conf 文件下载到当前目录时,文件保存在 .\\etc\\nginx.conf',
),
value: `.\\bscp.exe get file /etc/nginx.conf -a ${basicInfo!.serviceName.value} -c .\\bscp.yaml -d .\\`,
},
{
title: t(
'下载配置文件时,不保留目录层级,并将其保存到指定目录下,例如:将 \\etc\\nginx.conf 文件下载到当前目录时,文件保存在 .\\nginx.conf',
),
value: `.\\bscp.exe get file /etc/nginx.conf -a ${basicInfo!.serviceName.value} -c .\\bscp.yaml -d .\\ --ignore-dir`,
},
];

const kvText = [
{
title: t('下载二进制命令行'),
Expand Down Expand Up @@ -141,6 +186,7 @@
const replaceVal = ref('');
const copyReplaceVal = ref(''); // 渲染的值,用于复制未脱敏密钥的yaml数据
const variables = ref<IVariableEditParams[]>();
const isWindowsPath = ref(false);
// fileOption组件传递过来的数据汇总
const optionData = ref({
clientKey: '',
Expand All @@ -151,7 +197,13 @@
});

const cmdContent = computed(() => {
return basicInfo!.serviceType.value === 'file' ? fileText : kvText;
if (basicInfo!.serviceType.value === 'file') {
if (isWindowsPath.value) {
return windowsFileText; // 文件型-windows路径提示文案
}
return fileText; // 文件型-unix路径提示文案
}
return kvText;
});

onMounted(async () => {
Expand Down Expand Up @@ -183,14 +235,20 @@
// 文件配置筛选规则动态增/删
if (optionData.value.rules?.length) {
const rulesPart = `
# 当客户端无需拉取配置服务中的全量配置文件时,指定相应的通配符,可仅拉取客户端所需的文件,支持多个通配符
# 当客户端无需拉取配置服务中的全量配置文件时,指定相应的通配符,可仅拉取客户端所需的文件,支持多个通配符
config_matches: {{ .Bk_Bscp_Variable_Rules_Value }}`;
updateString = updateString.replaceAll('{{ .Bk_Bscp_Variable_Rules }}', rulesPart.trim());
updateString = updateString.replaceAll('{{ .Bk_Bscp_Variable_Rules }}', rulesPart);
} else {
updateString = updateString.replaceAll('{{ .Bk_Bscp_Variable_Rules }}', '');
updateString = updateString.replaceAll('{{ .Bk_Bscp_Variable_Rules }}', 'delete');
// updateString = updateString.replaceAll('\r\n{{ .Bk_Bscp_Variable_Rules }}', '');
}
// 临时目录为windows路径时去除首尾两行
if (isWindowsPath.value) {
// updateString = updateString.replaceAll('cat << EOF > ./bscp.yaml\r\n', '').replaceAll('\r\nEOF', '');
updateString = updateString.replaceAll('cat << EOF > ./bscp.yaml', 'delete').replaceAll('EOF', 'delete');
}
// 去除 动态插入的值为空的情况下产生的空白行
replaceVal.value = updateString.replaceAll(/\r\n\s+\r\n/g, '\n');
replaceVal.value = updateString.replaceAll(/(delete\r?\n|\r?\ndelete)/g, '');
};
const updateVariables = () => {
variables.value = [
Expand Down Expand Up @@ -330,5 +388,11 @@ config_matches: {{ .Bk_Bscp_Variable_Rules_Value }}`;
&.rules-height {
height: 394px;
}
&.windows-path-height {
height: 298px;
}
&.rules-height.windows-path-height {
height: 356px;
}
}
</style>
Loading
Loading