1010from compose2pod .exceptions import UnsupportedComposeError
1111from compose2pod .graph import depends_on , hostnames , startup_order
1212from compose2pod .healthcheck import health_cmd , interval_seconds
13- from compose2pod .keys import SERVICE_KEYS , Token , _Expand , _key_value_pairs
13+ from compose2pod .keys import SERVICE_KEYS , Expand , Token , key_value_pairs
1414from compose2pod .pod import pod_create_flags
1515from compose2pod .resources import deploy_resource_flags
1616from compose2pod .shell import to_shell , variable_names
@@ -24,7 +24,7 @@ def image_for(svc: dict[str, Any], ci_image: str) -> Token:
2424 """Services with a build section run the freshly built CI image."""
2525 if "build" in svc :
2626 return ci_image
27- return _Expand (value = svc ["image" ])
27+ return Expand (value = svc ["image" ])
2828
2929
3030def command_tokens (svc : dict [str , Any ]) -> list [Token ]:
@@ -33,8 +33,8 @@ def command_tokens(svc: dict[str, Any]) -> list[Token]:
3333 if command is None :
3434 return []
3535 if isinstance (command , str ):
36- return ["/bin/sh" , "-c" , _Expand (value = command )]
37- return [_Expand (value = str (token )) for token in command ]
36+ return ["/bin/sh" , "-c" , Expand (value = command )]
37+ return [Expand (value = str (token )) for token in command ]
3838
3939
4040def entrypoint_tokens (svc : dict [str , Any ]) -> list [Token ]:
@@ -43,15 +43,15 @@ def entrypoint_tokens(svc: dict[str, Any]) -> list[Token]:
4343 if entrypoint is None :
4444 return []
4545 if isinstance (entrypoint , str ):
46- return ["/bin/sh" , "-c" , _Expand (value = entrypoint )]
47- return [_Expand (value = str (token )) for token in entrypoint ]
46+ return ["/bin/sh" , "-c" , Expand (value = entrypoint )]
47+ return [Expand (value = str (token )) for token in entrypoint ]
4848
4949
5050def _add_health_flags (flags : list [Token ], healthcheck : dict [str , Any ]) -> None :
5151 """Add healthcheck flags to the flags list."""
5252 cmd = health_cmd (healthcheck .get ("test" ))
5353 if cmd is not None :
54- flags += ["--health-cmd" , _Expand (value = cmd )]
54+ flags += ["--health-cmd" , Expand (value = cmd )]
5555 if "timeout" in healthcheck :
5656 flags += ["--health-timeout" , str (healthcheck ["timeout" ])]
5757 if "start_period" in healthcheck :
@@ -63,34 +63,34 @@ def _add_health_flags(flags: list[Token], healthcheck: dict[str, Any]) -> None:
6363def _add_env_flags (flags : list [Token ], svc : dict [str , Any ], project_dir : str ) -> None :
6464 """Add -e and --env-file flags to the flags list."""
6565 # A null environment value means "pass KEY through from the host" (bare `-e KEY`).
66- for pair in _key_value_pairs (svc .get ("environment" ) or {}):
67- flags += ["-e" , _Expand (value = str (pair ))]
66+ for pair in key_value_pairs (svc .get ("environment" ) or {}):
67+ flags += ["-e" , Expand (value = str (pair ))]
6868 env_files = svc .get ("env_file" ) or []
6969 if isinstance (env_files , str ):
7070 env_files = [env_files ]
7171 for env_file in env_files :
72- flags += ["--env-file" , _Expand (value = str (Path (project_dir , env_file )))]
72+ flags += ["--env-file" , Expand (value = str (Path (project_dir , env_file )))]
7373
7474
7575def _add_volume_flags (flags : list [Token ], svc : dict [str , Any ], project_dir : str ) -> None :
7676 """Add -v and --tmpfs flags to the flags list."""
7777 for volume in svc .get ("volumes" ) or []:
7878 if ":" not in volume :
7979 # Anonymous volume: a bare container path, no host source to translate.
80- flags += ["-v" , _Expand (value = volume )]
80+ flags += ["-v" , Expand (value = volume )]
8181 continue
8282 source , destination = volume .split (":" , 1 )
8383 if source .startswith ("." ):
8484 # Relative bind mount: resolve against project_dir.
8585 source = str (Path (project_dir , source ))
8686 # Absolute bind mount (starts with "/") and named volume (bare
8787 # identifier) are both kept as-is — neither is a path to translate.
88- flags += ["-v" , _Expand (value = f"{ source } :{ destination } " )]
88+ flags += ["-v" , Expand (value = f"{ source } :{ destination } " )]
8989 tmpfs = svc .get ("tmpfs" ) or []
9090 if isinstance (tmpfs , str ):
9191 tmpfs = [tmpfs ]
9292 for mount in tmpfs :
93- flags += ["--tmpfs" , _Expand (value = mount )]
93+ flags += ["--tmpfs" , Expand (value = mount )]
9494
9595
9696def run_flags (name : str , svc : dict [str , Any ], pod : str , project_dir : str ) -> list [Token ]:
@@ -168,13 +168,13 @@ class PlannedScript:
168168
169169
170170def _render (tokens : list [Token ]) -> str :
171- return " " .join (to_shell (token .value ) if isinstance (token , _Expand ) else shlex .quote (token ) for token in tokens )
171+ return " " .join (to_shell (token .value ) if isinstance (token , Expand ) else shlex .quote (token ) for token in tokens )
172172
173173
174174def _collect_vars (tokens : list [Token ], names : set [str ]) -> None :
175- """Add the run-time variables any `_Expand ` tokens expand to `names`."""
175+ """Add the run-time variables any `Expand ` tokens expand to `names`."""
176176 for token in tokens :
177- if isinstance (token , _Expand ):
177+ if isinstance (token , Expand ):
178178 names .update (variable_names (token .value ))
179179
180180
@@ -220,7 +220,7 @@ def _plan(compose: dict[str, Any], options: EmitOptions) -> PlannedScript:
220220
221221 Every token source is visited a single time and feeds both outputs: each
222222 service's `_run_tokens` and the `pod_create_flags` render into lines *and*
223- have their `_Expand ` variables collected, so the script and the variable
223+ have their `Expand ` variables collected, so the script and the variable
224224 list cannot disagree about what the script expands at run time.
225225 """
226226 services = compose ["services" ]
0 commit comments