Skip to content

Commit

Permalink
Merge pull request #2496 from homholueng/V3.6.X_bugfix_no_permission_…
Browse files Browse the repository at this point in the history
…data_no_parent

bugfix: 修复无权限返回数据中实例信息没有父层级的问题
  • Loading branch information
normal-wls authored Aug 17, 2020
2 parents cbf3f79 + ca0e00a commit 92bc4e0
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 7 deletions.
2 changes: 0 additions & 2 deletions dev_log/V3.5.16/pagezhou_202007011630.yml

This file was deleted.

2 changes: 2 additions & 0 deletions dev_log/dev/homholueng_202008171837.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
bugfix:
- 修复无权限返回数据中实例信息没有父层级的问题
25 changes: 20 additions & 5 deletions iam/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,32 @@ def gen_perms_apply_data(system, subject, action_to_resources_list):
instances = []

for resources in resources_list:
instances.append(
[
for resource in resources:
inst_item = []
topo_path = resource.attribute.get("_bk_iam_path_")

if topo_path:
for part in topo_path[1:-1].split("/"):
rtype, rid = part.split(",")
inst_item.append(
{
"type": rtype,
"type_name": meta.get_resource_name(system_id, rtype),
"id": rid,
"name": part,
}
)

inst_item.append(
{
"type": resource.type,
"type_name": meta.get_resource_name(system_id, resource.type),
"id": resource.id,
"name": resource.attribute.get("name", "") if resource.attribute else "",
}
for resource in resources
]
)
)

instances.append(inst_item)

resource_types["instances"] = instances
related_resource_types.append(resource_types)
Expand Down

0 comments on commit 92bc4e0

Please sign in to comment.