Skip to content

Commit

Permalink
Merge pull request #9 from TencentBlueKing/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
wklken authored Jun 2, 2023
2 parents 7730c1f + 60b9167 commit 1920d74
Show file tree
Hide file tree
Showing 17 changed files with 831 additions and 641 deletions.
62 changes: 62 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
name: "Bug Report"
description: Report a bug to help improve blueking-apigateway.
title: "bug: ......"
body:
- type: markdown
attributes:
value: |
_请提供足够详细的信息, 以便我们能够快速帮助你__
提交 Issue 前,请先搜索 [开放的 Issue](https://github.com/TencentBlueKing/blueking-apigateway/issues),避免重复提交。
_The more information you share, the faster we can help you_
Search the [open issues](https://github.com/apache/apisix/issues) before you open a new issue.
- type: textarea
id: current-behavior
attributes:
label: Current Behavior
description: 遇到的问题 (Describe the issue you are facing)
validations:
required: true
- type: textarea
id: expected-behavior
attributes:
label: Expected Behavior
description: 预期行为 (Describe what you expected to happen)
validations:
required: false
- type: textarea
id: error
attributes:
label: Error Logs
description: 错误日志 (Paste the error logs if any)
validations:
required: false
- type: textarea
id: steps
attributes:
label: Steps to Reproduce
description: 复现步骤 (Share the steps you took so that we can reproduce the issue. Reports without proper steps details will likely be closed.)
placeholder: |
1. ...
2. ...
3. ...
validations:
required: true
- type: textarea
id: version-environment
attributes:
label: Version and Environment
description: 版本及环境信息 (Share your version and environment details)
value: |
- 蓝鲸版本号 (the version of BlueKing platform):
- 容器化部署还是二进制部署 (deployed on Kubernetes or using binary files):
- 二进制部署请提供网关版本号 (the version of bk-apigateway, required for binary distribution):
- 容器化部署请提供 (provide the following information, required for Kubernetes helm chart distribution):
- bk-apigateway helm chart version:
- `values.yaml` 中是否做了修改 (whether you have modified the `values.yaml`):
- `values.yaml` 中的配置, 注意去除敏感信息 (the contents of the `values.yaml` file, remember to remove any sensitive information):
validations:
required: true
24 changes: 24 additions & 0 deletions .github/ISSUE_TEMPLATE/feature_request.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: "Feature Request"
description: Suggest an enhancement to blueking-apigateway.
title: "feat: ......"
body:
- type: markdown
attributes:
value: |
_请提供足够详细的信息, 以便我们能够快速帮助你__
提交 Issue 前,请先搜索 [开放的 Issue](https://github.com/TencentBlueKing/blueking-apigateway/issues),避免重复提交。
_The more information you share, the faster we can help you_
Search the [open issues](https://github.com/apache/apisix/issues) before you open a new issue.
- type: textarea
id: description
attributes:
label: Description
description: 描述你期望支持的特性 (Describe the feature you would like to see.)
placeholder: |
功能需求描述, 包含具体需求背景和功能描述 (Functional requirements description, including specific requirements background and functional description)
validations:
required: true
14 changes: 14 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
### Description

<!-- 关联相关issue Please include a summary of the change and which issue is fixed. -->
<!-- 给出必要的上下文以及review需要的必要信息 Please also include relevant motivation and context. -->

Fixes # (issue)

### Checklist

- [ ] 填写 PR 描述及相关 issue (write PR description and related issue)
- [ ] 代码风格检查通过 (code style check passed)
- [ ] PR 中包含单元测试 (include unit test)
- [ ] 单元测试通过 (unit test passed)
- [ ] 本地开发联调环境验证通过 (local development environment verification passed)
10 changes: 6 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@ repos:
- id: Name check
name: Check sensitive info
verbose: true
language: script
entry: .pre_commit_hooks/rtx.sh
language: system
require_serial: true
entry: bash -c "if [[ -d pre_commit_hooks ]]; then pre_commit_hooks/rtx.sh $@; fi"
- id: IP check
name: Check sensitive info
verbose: true
language: script
entry: .pre_commit_hooks/ip.sh
language: system
require_serial: true
entry: bash -c "if [[ -d pre_commit_hooks ]]; then pre_commit_hooks/ip.sh $@; fi"
16 changes: 12 additions & 4 deletions src/dashboard-front/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,8 @@
3: ['componentAPI', 'ComponentAPIDetailIntro', 'ComponentAPIDetailDoc'],
4: ['apigwSDK'],
5: ['esbSDK']
}
},
isSwitch: false
}
},
computed: {
Expand Down Expand Up @@ -991,7 +992,7 @@
this.$router.push({
name: routeName,
params: {
id: this.apigwId
id: routeName === 'index' ? '' : this.apigwId
}
})
}
Expand Down Expand Up @@ -1053,7 +1054,10 @@
emitSideToggleEnd () {
bus.$emit('side-toggle-end')
},
handleApigwSelect (index) {
handleApigwSelect (id) {
if (!id) {
return
}
const routeParams = {
name: this.$route.meta.matchRoute || this.$route.name,
params: this.$route.params,
Expand All @@ -1062,7 +1066,7 @@
if (routeParams.name !== 'apigwVersionCreate') {
routeParams.query = this.$route.query
}
routeParams.params.id = index
routeParams.params.id = this.isSwitch ? this.activeApigwId : id
this.$router.push(routeParams)
},
async changeLanguage (languageType) {
Expand Down Expand Up @@ -1110,6 +1114,7 @@
})
} else {
optionInput.removeEventListener('keydown', this.handleNavigate)
this.isSwitch = false
}
},
// 键盘上下键回车处理
Expand All @@ -1122,15 +1127,18 @@
} else {
this.selectIndex--
}
this.isSwitch = true
break
case 40:
this.selectIndex < length - 1 ? this.selectIndex++ : this.selectIndex = 0
this.isSwitch = true
break
case 13:
e.preventDefault()
this.selectApigwId = this.activeApigwId
break
default:
this.isSwitch = false
break
}
},
Expand Down
3 changes: 3 additions & 0 deletions src/dashboard-front/src/components/user/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
focus () {
this.$refs.userSelector.focus()
},
handleBlur () {
this.$refs.userSelector.handleBlur()
},
async fuzzySearchMethod (keyword, page = 1) {
const users = await this.$http.get(this.api, {
params: {
Expand Down
27 changes: 24 additions & 3 deletions src/dashboard-front/src/views/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<table class="data-table" v-bkloading="{ isLoading: isLoading, zIndex: 10 }">
<thead class="apigw-table-thead">
<tr>
<th class="name" style="padding-left: 40px;"> {{ $t('网关名') }} </th>
<th class="name"> {{ $t('网关名') }} </th>
<th class="desc"> {{ $t('描述') }} </th>
<th class="creator"> {{ $t('创建者') }} </th>
<th class="env"> {{ $t('环境列表') }} </th>
Expand Down Expand Up @@ -173,6 +173,9 @@
})
} finally {
this.isDataLoading = false
this.$nextTick(() => {
this.hasElemnetScrollbar('.container-content')
})
}
},
Expand Down Expand Up @@ -284,6 +287,15 @@
item.isNewCreated = true
}
})
},
/**
* 当前容器是否存在滚动条
*/
hasElemnetScrollbar (elClassName) {
const element = document.querySelector(elClassName)
const hasVerticalScrollbar = element.scrollHeight > element.clientHeight
hasVerticalScrollbar ? element.classList.add('content-scroll-cls') : element.classList.remove('content-scroll-cls')
}
}
}
Expand All @@ -299,7 +311,7 @@
top: 0;
left: 0;
height: 80px;
background: linear-gradient(to right, #f5f7fa 99%, transparent 0px);
background: #f5f7fa;
z-index: 9;
overflow: hidden;
.content {
Expand Down Expand Up @@ -398,7 +410,7 @@
left: 0;
overflow: hidden;
z-index: 9;
background: linear-gradient(to right, #f5f7fa 99%, transparent 0px);
background: #f5f7fa;
tr {
display: block;
width: 1280px;
Expand Down Expand Up @@ -571,4 +583,13 @@
.gateway-wrapper /deep/ .bk-loading .bk-loading-wrapper {
top: 260px;
}
.container-content.content-scroll-cls {
.header {
width: calc(100% - 6px);
}
.apigw-table-thead {
width: calc(100% - 6px);
}
}
</style>
6 changes: 3 additions & 3 deletions src/dashboard-front/src/views/resource/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
:data="resourceList"
:size="setting.size"
:pagination="pagination"
:ext-cls="resourceList.length > 1 ? 'ag-resources-table' : 'ag-resource-table'"
:ext-cls="resourceList.length > 0 ? 'ag-resources-table' : 'ag-resource-table'"
v-bkloading="{ isLoading: isDataLoading, opacity: 1, immediate: true }"
:default-expand-all="false"
@page-limit-change="handlePageLimitChange"
Expand Down Expand Up @@ -404,7 +404,7 @@
key="updateTime"
:render-header="$renderHeader">
</bk-table-column>
<bk-table-column :label="$t('操作')" width="90" class="ag-action" :show-overflow-tooltip="false">
<bk-table-column :label="$t('操作')" width="90" class="ag-action" fixed="right" :show-overflow-tooltip="false">
<template slot-scope="props">
<bk-button
class="mr5"
Expand All @@ -413,7 +413,7 @@
@click.stop="handleEditResource(props.row)">
{{ $t('编辑') }}
</bk-button>
<bk-dropdown-menu ref="dropdown" align="right">
<bk-dropdown-menu ref="dropdown" align="right" position-fixed>
<i class="bk-icon icon-more ag-more-btn ml10 icon-more-hover" slot="dropdown-trigger"></i>
<ul class="bk-dropdown-list" slot="dropdown-content" style="width: 80px; ">
<!-- <li>
Expand Down
3 changes: 2 additions & 1 deletion src/dashboard-front/src/views/system/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@
</bk-select>
</bk-form-item>
<bk-form-item :label="$t('系统负责人')">
<user v-model="formData.maintainers"></user>
<user v-model="formData.maintainers" ref="userRef"></user>
</bk-form-item>
<bk-form-item :label="$t('超时时长')">
<bk-input type="number" :max="600" :min="1" :precision="0" v-model="formData.timeout">
Expand Down Expand Up @@ -568,6 +568,7 @@
},
async handleBeforeClose () {
this.$refs.userRef && this.$refs.userRef.handleBlur()
return this.$isSidebarClosed(JSON.stringify(this.formData))
}
}
Expand Down
44 changes: 30 additions & 14 deletions src/dashboard/apigateway/apigateway/apps/resource/importer.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,25 +142,41 @@ def _validate_method_path(self):
key_to_id[key] = resource_id

def _validate_resource_name(self):
"""校验资源名称是否合法,不符合标准的几种情况:
- 资源名称已存在,并且指定的 ID 不等于已存在的值
- 资源名称已存在,但路径或方法名变了(无法自动匹配到资源 ID,ID 值为空)
- 同一个资源名称被重复使用
:raise APIError: When validation fails.
"""
- 校验 name 不能重复
"""
resource_name_to_id = {
resource["name"]: resource_id for resource_id, resource in self._existed_resource_id_to_fields.items()
}
existed_name_res_map = {obj["name"]: obj for obj in self._existed_resource_id_to_fields.values()}
seen_names = set()
for resource in self._importing_resources:
resource_id = resource.get("id")
if resource_id:
existed_resource_fields = self._existed_resource_id_to_fields[resource_id]
resource_name_to_id.pop(existed_resource_fields["name"])

key = resource["name"]
if key in resource_name_to_id:
name = resource["name"]
# Check if there are any existing resources using the same name.
existed_res = existed_name_res_map.get(name)
if existed_res and existed_res["id"] != resource.get("id"):
raise error_codes.VALIDATE_ERROR.format(
message=_("资源名称【name={name}】重复。").format(name=resource["name"])
_(
"资源({input_method} {input_path})的名称【name={name}】重复,该名字已被现有资源"
"({method} {path})占用,需调整资源名或维持相同的请求方法和路径。"
).format( # noqa: E501
input_method=resource.get("method", ""),
input_path=resource.get("path", ""),
name=name,
method=existed_res["method"],
path=existed_res["path"],
),
)

resource_name_to_id[key] = resource_id
# Check if the name is duplicated
if name in seen_names:
raise error_codes.VALIDATE_ERROR.format(
_("资源名称【name={name}】重复,该名字在当前配置数据中被多次使用。").format(name=name),
)
else:
seen_names.add(name)

def _validate_resource_count(self):
new_resources = [resource for resource in self._importing_resources if not resource.get("id")]
Expand Down
8 changes: 4 additions & 4 deletions src/dashboard/apigateway/apigateway/conf/default.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@
RABBITMQ_PORT = env.str("BK_APIGW_RABBITMQ_PORT", "")
RABBITMQ_HOST = env.str("BK_APIGW_RABBITMQ_HOST", "")
RABBITMQ_USER = env.str("BK_APIGW_RABBITMQ_USER", "")
RABBITMQ_PASSWORD = env.str("RABBITMQ_PASSWORD", "")
RABBITMQ_PASSWORD = env.str("BK_APIGW_RABBITMQ_PASSWORD", "")
if all([RABBITMQ_VHOST, RABBITMQ_PORT, RABBITMQ_HOST, RABBITMQ_USER, RABBITMQ_PASSWORD]):
CELERY_BROKER_URL = f"amqp://{RABBITMQ_USER}:{RABBITMQ_PASSWORD}@{RABBITMQ_HOST}:{RABBITMQ_PORT}/{RABBITMQ_VHOST}"
CELERY_RESULT_BACKEND = f"redis://:{REDIS_PASSWORD}@{REDIS_HOST}:{REDIS_PORT}/0"
Expand Down Expand Up @@ -560,8 +560,8 @@
}

# 微网关 chart 信息
BCS_MICRO_GATEWAY_CHART_NAME = "bk-micro-gateway-operator"
BCS_MICRO_GATEWAY_CHART_VERSION = "0.0.1"
BCS_MICRO_GATEWAY_CHART_NAME = "bk-micro-gateway"
BCS_MICRO_GATEWAY_CHART_VERSION = "v1.0.0-alpha.2"
BCS_MICRO_GATEWAY_IMAGE_REGISTRY = ""
BCS_MICRO_GATEWAY_SENTRY_DSN = env.str("BCS_MICRO_GATEWAY_SENTRY_DSN", "")

Expand Down Expand Up @@ -650,7 +650,7 @@
}

APISIX_CONFIG = {
"plugin_attr": {
"pluginAttrs": {
"log-rotate": {
# 每间隔多长时间切分一次日志,秒为单位
"interval": 60 * 60,
Expand Down
Loading

0 comments on commit 1920d74

Please sign in to comment.