Skip to content

Commit f1e751d

Browse files
committed
automax-ci-generated-docs-sync.patch
1 parent f21f822 commit f1e751d

2 files changed

Lines changed: 19 additions & 2 deletions

File tree

src/automax/plugins/transfer.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@
2020
from automax.plugins.remote_utils import exec_remote, quote
2121

2222

23+
def _is_templated_path(value: str) -> bool:
24+
"""Return true when validation must wait until job rendering."""
25+
return "{{" in value or "{%" in value or "{#" in value
26+
27+
2328
def _sftp(context: ExecutionContext):
2429
if context.ssh_client is None:
2530
raise RuntimeError("transfer plugin requires an SSH session")
@@ -133,7 +138,10 @@ class TransferUploadPlugin(BasePlugin):
133138

134139
def validate(self, params: Dict[str, Any]) -> None:
135140
super().validate(params)
136-
src = Path(str(params["src"])).expanduser()
141+
src_value = str(params["src"])
142+
if _is_templated_path(src_value):
143+
return
144+
src = Path(src_value).expanduser()
137145
if not src.exists():
138146
raise PluginValidationError(f"transfer.upload source not found: {src}")
139147
if src.is_dir() and not bool(params.get("recursive", False)):
@@ -243,7 +251,10 @@ class TransferSyncPlugin(BasePlugin):
243251

244252
def validate(self, params: Dict[str, Any]) -> None:
245253
super().validate(params)
246-
src = Path(str(params["src"])).expanduser()
254+
src_value = str(params["src"])
255+
if _is_templated_path(src_value):
256+
return
257+
src = Path(src_value).expanduser()
247258
if not src.is_dir():
248259
raise PluginValidationError("transfer.sync source must be a directory")
249260

tests/test_next_engine.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4269,6 +4269,12 @@ def test_cron_readback_plugins_render_manual_commands():
42694269
assert "awk" in registry.get("cron.validate").manual_commands({"path": "/tmp/cron"}, context)[0]
42704270

42714271

4272+
def test_transfer_plugins_allow_templated_controller_sources_in_static_validation():
4273+
from automax.plugins.transfer import TransferSyncPlugin, TransferUploadPlugin
4274+
4275+
TransferSyncPlugin().validate({"src": "{{ vars.fixture_root }}/source-dir", "dest": "/tmp/dest"})
4276+
TransferUploadPlugin().validate({"src": "{{ vars.fixture_root }}/source.txt", "dest": "/tmp/dest"})
4277+
42724278
def test_transfer_upload_download_metadata_include_safety_options():
42734279
from automax.plugins.registry import build_builtin_registry
42744280

0 commit comments

Comments
 (0)