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

fix(api/category): plugin init_settings add more detail in log info #422

Merged
Merged
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
19 changes: 14 additions & 5 deletions src/api/bkuser_core/categories/plugins/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,20 @@ def init_settings(self, setting_meta_key: str, meta_info: dict):
# 理论上目录不能够被直接恢复, 所以已经被删除的目录不会被更新
# 仅做新增,避免覆盖已有配置
for category in ProfileCategory.objects.filter(type=self.category_type, enabled=True):
ins, created = Setting.objects.get_or_create(
meta=meta, category_id=category.id, defaults={"value": meta.default}
)
if created:
logger.debug("\n------ Setting<%s> of category<%s> created.", ins, category)
try:
ins, created = Setting.objects.get_or_create(
meta=meta, category_id=category.id, defaults={"value": meta.default}
)
if created:
logger.debug("\n------ Setting<%s> of category<%s> created.", ins, category)
except Exception: # pylint: disable=broad-except
logger.exception(
"Setting default of meta<%s>, category_id<%s>, defaults<%s> can not been created.",
meta,
category.id,
meta.default,
)
continue

def load_settings_from_yaml(self):
"""从 yaml 中加载 SettingMeta 配置"""
Expand Down