Skip to content
Merged
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 @@ -60,6 +60,14 @@ const configTypeMap = {
deploy: 'DeployConfig',
};

const convertExportConfigs = (configs: PIPELINE_CONFIG.ConfigItem[] = []) =>
configs
.filter(({ encrypt }) => !encrypt)
.map(({ key, value }) => ({
key,
value,
}));

interface IProps {
envToNs: Obj<string>;
configs: PIPELINE_CONFIG.ConfigItemMap;
Expand Down Expand Up @@ -370,7 +378,7 @@ const VariableConfig = ({
<Button type="primary" className="mb-3" ghost onClick={() => openModal(null, env)}>
{i18n.t('dop:Add Variable')}
</Button>
{configType === configTypeMap.deploy && (
{importConfig && exportConfig && (
<>
<Button
type="primary"
Expand Down Expand Up @@ -509,6 +517,23 @@ export const PipelineConfig = () => {
addConfig={configStore.addConfigs}
updateConfig={configStore.updateConfigs}
deleteConfig={configStore.removeConfigWithoutDeploy}
importConfig={({ query, configs }) => {
const encryptedKeys = new Set(
fullConfigs[query.namespace_name]?.filter(({ encrypt }) => encrypt).map(({ key }) => key),
);
return configStore.updateConfigs({
query: { ...query, encrypt: false },
configs: JSON.parse(configs)
.filter(({ key }: PIPELINE_CONFIG.ConfigItem) => !encryptedKeys.has(key))
.map((item: PIPELINE_CONFIG.ConfigItem) => ({
...item,
encrypt: false,
type: item.type || typeMap.kv,
})),
batch: true,
});
}}
exportConfig={({ namespace_name }) => Promise.resolve(convertExportConfigs(fullConfigs[namespace_name]))}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

导入可能将加密变量覆盖为明文:
配置以 decrypt: false 获取,导入窗口却预填全部变量;提交时再统一设置 encrypt: false。用户只需打开导入窗口并确认,就可能用未解密的返回值覆盖密文,同时取消加密属性。

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修复:pipeline 变量导出/导入弹窗预填时会过滤掉 encrypt=true 的变量;导入提交时也会根据当前 namespace 的已有配置跳过加密 key,避免打开弹窗直接确认时覆盖加密变量或取消加密属性。

uploadTip={i18n.t('dop:upload-file-tip')}
/>
);
Expand Down
Loading