Skip to content

Commit

Permalink
feature: Job 支持容器执行 - 脚本任务 TencentBlueKing#2631
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyu096 committed Feb 1, 2024
1 parent 2495e5a commit 6ab5dca
Showing 1 changed file with 14 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,26 @@ public static Map<JobFile, FileDest> buildSourceDestPathMapping(Set<JobFile> src
String standardTargetDir = FilePathUtils.standardizedDirPath(targetDir);
long currentTime = System.currentTimeMillis();
for (JobFile srcFile : srcFiles) {
// 本地文件的源ip是本机ip,展开源文件IP地址宏采用"0.0.0.0"
String destDirPath = MacroUtil.resolveFileSrcIpMacro(standardTargetDir,
srcFile.getFileType() == TaskFileTypeEnum.LOCAL ? "0_0.0.0.0" :
srcFile.getExecuteObject().getHost().getBkCloudId() + "_"
+ srcFile.getExecuteObject().getHost().getPrimaryIp());
String destDirPath = resolveFileSrcIp(standardTargetDir, srcFile);
destDirPath = MacroUtil.resolveDate(destDirPath, currentTime);
addSourceDestPathMapping(sourceDestPathMap, srcFile, destDirPath, targetFileName);
}
return sourceDestPathMap;
}


private static String resolveFileSrcIp(String targetFilePath, JobFile srcFile) {
// 本地文件的源ip是本机ip,展开源文件IP地址宏采用"0.0.0.0"
String resolvedTargetPath = targetFilePath;
if (srcFile.getExecuteObject().isHostExecuteObject()) {
resolvedTargetPath = MacroUtil.resolveFileSrcIpMacro(targetFilePath,
srcFile.getFileType() == TaskFileTypeEnum.LOCAL ? "0_0.0.0.0" :
srcFile.getExecuteObject().getHost().getBkCloudId() + "_"
+ srcFile.getExecuteObject().getHost().getPrimaryIp());
}
return resolvedTargetPath;
}

private static void addSourceDestPathMapping(Map<JobFile, FileDest> sourceDestPathMap,
JobFile sourceFile,
String destDirPath,
Expand Down

0 comments on commit 6ab5dca

Please sign in to comment.