Skip to content

ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.

feat(marketplace): default the registry to the public serverkit-extensions index

Juan Denisaf777a87b385
diff --git a/backend/app/services/registry_service.py b/backend/app/services/registry_service.py
index 07f57696..c1b71a58 100644
--- a/backend/app/services/registry_service.py
+++ b/backend/app/services/registry_service.py
@@ -9,7 +9,9 @@ Design rules:
- Read-only discovery. NOTHING here ever auto-installs; installs are explicit.
- Offline-tolerant. A failed/absent fetch falls back to the last good cache, then
to a bundled copy (app/data/registry_index.json) — the Marketplace never blanks.
- - Configurable. SERVERKIT_REGISTRY_URL points at the live index; unset ⇒ bundled.
+ - Configurable. SERVERKIT_REGISTRY_URL points at the live index. Unset ⇒ the
+ public serverkit-extensions registry; set-but-EMPTY ⇒ explicitly disabled
+ (bundled copy only — also how the test suite stays offline).
"""
import json
import logging
@@ -26,7 +28,20 @@ _BUNDLED_INDEX = os.path.join(
os.path.dirname(os.path.dirname(os.path.abspath(__file__))), 'data', 'registry_index.json'
)
-REGISTRY_URL = os.environ.get('SERVERKIT_REGISTRY_URL', '').strip()
+# The curated public index (one JSON file, PR-reviewed, checksum-verified
+# installs). Panels fall back to cache → bundled copy when unreachable.
+DEFAULT_REGISTRY_URL = (
+ 'https://raw.githubusercontent.com/jhd3197/serverkit-extensions/main/index.json'
+)
+
+
+def _registry_url():
+ """Resolve the live index URL per request (env changes apply without a
+ restart). Unset ⇒ the public registry; set-but-empty ⇒ disabled."""
+ value = os.environ.get('SERVERKIT_REGISTRY_URL')
+ if value is None:
+ return DEFAULT_REGISTRY_URL
+ return value.strip()
try:
_TTL = int(os.environ.get('SERVERKIT_REGISTRY_TTL', '3600'))
except ValueError:
@@ -85,9 +100,10 @@ def _load_bundled():
def _fetch_remote():
- if not REGISTRY_URL:
+ url = _registry_url()
+ if not url:
return None
- resp = requests.get(REGISTRY_URL, timeout=15, headers={
+ resp = requests.get(url, timeout=15, headers={
'Accept': 'application/json',
'User-Agent': 'ServerKit-Registry/1.0',
})
@@ -109,7 +125,7 @@ def refresh(force=False):
if entries is not None:
source = 'remote'
except Exception as e:
- logger.warning(f'Registry fetch failed ({REGISTRY_URL}): {e}')
+ logger.warning(f'Registry fetch failed ({_registry_url()}): {e}')
if entries is None:
# Keep the last good remote cache if we have one; else bundled.
diff --git a/backend/tests/conftest.py b/backend/tests/conftest.py
index 1b8d76e4..07278a5b 100644
--- a/backend/tests/conftest.py
+++ b/backend/tests/conftest.py
@@ -11,6 +11,11 @@ if _backend not in sys.path:
os.environ.setdefault('FLASK_ENV', 'testing')
+# Keep the suite offline: unset SERVERKIT_REGISTRY_URL now means "use the
+# public serverkit-extensions registry", while set-but-EMPTY means explicitly
+# disabled (bundled index only) — which is what hermetic tests want.
+os.environ.setdefault('SERVERKIT_REGISTRY_URL', '')
+
# Tests use a FILE-backed SQLite, not :memory:. Flask-SQLAlchemy serves an
# in-memory SQLite from a single shared connection (StaticPool), so a test that
# drives the DB from a background thread (e.g. the agent send_command round-trip
diff --git a/backend/tests/test_registry.py b/backend/tests/test_registry.py
index a7f7da44..0b6d854e 100644
--- a/backend/tests/test_registry.py
+++ b/backend/tests/test_registry.py
@@ -151,3 +151,28 @@ def test_update_flow(app, plugin_dirs, monkeypatch):
updated = plugin_service.update_plugin(plugin.id)
assert updated.version == '2.0.0'
assert InstalledPlugin.query.filter_by(slug='regext').count() == 1
+
+
+# --------------------------------------------------------------------------- #
+# Registry URL resolution (live default vs explicit opt-out)
+# --------------------------------------------------------------------------- #
+
+def test_registry_url_defaults_to_public_index(monkeypatch):
+ """Unset env → the curated serverkit-extensions raw index (the go-live
+ default). conftest pins it EMPTY suite-wide, so simulate unset here."""
+ monkeypatch.delenv('SERVERKIT_REGISTRY_URL', raising=False)
+ assert registry_service._registry_url() == registry_service.DEFAULT_REGISTRY_URL
+ assert 'serverkit-extensions' in registry_service.DEFAULT_REGISTRY_URL
+
+
+def test_registry_url_empty_disables_remote(monkeypatch):
+ """Explicitly-empty env disables the remote entirely (bundled only) —
+ the hermetic-test/air-gapped escape hatch."""
+ monkeypatch.setenv('SERVERKIT_REGISTRY_URL', '')
+ assert registry_service._registry_url() == ''
+ assert registry_service._fetch_remote() is None
+
+
+def test_registry_url_env_override_wins(monkeypatch):
+ monkeypatch.setenv('SERVERKIT_REGISTRY_URL', 'https://example.test/index.json')
+ assert registry_service._registry_url() == 'https://example.test/index.json'
diff --git a/docs/EXTENSIONS_REGISTRY.md b/docs/EXTENSIONS_REGISTRY.md
index 36bb552c..e31a443a 100644
--- a/docs/EXTENSIONS_REGISTRY.md
+++ b/docs/EXTENSIONS_REGISTRY.md
@@ -11,9 +11,12 @@ This document is the format spec (task #16) and the publisher guide (task #21).
## How a panel consumes the registry
-- The panel fetches the index from `SERVERKIT_REGISTRY_URL` (env var). When unset,
- or when the fetch fails (offline), it falls back to the **last good cache**, then
- to a **bundled copy** shipped at `backend/app/data/registry_index.json`. The
+- The panel fetches the index from `SERVERKIT_REGISTRY_URL` (env var). When unset
+ it defaults to the curated public registry
+ (`https://raw.githubusercontent.com/jhd3197/serverkit-extensions/main/index.json`);
+ set it **empty** to disable remote fetching entirely (air-gapped panels). When
+ the fetch fails (offline), it falls back to the **last good cache**, then to a
+ **bundled copy** shipped at `backend/app/data/registry_index.json`. The
Marketplace never blanks.
- Results are cached in-memory for `SERVERKIT_REGISTRY_TTL` seconds (default 3600).
- Discovery is **read-only** — nothing in the registry is ever auto-installed.