api: client default URLs should come from stack.toml not string literals #137

Closed
opened 2026-03-23 23:41:18 +00:00 by kert · 0 comments
Owner

Problem

Python API clients have hardcoded default base URLs:

  • api.clients.gitea — http://gitea:3000/api/v1
  • api.clients.woodpecker — http://woodpecker-server:8000/api
  • api.clients.rustfs — http://rustfs:9000
  • api.auth.provision — duplicates of above (lines 212, 300)
  • api.auth.deploy — duplicates (lines 73, 95)

Fix

Add a [services] section to stack.toml:

[services]
gitea = "http://gitea:3000"
woodpecker = "http://woodpecker-server:8000"
rustfs = "http://rustfs:9000"

Clients read from conf with env var override:

def __init__(self, token, base_url=None):
    self.base_url = base_url or os.environ.get('GITEA_URL') or f'{cfg.services.gitea}/api/v1'

Remove duplicated defaults from auth modules — they should call the clients.

Files

  • stack.toml
  • src/api/clients/gitea/client.py
  • src/api/clients/woodpecker/client.py
  • src/api/clients/rustfs/client.py
  • src/api/auth/provision.py
  • src/api/auth/deploy.py
## Problem Python API clients have hardcoded default base URLs: - `api.clients.gitea` — `http://gitea:3000/api/v1` - `api.clients.woodpecker` — `http://woodpecker-server:8000/api` - `api.clients.rustfs` — `http://rustfs:9000` - `api.auth.provision` — duplicates of above (lines 212, 300) - `api.auth.deploy` — duplicates (lines 73, 95) ## Fix Add a `[services]` section to `stack.toml`: ```toml [services] gitea = "http://gitea:3000" woodpecker = "http://woodpecker-server:8000" rustfs = "http://rustfs:9000" ``` Clients read from conf with env var override: ```python def __init__(self, token, base_url=None): self.base_url = base_url or os.environ.get('GITEA_URL') or f'{cfg.services.gitea}/api/v1' ``` Remove duplicated defaults from auth modules — they should call the clients. ## Files - `stack.toml` - `src/api/clients/gitea/client.py` - `src/api/clients/woodpecker/client.py` - `src/api/clients/rustfs/client.py` - `src/api/auth/provision.py` - `src/api/auth/deploy.py`
kert added this to the P18: Config Consolidation — eliminate hardcoded values milestone 2026-03-23 23:41:18 +00:00
kert added the configapi labels 2026-03-23 23:41:18 +00:00
kert closed this issue 2026-03-23 23:51:30 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: homelab/stack#137