77from wrappers .renderer import RenderEngine
88
99TEMPLATE_FILE = "azure.yaml"
10+ CWD = os .path .abspath (os .path .join (os .getcwd (), os .pardir ))
1011
1112def set_env_from_azd ():
1213 """
@@ -21,28 +22,28 @@ def set_env_from_azd():
2122 os .environ [key ] = value
2223
2324def get_services_to_deploy (yaml_template ) -> dict :
24- template_file = os .path .join (os . getcwd () , yaml_template )
25+ template_file = os .path .join (CWD , yaml_template )
2526
2627 with open (template_file , "r" , encoding = "utf-8" ) as stream :
2728 try :
2829 # Converts yaml document to python object
2930 yaml_dict = yaml .safe_load (stream )
3031
3132 if "services" not in yaml_dict :
32- raise ValueError ("No services found in yaml file." )
33+ raise ValueError (f "No services found in yaml file { template_file } ." )
3334
3435 return yaml_dict ["services" ]
3536 except yaml .YAMLError as ex :
3637 print ("Error loading yaml file: " , ex )
3738
3839def pre_req_assertions (deployment_template ):
39- azure_dir = os .path .join (os . getcwd () , ".azure" )
40- template_file = os .path .join (os . getcwd () , deployment_template )
40+ azure_dir = os .path .join (CWD , ".azure" )
41+ template_file = os .path .join (CWD , deployment_template )
4142
4243 # verify that the .azure folder exists
4344 if not os .path .exists (azure_dir ):
4445 raise ValueError (
45- "The .azure folder does not exist. Please run 'azd init' \
46+ f "The .azure folder in { azure_dir } does not exist. Please run 'azd init' \
4647 to setup your environment."
4748 )
4849
@@ -108,11 +109,15 @@ def ignore_func(_, files):
108109 and "deploymentPath" in services_to_deploy [service ]["k8s" ]:
109110 manifest_dir = services_to_deploy [service ]["k8s" ]["deploymentPath" ]
110111
111- manifest_path = os .path .join (os .getcwd (), project_dir , manifest_dir )
112- service_render_path = os .path .join (git_clone_dir , "environments" , \
113- environment_name , "src" , "manifests" , "services" , service )
112+ manifest_path = os .path .join (CWD , project_dir , manifest_dir )
113+ gitops_environment_path = os .path .join (git_clone_dir , "environments" , \
114+ environment_name , "src" , "manifests" )
115+ service_render_path = os .path .join (gitops_environment_path , "services" , service )
114116 copy_manifest_dir_tree_to_repo (manifest_path , service_render_path )
115- render_client = RenderEngine (service_render_path )
117+ render_client = RenderEngine (service_render_path , \
118+ os .path .join (gitops_environment_path , \
119+ "kustomization.yaml" ), \
120+ service )
116121 render_client .render ()
117122 git_client .push_changes (git_clone_dir , f"Deployed service: { service } " )
118123 print (f"Service { service } deployed successfully." )
0 commit comments