Skip to content

Commit 59c7a27

Browse files
committed
Added reindex_version for the latest version of the gobbler backend.
1 parent 32f90de commit 59c7a27

File tree

4 files changed

+60
-1
lines changed

4 files changed

+60
-1
lines changed

src/pygobbler/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
from .remove_asset import remove_asset
3535
from .remove_version import remove_version
3636
from .clone_version import clone_version
37+
from .reindex_version import reindex_version
3738
from .service_info import service_info
3839
from .version_path import version_path
3940
from .refresh_latest import refresh_latest

src/pygobbler/reindex_version.py

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from . import _utils as ut
2+
3+
4+
def reindex_version(project: str, asset: str, version: str, staging: str, url: str):
5+
"""
6+
Reindex a version of a project asset in the registry.
7+
This regenerates all of the internal ``..manifest`` and ``..links`` files.
8+
9+
Args:
10+
project:
11+
The name of the project.
12+
13+
asset:
14+
The name of the asset of the ``project``.
15+
16+
version:
17+
The name of the version of the ``asset`` to remove.
18+
19+
staging:
20+
Path to the staging directory.
21+
22+
url:
23+
URL to the Gobbler REST API.
24+
25+
Returns:
26+
The requested version is reindexed.
27+
"""
28+
ut.dump_request(staging, url, "reindex_version", { "project": project, "asset": asset, "version": version })

src/pygobbler/start_gobbler.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ def start_gobbler(
1414
registry: Optional[str] = None,
1515
port: Optional[int] = None,
1616
wait: float = 1,
17-
version: str = "0.3.7",
17+
version: str = "0.3.8",
1818
overwrite: bool = False) -> Tuple[bool, str, str, str]:
1919
"""
2020
Start a test Gobbler service.

tests/test_reindex_version.py

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import pygobbler as pyg
2+
import tempfile
3+
import os
4+
import time
5+
import pytest
6+
7+
8+
def test_reindex_version():
9+
_, staging, registry, url = pyg.start_gobbler()
10+
11+
pyg.remove_project("test-reindex", staging=staging, url=url)
12+
pyg.create_project("test-reindex", staging=staging, url=url)
13+
14+
src = pyg.allocate_upload_directory(staging)
15+
with open(os.path.join(src, "foo"), "w") as handle:
16+
handle.write("BAR")
17+
pyg.upload_directory("test-reindex", "simple", "v1", src, staging=staging, url=url)
18+
19+
# Adding another file directly to the registry.
20+
with open(os.path.join(registry, "test-reindex", "simple", "v1", "whee"), "w") as handle:
21+
handle.write("stuff")
22+
23+
# This does not show up in the manifest...
24+
man = pyg.fetch_manifest("test-reindex", "simple", "v1", registry=registry, url=url)
25+
assert list(man.keys()) == ["foo"]
26+
27+
# until we reindex the version.
28+
pyg.reindex_version("test-reindex", "simple", "v1", staging=staging, url=url)
29+
man = pyg.fetch_manifest("test-reindex", "simple", "v1", registry=registry, url=url)
30+
assert sorted(list(man.keys())) == ["foo", "whee"]

0 commit comments

Comments
 (0)