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.
Output¤
Returns results keyed by original Git URL. Each entry contains failed, errors,
and result; successful results contain the file's published nf:// URL using
its remote's configured mount. Missing files, invalid paths, and failed remotes
produce individual failures. Each valid referenced remote is synchronized once
per request. The url argument accepts a string or list. A string retains the original single-file result containing the published URL directly, or 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 remotes and resolve a batch of Git URLs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
job
|
Job
|
Active worker job used for synchronization events. |
required |
url
|
str | list[str]
|
A git:// URL or list of URLs. An empty list returns no entries. |
required |
Returns:
| Type | Description |
|---|---|
Result
|
For string input, a published nf:// URL or a failed result. For list |
Result
|
input, per-URL results containing published URLs or individual errors. |
Result
|
Each referenced valid remote is synchronized once per request. A |
Result
|
remote synchronization failure affects only that remote's entries. |
Result
|
Entry errors are also collected in the outer result errors list. |
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 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 | |
Batch entry errors are also collected in the outer result's errors list, while successful entries remain available.