Filesharing Resolve Git URL Task¤
task api name:
resolve_git_url
The resolve_git_url task validates a git:// file URL, synchronizes its
configured remote, and returns the file's published nf:// URL. The task does
not stream file content. NFPClient.fetch_file() calls it automatically before
using the existing File Sharing transfer flow.
Inputs¤
| Parameter | Required | Description |
|---|---|---|
url |
Yes | File URL in git://<remote-name>/<path> format |
Output¤
Successful resolution returns an nf:// URL using the remote's configured
mount:
"nf://repositories/network-assets/templates/base.j2"
Invalid URLs, unknown remotes, paths outside the selected mount, missing files, and Git synchronization failures return a failed result.
Examples¤
Use the client-level file command, which resolves the URL automatically:
nf#file copy url git://network-assets/templates/base.j2 read
Direct task invocation:
from norfab.core.nfapi import NorFab
with NorFab(inventory="./inventory.yaml") as nf:
client = nf.make_client()
result = client.run_job(
service="filesharing",
task="resolve_git_url",
workers="filesharing-worker-1",
kwargs={"url": "git://network-assets/templates/base.j2"},
)
print(result)
Normal file retrieval:
from norfab.core.nfapi import NorFab
with NorFab(inventory="./inventory.yaml") as nf:
client = nf.make_client()
result = client.fetch_file(
"git://network-assets/templates/base.j2",
read=True,
)
print(result["content"])
Notes¤
- The remote must already be configured or registered with
create_remote_git. - Resolution synchronizes the complete configured branch before returning.
- The returned URL uses the configured mount, which may differ from the remote name.
- Git access and credentials remain inside the File Sharing worker.
Python API Reference¤
Synchronize a Git remote and resolve its file URL to an nf:// URL.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job
|
Job
|
Active worker job used by the Git synchronization task. |
required |
url
|
str
|
File URL in |
required |
Returns:
| Type | Description |
|---|---|
Result
|
A result containing the published |
Result
|
unknown remotes, unsafe paths, and synchronization failures produce |
Result
|
failed results. |
Source code in norfab\workers\filesharing_worker\git_tasks.py
472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 | |