Skip to content

Commit

Permalink
skip authorization if in development/testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ShakyaMajumdar committed Jul 18, 2024
1 parent 11f0384 commit 231ecad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/loader/constants.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
"""Loader settings."""

from os import getenv

from pydantic_settings import BaseSettings

GIT_SHA = getenv("GIT_SHA", "development")


class _Settings(BaseSettings):
"""Settings for the Dragonfly Loader."""
Expand Down
6 changes: 4 additions & 2 deletions src/loader/loader.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
from httpx import Client
from letsbuilda.pypi import PyPIServices

from loader.constants import Settings
from loader.constants import GIT_SHA, Settings

SKIP_AUTH = GIT_SHA in {"testing", "development"}


def build_authorization_header(access_token: str) -> dict[str, str]:
Expand Down Expand Up @@ -47,7 +49,7 @@ def load_packages(packages: list[tuple[str, str]], *, http_client: Client, acces

def main(*, http_client: Client, pypi_client: PyPIServices) -> None:
"""Run the loader."""
access_token = get_access_token(http_client=http_client)
access_token = "DEVELOPMENT" if SKIP_AUTH else get_access_token(http_client=http_client)

packages = fetch_packages(pypi_client=pypi_client)

Expand Down

0 comments on commit 231ecad

Please sign in to comment.