Skip to content
This repository has been archived by the owner on Feb 21, 2022. It is now read-only.

Commit

Permalink
feat(entities): register entity models in admin and add logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jarosevcik committed Oct 1, 2021
1 parent d4a2ed0 commit a1de85e
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 1 deletion.
18 changes: 18 additions & 0 deletions zoo/entities/admin.py
Original file line number Diff line number Diff line change
@@ -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")
8 changes: 7 additions & 1 deletion zoo/repos/tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand All @@ -182,6 +184,10 @@ 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.creating_components",
project=proj["name"],
)
try:
repository = Repository.objects.get(
remote_id=int(proj["id"]), provider=proj["provider"]
Expand All @@ -204,7 +210,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):
Expand Down

0 comments on commit a1de85e

Please sign in to comment.