2525
2626
2727class InputDeployOverrides (BaseModel ):
28- repository : str | None = Field (
29- default = None , description = "Override the repository for deployment"
30- )
31- image_tag : str | None = Field (
32- default = None , description = "Override the image tag for deployment"
33- )
28+ repository : str | None = Field (default = None , description = "Override the repository for deployment" )
29+ image_tag : str | None = Field (default = None , description = "Override the image tag for deployment" )
3430
3531
3632def check_helm_installed () -> bool :
3733 """Check if helm is installed and available"""
3834 try :
39- result = subprocess .run (
40- ["helm" , "version" , "--short" ], capture_output = True , text = True , check = True
41- )
35+ result = subprocess .run (["helm" , "version" , "--short" ], capture_output = True , text = True , check = True )
4236 logger .info (f"Helm version: { result .stdout .strip ()} " )
4337 return True
4438 except (subprocess .CalledProcessError , FileNotFoundError ):
4539 return False
4640
4741
48- def add_helm_repo () -> None :
42+ def add_helm_repo (helm_repository_name : str , helm_repository_url : str ) -> None :
4943 """Add the agentex helm repository if not already added"""
5044 try :
5145 # Check if repo already exists
52- result = subprocess .run (
53- ["helm" , "repo" , "list" ], capture_output = True , text = True , check = True
54- )
46+ result = subprocess .run (["helm" , "repo" , "list" ], capture_output = True , text = True , check = True )
5547
56- if "scale-egp" not in result .stdout :
48+ if helm_repository_name not in result .stdout :
5749 console .print ("Adding agentex helm repository..." )
5850 subprocess .run (
5951 [
6052 "helm" ,
6153 "repo" ,
6254 "add" ,
63- "scale-egp" ,
64- "https://scale-egp-helm-charts-us-west-2.s3.amazonaws.com/charts" ,
55+ helm_repository_name ,
56+ helm_repository_url ,
6557 ],
6658 check = True ,
6759 )
@@ -75,7 +67,6 @@ def add_helm_repo() -> None:
7567 raise HelmError (f"Failed to add helm repository: { e } " ) from e
7668
7769
78-
7970def convert_env_vars_dict_to_list (env_vars : dict [str , str ]) -> list [dict [str , str ]]:
8071 """Convert a dictionary of environment variables to a list of dictionaries"""
8172 return [{"name" : key , "value" : value } for key , value in env_vars .items ()]
@@ -169,11 +160,11 @@ def merge_deployment_configs(
169160 # Priority: manifest -> environments.yaml -> secrets (highest)
170161 all_env_vars : dict [str , str ] = {}
171162 secret_env_vars : list [dict [str , str ]] = []
172-
163+
173164 # Start with agent_config env vars from manifest
174165 if agent_config .env :
175166 all_env_vars .update (agent_config .env )
176-
167+
177168 # Override with environment config env vars if they exist
178169 if agent_env_config and agent_env_config .helm_overrides and "env" in agent_env_config .helm_overrides :
179170 env_overrides = agent_env_config .helm_overrides ["env" ]
@@ -185,8 +176,6 @@ def merge_deployment_configs(
185176 env_override_dict [str (env_var ["name" ])] = str (env_var ["value" ])
186177 all_env_vars .update (env_override_dict )
187178
188-
189-
190179 # Handle credentials and check for conflicts
191180 if agent_config .credentials :
192181 for credential in agent_config .credentials :
@@ -199,7 +188,7 @@ def merge_deployment_configs(
199188 env_var_name = credential .env_var_name
200189 secret_name = credential .secret_name
201190 secret_key = credential .secret_key
202-
191+
203192 # Check if the environment variable name conflicts with existing env vars
204193 if env_var_name in all_env_vars :
205194 logger .warning (
@@ -208,7 +197,7 @@ def merge_deployment_configs(
208197 )
209198 # Remove from regular env vars since secret takes precedence
210199 del all_env_vars [env_var_name ]
211-
200+
212201 secret_env_vars .append (
213202 {
214203 "name" : env_var_name ,
@@ -222,13 +211,14 @@ def merge_deployment_configs(
222211 # Add auth principal env var if environment config is set
223212 if agent_env_config .auth :
224213 from agentex .lib .cli .utils .auth_utils import _encode_principal_context_from_env_config
214+
225215 encoded_principal = _encode_principal_context_from_env_config (agent_env_config .auth )
226216 logger .info (f"Encoding auth principal from { agent_env_config .auth } " )
227217 if encoded_principal :
228218 all_env_vars [EnvVarKeys .AUTH_PRINCIPAL_B64 .value ] = encoded_principal
229219 else :
230220 raise DeploymentError (f"Auth principal unable to be encoded for agent_env_config: { agent_env_config } " )
231-
221+
232222 logger .info (f"Defined agent helm overrides: { agent_env_config .helm_overrides } " )
233223 logger .info (f"Before-merge helm values: { helm_values } " )
234224 if agent_env_config .helm_overrides :
@@ -239,7 +229,7 @@ def merge_deployment_configs(
239229 # Environment variable precedence: manifest -> environments.yaml -> secrets (highest)
240230 if all_env_vars :
241231 helm_values ["env" ] = convert_env_vars_dict_to_list (all_env_vars )
242-
232+
243233 if secret_env_vars :
244234 helm_values ["secretEnvVars" ] = secret_env_vars
245235
@@ -252,30 +242,25 @@ def merge_deployment_configs(
252242
253243 # Handle image pull secrets
254244 if manifest .deployment and manifest .deployment .imagePullSecrets :
255- pull_secrets = [
256- pull_secret .model_dump ()
257- for pull_secret in manifest .deployment .imagePullSecrets
258- ]
245+ pull_secrets = [pull_secret .model_dump () for pull_secret in manifest .deployment .imagePullSecrets ]
259246 helm_values ["global" ]["imagePullSecrets" ] = pull_secrets
260247 helm_values ["imagePullSecrets" ] = pull_secrets
261248
262249 # Add dynamic ACP command based on manifest configuration if command is not set in helm overrides
263- helm_overrides_command = agent_env_config and agent_env_config .helm_overrides and "command" in agent_env_config .helm_overrides
250+ helm_overrides_command = (
251+ agent_env_config and agent_env_config .helm_overrides and "command" in agent_env_config .helm_overrides
252+ )
264253 if not helm_overrides_command :
265254 add_acp_command_to_helm_values (helm_values , manifest , manifest_path )
266-
255+
267256 logger .info ("Deploying with the following helm values: %s" , helm_values )
268257 return helm_values
269258
270259
271260def _deep_merge (base_dict : dict [str , Any ], override_dict : dict [str , Any ]) -> None :
272261 """Deep merge override_dict into base_dict"""
273262 for key , value in override_dict .items ():
274- if (
275- key in base_dict
276- and isinstance (base_dict [key ], dict )
277- and isinstance (value , dict )
278- ):
263+ if key in base_dict and isinstance (base_dict [key ], dict ) and isinstance (value , dict ):
279264 _deep_merge (base_dict [key ], value )
280265 else :
281266 base_dict [key ] = value
@@ -317,8 +302,14 @@ def deploy_agent(
317302 else :
318303 console .print (f"[yellow]⚠[/yellow] No environments.yaml found, skipping environment-specific config" )
319304
305+ if agent_env_config :
306+ helm_repository_name = agent_env_config .helm_repository_name
307+ helm_repository_url = agent_env_config .helm_repository_url
308+ else :
309+ helm_repository_name = "scale-egp"
310+ helm_repository_url = "https://scale-egp-helm-charts-us-west-2.s3.amazonaws.com/charts"
320311 # Add helm repository/update
321- add_helm_repo ()
312+ add_helm_repo (helm_repository_name , helm_repository_url )
322313
323314 # Merge configurations
324315 helm_values = merge_deployment_configs (manifest , agent_env_config , deploy_overrides , manifest_path )
@@ -348,7 +339,7 @@ def deploy_agent(
348339 "helm" ,
349340 "upgrade" ,
350341 release_name ,
351- "scale-egp /agentex-agent" ,
342+ f" { helm_repository_name } /agentex-agent" ,
352343 "--version" ,
353344 AGENTEX_AGENTS_HELM_CHART_VERSION ,
354345 "-f" ,
@@ -370,7 +361,7 @@ def deploy_agent(
370361 "helm" ,
371362 "install" ,
372363 release_name ,
373- "scale-egp /agentex-agent" ,
364+ f" { helm_repository_name } /agentex-agent" ,
374365 "--version" ,
375366 AGENTEX_AGENTS_HELM_CHART_VERSION ,
376367 "-f" ,
@@ -388,12 +379,8 @@ def deploy_agent(
388379
389380 # Show success message with helpful commands
390381 console .print ("\n [green]🎉 Deployment completed successfully![/green]" )
391- console .print (
392- f"[blue]Check deployment status:[/blue] helm status { release_name } -n { namespace } "
393- )
394- console .print (
395- f"[blue]View logs:[/blue] kubectl logs -l app.kubernetes.io/name=agentex-agent -n { namespace } "
396- )
382+ console .print (f"[blue]Check deployment status:[/blue] helm status { release_name } -n { namespace } " )
383+ console .print (f"[blue]View logs:[/blue] kubectl logs -l app.kubernetes.io/name=agentex-agent -n { namespace } " )
397384
398385 except subprocess .CalledProcessError as e :
399386 raise HelmError (
0 commit comments