diff --git a/zoo/entities/admin.py b/zoo/entities/admin.py new file mode 100644 index 00000000..ac18c886 --- /dev/null +++ b/zoo/entities/admin.py @@ -0,0 +1,18 @@ +from django.contrib import admin + +from . import models + + +@admin.register(models.Entity) +class EntityAdmin(admin.ModelAdmin): + search_fields = ("name", "owner", "kind", "type") + + +@admin.register(models.Link) +class LinkAdmin(admin.ModelAdmin): + search_fields = ("name",) + + +@admin.register(models.Group) +class GroupAdmin(admin.ModelAdmin): + search_fields = ("product_owner", "project_owner") diff --git a/zoo/entities/builder.py b/zoo/entities/builder.py index dfc14ead..13ad48a6 100644 --- a/zoo/entities/builder.py +++ b/zoo/entities/builder.py @@ -19,7 +19,7 @@ def sync_entities(self, data, repository): @staticmethod def _build_base_component(data, repository): group = Group.objects.create( - product_owner=data["metadata"]["group"]["product_owner"], + product_owner=data["metadata"].get("group", {}).get("product_owner"), project_owner=data["metadata"]["group"]["project_owner"], maintainers=data["metadata"]["group"]["maintainers"], ) diff --git a/zoo/repos/tasks.py b/zoo/repos/tasks.py index d4165187..a69fcb4a 100644 --- a/zoo/repos/tasks.py +++ b/zoo/repos/tasks.py @@ -163,7 +163,9 @@ def sync_entity_file(): for project in itertools.chain( get_github_repositories(), get_gitlab_repositories() ): + log.info("repos.sync_entity_yml.processing", project=project["name"]) if settings.SYNC_REPOS_SKIP_FORKS and project["is_fork"]: + log.info("repos.sync_entity_yml.skipping", project=project["name"]) continue update_project_from_entity_file.apply_async(args=[project]) @@ -182,11 +184,19 @@ def update_project_from_entity_file(proj: Dict) -> None: def update_or_create_components(data: List, proj: Dict) -> None: # Skip processing the entity file if the repository is not yet synced + log.info( + "repos.sync_entity_yml.update_or_create_components", + project=proj["name"], + ) try: repository = Repository.objects.get( - remote_id=int(proj["id"]), provider=proj["provider"] + remote_id=int(proj["remote_id"]), provider=proj["provider"] ) except Repository.DoesNotExist: + log.error( + "repos.sync_entity_yml.update_or_create_components.repository_not_found", + remote_id=proj["remote_id"], + ) return def _do_cleanup(): @@ -204,7 +214,7 @@ def _do_cleanup(): def get_entity_file_content(proj: Dict) -> str: provider = get_scm_module(proj["provider"]) - return provider.get_file_content(proj["id"], "entities.yaml") + return provider.get_file_content(proj["remote_id"], "entities.yaml") def sync_enviroments_from_gitlab(repo: Repository):