Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip authorization if in development/testing #48

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"}
ShakyaMajumdar marked this conversation as resolved.
Show resolved Hide resolved


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
Loading