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

perf: 根据蓝鲸规范调整文档链接 #3217 #3219

Merged
merged 3 commits into from
Sep 23, 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 @@ -27,28 +27,23 @@
package com.tencent.bk.job.common;

import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.info.BuildProperties;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class VersionInfoLogApplicationRunner implements ApplicationRunner {
@Value("${spring.application.name:bk-job}")
private String serviceName;
private final String serviceName;
private final BuildProperties buildProperties;

@Autowired
public VersionInfoLogApplicationRunner(BuildProperties buildProperties) {
public VersionInfoLogApplicationRunner(String serviceName, BuildProperties buildProperties) {
this.serviceName = serviceName;
this.buildProperties = buildProperties;
}

@Override
public void run(ApplicationArguments args){
public void run(ApplicationArguments args) {
String version = buildProperties.getVersion();
log.info("Service name: '{}', Version: '{}'", serviceName, version);
log.info("serviceName= {}, version= {}", serviceName, version);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,11 @@

package com.tencent.bk.job.common.service.config;

import com.tencent.bk.job.common.VersionInfoLogApplicationRunner;
import com.tencent.bk.job.common.config.BkConfig;
import com.tencent.bk.job.common.util.ApplicationContextRegister;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.info.BuildProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
Expand All @@ -39,4 +42,12 @@ public class JobCommonAutoConfiguration {
public ApplicationContextRegister applicationContextRegister() {
return new ApplicationContextRegister();
}

@Value("${spring.application.name:bk-job}")
private String serviceName;

@Bean
public VersionInfoLogApplicationRunner versionInfoLogApplicationRunner(BuildProperties buildProperties) {
return new VersionInfoLogApplicationRunner(serviceName, buildProperties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import com.tencent.bk.job.common.context.JobContext;
import com.tencent.bk.job.common.context.JobContextThreadLocal;
import com.tencent.bk.job.common.i18n.locale.LocaleUtils;
import com.tencent.bk.job.common.model.dto.AppResourceScope;
import io.micrometer.core.instrument.Tag;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -135,6 +136,11 @@ public static void setUserLang(String userLang) {
jobContext.setUserLang(userLang);
}

public static boolean isEnglishLocale() {
String normalLang = LocaleUtils.getNormalLang(getUserLang());
return normalLang.equals(LocaleUtils.LANG_EN) || normalLang.equals(LocaleUtils.LANG_EN_US);
}

public static List<String> getDebugMessage() {
JobContext jobContext = JobContextThreadLocal.get();
List<String> debugMessage = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public IndexService(AnalysisTaskInstanceDAO analysisTaskInstanceDAO,

private Map<String, String> getVariablesMap() {
Map<String, String> variablesMap = new HashMap<>();
variablesMap.put("BK_DOCS_CENTER", globalSettingsResource.getDocCenterBaseUrl().getData());
variablesMap.put("BK_DOC_JOB_ROOT_URL", globalSettingsResource.getDocJobRootUrl().getData());
return variablesMap;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,21 @@
@InternalAPI
public interface ServiceGlobalSettingsResource {

/**
* 获取文档中心基础Url
* Deprecated:3.9.x中不推荐使用,3.10.x中下线,请使用getDocJobRootUrl
*
* @return 文档中心基础Url
*/
@Deprecated
@ApiOperation(value = "获取文档中心基础Url", produces = "application/json")
@GetMapping("/service/globalSettings/docCenterBaseUrl")
InternalResponse<String> getDocCenterBaseUrl();

@ApiOperation(value = "获取文档中心Job文档基础Url", produces = "application/json")
@GetMapping("/service/globalSettings/docJobRootUrl")
InternalResponse<String> getDocJobRootUrl();

@ApiOperation(value = "获取文件上传设置", produces = "application/json")
@GetMapping("/service/globalSettings/fileUploadSettings")
InternalResponse<ServiceFileUploadSettingDTO> getFileUploadSettings();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,20 @@ public InternalResponse<String> getDocCenterBaseUrl() {
return InternalResponse.buildSuccessResp(globalSettingsService.getDocCenterBaseUrl());
}

@Override
public InternalResponse<String> getDocJobRootUrl() {
return InternalResponse.buildSuccessResp(globalSettingsService.getDocJobRootUrl());
}

@Override
public InternalResponse<ServiceFileUploadSettingDTO> getFileUploadSettings() {
FileUploadSettingVO fileUploadSettingVO = globalSettingsService.getFileUploadSettings();
return InternalResponse.buildSuccessResp(convertToServiceFileUploadSettingDTO(fileUploadSettingVO));
}

private ServiceFileUploadSettingDTO convertToServiceFileUploadSettingDTO(FileUploadSettingVO fileUploadSettingVO) {
ServiceFileUploadSettingDTO serviceFileUploadSettingDTO = new ServiceFileUploadSettingDTO();
if(fileUploadSettingVO != null){
if (fileUploadSettingVO != null) {
serviceFileUploadSettingDTO.setSuffixList(fileUploadSettingVO.getSuffixList());
serviceFileUploadSettingDTO.setUnit(fileUploadSettingVO.getUnit());
serviceFileUploadSettingDTO.setAmount(fileUploadSettingVO.getAmount());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ ChannelTemplateDetailWithDefaultVO getChannelTemplateDetail(String username, Str

String getDocCenterBaseUrl();

String getDocJobRootUrl();

Map<String, String> getRelatedSystemUrls(String username);

Map<String, Object> getJobConfig(String username);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -602,6 +602,27 @@ public List<ChannelTemplateStatusVO> listChannelTemplateStatus(String username)
return resultList;
}

@Override
public String getDocJobRootUrl() {
String docCenterBaseUrl = getDocCenterBaseUrl();
StringBuilder sb = new StringBuilder(docCenterBaseUrl);
sb.append("/markdown/");
if (JobContextUtil.isEnglishLocale()) {
sb.append("EN");
} else {
sb.append("ZH");
}
sb.append("/JOB/");
sb.append(getTwoDigitVersion());
return sb.toString();
}

private String getTwoDigitVersion() {
String completeVersion = buildProperties.getVersion();
String[] versionParts = completeVersion.split("\\.");
return versionParts[0] + "." + versionParts[1];
}

@Override
public String getDocCenterBaseUrl() {
String url;
Expand Down Expand Up @@ -656,7 +677,7 @@ public Map<String, String> getRelatedSystemUrls(String username) {
removeSuffixBackSlash(jobManageConfig.getCmdbServerUrl()) + jobManageConfig.getCmdbAppIndexPath());
urlMap.put(RelatedUrlKeys.KEY_BK_NODEMAN_ROOT_URL, getNodemanRootUrl());
urlMap.put(RelatedUrlKeys.KEY_BK_DOC_CENTER_ROOT_URL, getDocCenterBaseUrl());
urlMap.put(RelatedUrlKeys.KEY_BK_DOC_JOB_ROOT_URL, getDocCenterBaseUrl());
urlMap.put(RelatedUrlKeys.KEY_BK_DOC_JOB_ROOT_URL, getDocJobRootUrl());
urlMap.put(RelatedUrlKeys.KEY_BK_FEED_BACK_ROOT_URL, getFeedBackRootUrl());
urlMap.put(RelatedUrlKeys.KEY_BK_SHARED_RES_BASE_JS_URL, getBkSharedResBaseJsUrl());
return urlMap;
Expand Down
2 changes: 2 additions & 0 deletions support-files/kubernetes/images/migration/startup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ function migrateMySQL(){
done

for sql in "${ALL_SQL[@]}"; do
echo "migrate $sql"
mysql -h $BK_JOB_MYSQL_HOST -P $BK_JOB_MYSQL_PORT -u$BK_JOB_MYSQL_ADMIN_USERNAME -p$BK_JOB_MYSQL_ADMIN_PASSWORD < $sql
echo "migrate $sql done"
done
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
SET NAMES utf8mb4;
USE job_analysis;

REPLACE INTO `job_analysis`.`analysis_task_static_instance`(`id`, `app_id`, `task_id`, `status`, `result_data`, `result_data_en`, `priority`, `active`, `creator`, `last_modify_user`, `create_time`, `last_modify_time`) VALUES (1, -1, -1, 2, '使用作业平台 Shell 脚本的内置函数 `job_success` `job_fail`,可以轻松实现简单的执行结果归类分组效果;更多使用技巧,详见[文档](${BK_DOC_JOB_ROOT_URL}/UserGuide/Best-Practices/Use-built-in-functions-to-make-exec-result-grouping.md)', 'Using built-in functions `job_success` `job_fail`, execution results can be grouped easily. Find out more tips with [Docs](${BK_DOC_JOB_ROOT_URL}/UserGuide/Best-Practices/Use-built-in-functions-to-make-exec-result-grouping.md)', 100, b'1', 'admin', 'admin', 1583492717314, 1583492717318);
REPLACE INTO `job_analysis`.`analysis_task_static_instance`(`id`, `app_id`, `task_id`, `status`, `result_data`, `result_data_en`, `priority`, `active`, `creator`, `last_modify_user`, `create_time`, `last_modify_time`) VALUES (2, -1, -1, 2, '如何让同一批主机在不同的步骤中享有独立的变量空间?这样在应对多批次机器执行同一场景时,而无需设置过多的字符串变量或数组索引;详见[文档](${BK_DOC_JOB_ROOT_URL}/UserGuide/Best-Practices/How-to-make-same-host-have-its-own-namespace.md)', 'How to make bunch of hosts own its independent variable space in different steps? In this way, when dealing with multiple hosts to execute the same scene, not necessary to set too many string variables or array indexes. For more information see [Docs](${BK_DOC_JOB_ROOT_URL}/UserGuide/Best-Practices/How-to-make-same-host-have-its-own-namespace.md)', 100, b'1', 'admin', 'admin', 1583492717314, 1583492717318);
REPLACE INTO `job_analysis`.`analysis_task_static_instance`(`id`, `app_id`, `task_id`, `status`, `result_data`, `result_data_en`, `priority`, `active`, `creator`, `last_modify_user`, `create_time`, `last_modify_time`) VALUES (3, -1, -1, 2, '脚本传参涉及到敏感信息(如密码)该如何规避因明文传输而导致信息泄露的风险?`密文` 变量可以帮你解决这个问题!', 'Params involves sensitive information (such as passwords). How to avoid the risk of information leakage? The `Ciphertext` variable can help you solve this problem!', 100, b'1', 'admin', 'admin', 1583492717314, 1583492717318);
REPLACE INTO `job_analysis`.`analysis_task_static_instance`(`id`, `app_id`, `task_id`, `status`, `result_data`, `result_data_en`, `priority`, `active`, `creator`, `last_modify_user`, `create_time`, `last_modify_time`) VALUES (4, -1, -1, 2, '为你的作业模板设置一个标签可以方便你更好的进行分类管理,在「作业」页面左侧可以快速通过分类标签找到你的作业模板。', 'Job tags can help you manage template classification better, you can easily toggle different tags in left side on Jobs page.', 100, b'1', 'admin', 'admin', 1583492717314, 1583492717318);
REPLACE INTO `job_analysis`.`analysis_task_static_instance`(`id`, `app_id`, `task_id`, `status`, `result_data`, `result_data_en`, `priority`, `active`, `creator`, `last_modify_user`, `create_time`, `last_modify_time`) VALUES (5, -1, -1, 2, '收藏的作业除了可以在列表中置顶,还会显示到首页中,这样你就能更快的找到你常用的作业了。', 'Favorited Jobs can be displayed on the top of the Job list, also in HOME page, so you can found it faster when you need it.', 100, b'1', 'admin', 'admin', 1583492717314, 1583492717318);
REPLACE INTO `job_analysis`.`analysis_task_static_instance`(`id`, `app_id`, `task_id`, `status`, `result_data`, `result_data_en`, `priority`, `active`, `creator`, `last_modify_user`, `create_time`, `last_modify_time`) VALUES (6, -1, -1, 2, '你知道么,Shell 也支持数组变量喔~ 写法示例: `var[0]=\'test1\'; var[1]=\'test2\';` 通过 `echo ${var[*]}` 可以打印变量的所有索引值,`echo ${#var[*]}` 可以打印变量一共有多少个索引。', 'You know what, Array variable is supported in Bash. How? `var[0]=\'test1\'; var[1]=\'test2\';` and using `echo ${var[*]}` to print all index values of Array variable, using `echo ${#var[*]}` to show how many index the Array variable has.', 100, b'1', 'admin', 'admin', 1583492717314, 1583492717318);
REPLACE INTO `job_analysis`.`analysis_task_static_instance`(`id`, `app_id`, `task_id`, `status`, `result_data`, `result_data_en`, `priority`, `active`, `creator`, `last_modify_user`, `create_time`, `last_modify_time`) VALUES (7, -1, -1, 2, '当发现某个线上脚本出现严重漏洞时,如何快速止损?脚本版本管理的 `禁用` 可以帮到你,详见[文档](${BK_DOC_JOB_ROOT_URL}/UserGuide/Best-Practices/How-to-stop-the-spread-of-the-problem-script-immediately.md)', 'How to stop loss immediately when a serious bug in an online script is found? You can set the version status to `BANNED` in script version management. See [Docs](${BK_DOC_JOB_ROOT_URL}/UserGuide/Best-Practices/How-to-stop-the-spread-of-the-problem-script-immediately.md)', 100, b'1', 'admin', 'admin', 1583492717314, 1583492717318);
Loading