Skip to content

Commit 89e1729

Browse files
committed
banner for env overrides
1 parent c4bb19c commit 89e1729

1 file changed

Lines changed: 34 additions & 7 deletions

File tree

src/redfetch/config_firstrun.py

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -213,13 +213,40 @@ def first_run_setup():
213213

214214
effective_env = env_from_file or os.environ.get("REDFETCH_ENV") or "LIVE"
215215

216-
console.print(
217-
Panel(
218-
f"[bold yellow]Server type: [cyan]{effective_env}[/cyan][/bold yellow]\n"
219-
f"Configuration directory: {config_dir}",
220-
expand=False,
221-
)
222-
)
216+
# Banner always shows server/config dir, plus effective env overrides.
217+
notice_lines: list[str] = [
218+
f"[bold yellow]Server type: [cyan]{effective_env}[/cyan][/bold yellow]",
219+
f"Configuration directory: {config_dir}",
220+
]
221+
222+
# Base URL override (show if explicitly set via env).
223+
base_url_override = os.environ.get("REDFETCH_BASE_URL")
224+
if base_url_override:
225+
notice_lines.append(f"[bold red]REDFETCH_BASE_URL:[/bold red] {base_url_override}")
226+
227+
# Auth overrides: API key always takes precedence over OAuth.
228+
api_key_present = bool(os.environ.get("REDGUIDES_API_KEY"))
229+
if api_key_present:
230+
notice_lines.append("[bold yellow]Auth:[/bold yellow] API key via REDGUIDES_API_KEY")
231+
# Only meaningful alongside API key (used to skip a lookup).
232+
if os.environ.get("REDGUIDES_USER_ID"):
233+
notice_lines.append("[bold yellow]Auth:[/bold yellow] REDGUIDES_USER_ID set via env")
234+
else:
235+
# Only surface OAuth env vars when API key isn't overriding them.
236+
if os.environ.get("REDFETCH_OAUTH_CLIENT_ID"):
237+
notice_lines.append("[bold yellow]OAuth:[/bold yellow] Client ID set via env")
238+
if os.environ.get("REDFETCH_OAUTH_CLIENT_SECRET"):
239+
notice_lines.append("[bold yellow]OAuth:[/bold yellow] Client secret set via env")
240+
oauth_redirect_override = os.environ.get("REDFETCH_OAUTH_REDIRECT_URI")
241+
if oauth_redirect_override:
242+
notice_lines.append(f"[bold yellow]OAuth redirect:[/bold yellow] {oauth_redirect_override}")
243+
244+
# PyPI URL override
245+
pypi_url_override = os.environ.get("REDFETCH_PYPI_URL")
246+
if pypi_url_override:
247+
notice_lines.append(f"[bold yellow]REDFETCH_PYPI_URL:[/bold yellow] {pypi_url_override}")
248+
249+
console.print(Panel("\n".join(notice_lines), expand=False))
223250
return config_dir
224251
else:
225252
console.print("[bold red]Environment file (.env) not found. Rerunning setup.[/bold red]")

0 commit comments

Comments
 (0)