22 Path ,
33)
44
5+ MINOS_PROJECT_FILENAME = ".minos-project.yaml"
6+ MINOS_MICROSERVICE_FILENAME = ".minos-microservice.yaml"
7+ MICROSERVICES_DIRECTORY = "microservices"
8+
59
610def get_project_target_directory (path : Path ) -> Path :
711 """Get the target directory for a project.
@@ -10,9 +14,10 @@ def get_project_target_directory(path: Path) -> Path:
1014 """
1115 current = path
1216 while current != current .parent :
13- if (current / ".minos-project.yaml" ).exists ():
17+ if (current / MINOS_PROJECT_FILENAME ).exists ():
1418 return current
15- current = current .parent
19+ else :
20+ current = current .parent
1621
1722 raise ValueError (f"Unable to find the target directory from { path } origin." )
1823
@@ -26,13 +31,18 @@ def get_microservice_target_directory(path: Path, name: str) -> Path:
2631 """
2732 current = path
2833 while current != current .parent :
29- if (current / ".minos-microservice.yaml" ).exists ():
34+ if (current / MINOS_MICROSERVICE_FILENAME ).exists ():
3035 return current
3136
32- if (current / ".minos-project.yaml" ).exists ():
33- target = current / "microservices" / name
34- if (target / ".minos-microservice.yaml" ).exists ():
37+ if (current / MINOS_PROJECT_FILENAME ).exists ():
38+ target = current / MICROSERVICES_DIRECTORY / name
39+ if (target / MINOS_MICROSERVICE_FILENAME ).exists ():
3540 return target
3641 current = current .parent
3742
3843 raise ValueError (f"Unable to find the target directory for { name } from { path } origin." )
44+
45+
46+ def get_microservices_directory (path : Path ) -> Path :
47+ project_directory = get_project_target_directory (path )
48+ return project_directory / MICROSERVICES_DIRECTORY
0 commit comments