This repository has been archived by the owner on Feb 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jaroslav Sevcik
committed
Jul 1, 2021
1 parent
14dc725
commit da62461
Showing
20 changed files
with
233 additions
and
200 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
from django.apps import AppConfig | ||
|
||
|
||
class EntitiesConfig(AppConfig): | ||
name = "zoo.entities" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
from zoo.entities.models import Entity, Group | ||
|
||
|
||
class EntityBuilder: | ||
def entity(self, data): | ||
if data["kind"] == "component": | ||
if data["spec"]["type"] == "service": | ||
self._build_service(data) | ||
elif data["spec"]["spec"] == "library": | ||
self._build_library(data) | ||
else: | ||
self._build_base_component(data) | ||
else: | ||
return NotImplemented | ||
|
||
@staticmethod | ||
def _build_base_component(data): | ||
group, _ = Group.objects.update_or_create( | ||
product_owner=data["metadata"]["group"]["product_owner"], | ||
project_owner=data["metadata"]["group"]["project_owner"], | ||
maintainers=data["metadata"]["group"]["maintainers"], | ||
) | ||
obj, _ = Entity.objects.update_or_create( | ||
name=data["metadata"]["name"], | ||
kind=data["kind"], | ||
owner=data["metadata"]["owner"], | ||
type=data["spec"]["type"], | ||
defaults={ | ||
"group": group, | ||
"description": data["metadata"]["description"], | ||
"tags": data["metadata"]["tags"], | ||
"links": "", | ||
}, | ||
) | ||
return obj | ||
|
||
def _build_service(self, data): | ||
base_component = self._build_base_component(data) | ||
|
||
def _build_library(self, data): | ||
self._build_base_component(data) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ies/migrations/0004_auto_20210617_0010.py → ...ies/migrations/0004_auto_20210701_1130.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.