Skip to content

Commit

Permalink
fix: 修复下架插件不能操作的问题&API文档更新 (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiayuan929 authored Jan 13, 2023
1 parent 99fc9c9 commit 04a7866
Show file tree
Hide file tree
Showing 25 changed files with 1,611 additions and 13 deletions.
2 changes: 1 addition & 1 deletion apiserver/paasng/paasng/pluginscenter/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class PluginStatus(str, StructuredEnum):
DEVELOPING = EnumField("developing", label="开发中")
RELEASING = EnumField("releasing", label="发布中")
RELEASED = EnumField("released", label="已发布")
# 后台轮询下架进度, 进入「下架」相关的状态后, 插件不可进行任何操作
# 后台轮询下架进度, 进入「下架」相关的状态后, 插件还可以进行相关操作
ARCHIVED = EnumField("archived", label="已下架")

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion apiserver/paasng/paasng/pluginscenter/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ class PluginInstanceMixin:
IF request.user DOES NOT have object permissions, will raise PermissionDeny exception
"""

def get_plugin_instance(self, allow_archive: bool = False) -> PluginInstance:
def get_plugin_instance(self, allow_archive: bool = True) -> PluginInstance:
queryset = PluginInstance.objects.all()
filter_kwargs = {"pd__identifier": self.kwargs["pd_id"], "id": self.kwargs["plugin_id"]} # type: ignore
obj = get_object_or_404(queryset, **filter_kwargs)
Expand Down
9 changes: 4 additions & 5 deletions apiserver/paasng/paasng/settings/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,6 @@
# 云原生应用的默认集群名称
CLOUD_NATIVE_APP_DEFAULT_CLUSTER = settings.get("CLOUD_NATIVE_APP_DEFAULT_CLUSTER", "")

# 是否允许创建蓝鲸插件应用
IS_ALLOW_CREATE_BK_PLUGIN_APP = settings.get("IS_ALLOW_CREATE_BK_PLUGIN_APP", False)

# ---------------
# HealthZ 配置
# ---------------
Expand Down Expand Up @@ -791,9 +788,11 @@


# === 插件应用相关
#
# 是否允许创建蓝鲸插件应用
IS_ALLOW_CREATE_BK_PLUGIN_APP = settings.get("IS_ALLOW_CREATE_BK_PLUGIN_APP", False)

# [region-aware] 是否允许用户创建插件应用
BK_PLUGIN_CONFIG = settings.get('BK_PLUGIN_CONFIG', {'allow_creation': False})
BK_PLUGIN_CONFIG = settings.get('BK_PLUGIN_CONFIG', {'allow_creation': IS_ALLOW_CREATE_BK_PLUGIN_APP})

# 管理插件应用的 API 网关时所使用的配置:
BK_PLUGIN_APIGW_SERVICE_STAGE = settings.get('BK_PLUGIN_APIGW_SERVICE_STAGE', 'prod') # 环境(stage)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
### Resource Description

get deploy phases framework

### Example
```bash
curl -X GET -H 'X-BKAPI-AUTHORIZATION: {"bk_app_code": "***", "bk_app_secret": "***", "access_token": "***"}' http://bkapi.example.com/api/bkpaas3/prod/bkapps/applications/{app_code}/modules/{module}/envs/{env}/get_deploy_phases/
```

### Path parameter

| Field | Type | Required | Description |
| ------------ | ------------ | ------ | ---------------- |
| app_code | string |yes| App ID, e.g. "Monitor" |
| module | string | yes | Module name, such as "default"|
| env | string | yes | Environment name, e.g. "Stag,""prod"|



### Response
```json
[{
"display_name": "Preparation Phase",
"type": "preparation",
"steps": [{
"name": "解析应用进程信息",
"display_name": "Parse app process"
}, {
"name": "上传仓库代码",
"display_name": "Upload repository code"
}, {
"name": "配置资源实例",
"display_name": "Config resource instance"
}]
}, {
"display_name": "Build Phase",
"type": "build",
"steps": [{
"name": "下载代码",
"display_name": "Downloading code"
}, {
"name": "加载缓存",
"display_name": "Restoring cache"
}, {
"name": "构建应用",
"display_name": "Building Applications"
}, {
"name": "检测进程类型",
"display_name": "Discover process types"
}, {
"name": "制作打包构件",
"display_name": "Making slug package"
}, {
"name": "上传缓存",
"display_name": "Upload Cache"
}]
}, {
"display_name": "Deploy Phase",
"type": "release",
"steps": [{
"name": "执行部署前置命令",
"display_name": "Execute Pre-release cmd"
}, {
"name": "部署应用",
"display_name": "Deploying the app"
}, {
"name": "检测部署结果",
"display_name": "View Deploy results"
}]
}]
```

### Description of the Response

#### Description of the fields of the DeployPhase object
| Field | Type | Description |
|---|---|---|---|
| display_name | string | The display name of DeployPhase object |
| type | string | The type of DeployPhase object |
| steps | List | Steps included in the DeployPhase |


#### Description of the fields of the DeployStep object
| Field | Type | Description |
|---|---|---|---|
| display_name | string | The display name of DeployStep object |
| name | string | The unique name of DeployStep object |
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
### Resource Description
get deploy phases for deployment instance

### Example
```bash
curl -X GET -H 'X-BKAPI-AUTHORIZATION: {"bk_app_code": "***", "bk_app_secret": "***", "access_token": "***"}' http://bkapi.example.com/api/bkpaas3/prod/bkapps/applications/{app_code}/modules/{module}/envs/{env}/get_deploy_phases/{deployment_id}/
```

### Path parameter

| Field | Type | Required | Description |
| ------------ | ------------ | ------ | ---------------- |
| app_code | string |yes| App ID, e.g. "Monitor" |
| module | string | yes | Module name, such as "default"|
| env | string | yes | Environment name, e.g. "Stag,""prod"|
| deployment_id | string || the id field of deployment instance |


### Response
```json
[{
"display_name": "Preparation Phase",
"type": "preparation",
"steps": [{
"name": "解析应用进程信息",
"display_name": "Parse app process"
}, {
"name": "上传仓库代码",
"display_name": "Upload repository code"
}, {
"name": "配置资源实例",
"display_name": "Config resource instance"
}]
}, {
"display_name": "Build Phase",
"type": "build",
"steps": [{
"name": "下载代码",
"display_name": "Downloading code"
}, {
"name": "加载缓存",
"display_name": "Restoring cache"
}, {
"name": "构建应用",
"display_name": "Building Applications"
}, {
"name": "检测进程类型",
"display_name": "Discover process types"
}, {
"name": "制作打包构件",
"display_name": "Making slug package"
}, {
"name": "上传缓存",
"display_name": "Upload Cache"
}]
}, {
"display_name": "Deploy Phase",
"type": "release",
"steps": [{
"name": "执行部署前置命令",
"display_name": "Execute Pre-release cmd"
}, {
"name": "部署应用",
"display_name": "Deploying the app"
}, {
"name": "检测部署结果",
"display_name": "View Deploy results"
}]
}]
```

### Description of the Response

#### Description of the fields of the DeployPhase object
| Field | Type | Description |
|---|---|---|---|
| display_name | string | The display name of DeployPhase object |
| type | string | The type of DeployPhase object |
| steps | List | Steps included in the DeployPhase |


#### Description of the fields of the DeployStep object
| Field | Type | Description |
|---|---|---|---|
| display_name | string | The display name of DeployStep object |
| name | string | The unique name of DeployStep object |
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
### Resource Description

Query logs for a blueking plug-in tags for internal system use only.


### Authentication mode

Use Bearer method for authentication. Please apply to the administrator for specific authentication.

### Input parameter Description

| Field | Type | Required | Description |
| ------------ | ------------ | ------ | ---------------- |
| private_token | string | no | Token allocated by PaaS platform, which must be provided when the app identity of the requester is not authenticated by PaaS platform |


### Return result

```javascript
[
{
"code_name": "tag1",
"name": "分类1",
"id": 1
}
]
```
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ Use Bearer method for authentication. Please apply to the administrator for spec
| order_by | string | no | Sorting, default is "encrypted," and supports "encrypted,""code" and "encrypted code" |
| has_deployed | boolean |no | Filter by "has plug-in been deployed" and do not filter by default |
| distributor_code_name | string | no | Filter by "authorized user code," such as "bksops," which is not filtered by default |
| tag | integer || Filter by plugin tag and do not filter by default |
| limit | integer |no | Paging parameter, total, default is 100 |
| offset | integer | no | Paging parameter, deviation number, default is 0 |

Expand All @@ -34,7 +35,12 @@ Use Bearer method for authentication. Please apply to the administrator for spec
"has_deployed": false,
"creator": "username",
"created": "2021-08-17 19:35:25",
"updated": "2021-08-17 19:35:25"
"updated": "2021-08-17 19:35:25",
"tag_info": {
"id": 1,
"name": "tag-1",
"code_name": "tag1"
}
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Use Bearer method for authentication. Please apply to the administrator for spec
| order_by | string | no | Sorting, default is "created," and supports "created,""code,""created code,""name,""created name"|
| has_deployed | boolean |no | Filter by "plug-in deployed" and do not filter by default |
| distributor_code_name | string | no | Filter by "authorized user code," such as "bksops," which is not filtered by default |
| tag | integer || Filter by plugin tag and do not filter by default |
| limit | integer |no | Paging parameter, total, default is 100 |
| offset | integer | no | Paging parameter, deviation number, default is 0 |

Expand All @@ -36,7 +37,12 @@ Use Bearer method for authentication. Please apply to the administrator for spec
"has_deployed": true,
"creator": "username",
"created": "2021-08-13 10:37:29",
"updated": "2021-08-13 10:37:29"
"updated": "2021-08-13 10:37:29",
"tag_info": {
"id": 1,
"name": "tag-1",
"code_name": "tag1"
}
},
"deployed_statuses": {
"stag": {
Expand Down
Loading

0 comments on commit 04a7866

Please sign in to comment.