Skip to content

Commit

Permalink
minor: job 类自动去除用户输入的左右空格
Browse files Browse the repository at this point in the history
  • Loading branch information
hanshuaikang committed Oct 11, 2023
1 parent 630b28e commit 03fbb6a
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,18 @@

from django.utils import translation
from django.utils.translation import ugettext_lazy as _

from pipeline.core.flow.io import (
StringItemSchema,
ObjectItemSchema,
BooleanItemSchema,
)
from pipeline.component_framework.component import Component
from pipeline.core.flow.io import BooleanItemSchema, ObjectItemSchema, StringItemSchema

from api.utils.request import batch_request
from gcloud.exceptions import ApiRequestError
from pipeline_plugins.components.collections.sites.open.job import JobService, GetJobTargetServerMixin
from pipeline_plugins.components.utils import get_job_instance_url, get_node_callback_url
from ..base import GetJobHistoryResultMixin, get_job_tagged_ip_dict_complex

from gcloud.conf import settings
from gcloud.constants import JobBizScopeType
from gcloud.exceptions import ApiRequestError
from gcloud.utils.handlers import handle_api_error
from pipeline_plugins.components.collections.sites.open.job import GetJobTargetServerMixin, JobService
from pipeline_plugins.components.utils import get_job_instance_url, get_node_callback_url

from ..base import GetJobHistoryResultMixin, get_job_tagged_ip_dict_complex

__group_name__ = _("作业平台(JOB)")

Expand Down Expand Up @@ -119,7 +114,10 @@ def inputs_format(self):
schema=StringItemSchema(description=_("执行脚本的目标机器 IP,多个用英文逗号 `,` 分隔")),
),
self.InputItem(
name=_("目标账户"), key="job_account", type="string", schema=StringItemSchema(description=_("执行脚本的目标机器账户")),
name=_("目标账户"),
key="job_account",
type="string",
schema=StringItemSchema(description=_("执行脚本的目标机器账户")),
),
self.InputItem(
name=_("滚动执行"),
Expand Down Expand Up @@ -217,7 +215,7 @@ def execute(self, data, parent_data):
"bk_scope_id": str(biz_cc_id),
"bk_biz_id": biz_cc_id,
"timeout": data.get_one_of_inputs("job_script_timeout"),
"account_alias": data.get_one_of_inputs("job_account"),
"account_alias": data.get_one_of_inputs("job_account").strip(),
"target_server": target_server,
"callback_url": get_node_callback_url(self.root_pipeline_id, self.id, getattr(self, "version", "")),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,16 @@ class BaseJobLocalContentUploadService(Service, GetJobTargetServerMixin):
def inputs_format(self):
return [
self.InputItem(
name=_("生成文件名[后缀]"), key="local_name", type="string", schema=StringItemSchema(description=_("生成文件名")),
name=_("生成文件名[后缀]"),
key="local_name",
type="string",
schema=StringItemSchema(description=_("生成文件名")),
),
self.InputItem(
name=_("文本内容"), key="local_content", type="string", schema=StringItemSchema(description=_("文本内容")),
name=_("文本内容"),
key="local_content",
type="string",
schema=StringItemSchema(description=_("文本内容")),
),
self.InputItem(
name=_("目标IP"),
Expand All @@ -59,7 +65,10 @@ def inputs_format(self):
schema=StringItemSchema(description=_("请输入在蓝鲸作业平台上注册的账户名")),
),
self.InputItem(
name=_("目标路径"), key="file_path", type="string", schema=StringItemSchema(description=_("目标路径")),
name=_("目标路径"),
key="file_path",
type="string",
schema=StringItemSchema(description=_("目标路径")),
),
self.InputItem(
name=_("是否允许跨业务"),
Expand Down Expand Up @@ -113,7 +122,7 @@ def get_job_kwargs(self, biz_cc_id, data, target_server):
"bk_scope_type": JobBizScopeType.BIZ.value,
"bk_scope_id": str(biz_cc_id),
"bk_biz_id": biz_cc_id,
"account_alias": data.get_one_of_inputs("file_account"),
"account_alias": data.get_one_of_inputs("file_account").strip(),
"file_target_path": data.get_one_of_inputs("file_path"),
"file_list": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@
"""

from django.utils.translation import ugettext_lazy as _

from pipeline.component_framework.component import Component
from pipeline.core.flow.io import BooleanItemSchema, StringItemSchema

from gcloud.conf import settings
from pipeline_plugins.components.collections.sites.open.job.push_local_files.base_service import (
BaseJobPushLocalFilesService,
)
from gcloud.conf import settings

__group_name__ = _("作业平台(JOB)")

Expand Down Expand Up @@ -67,7 +66,7 @@ def get_params_list(self, client, data, target_server, local_files_and_target_pa
job_rolling_mode = job_rolling_config.get("job_rolling_mode")
rolling_config = {"expression": job_rolling_expression, "mode": job_rolling_mode}

target_account = data.inputs.job_target_account
target_account = data.inputs.job_target_account.strip()
params_list = [
{
"esb_client": client,
Expand Down

0 comments on commit 03fbb6a

Please sign in to comment.